mirror of
https://github.com/nxp-imx/linux-imx.git
synced 2025-07-13 12:49:35 +02:00
ANDROID: fs/proc: Perform priority inheritance around access_remote_vm()
It holds mmap_sem lock which is a hot path. Some debug daemons can end
up holding this lock to get the cmdline of a process, which can result
in slowing down this process.
Add hooks around the calls to allow vendors to implement a simple prio
inheritance scheme to deal with this.
Bug: 344826816
Bug: 289412815
Signed-off-by: Qais Yousef <qyousef@google.com>
Change-Id: I160637b30e5bd58d5978b25be8a21ce025175ec3
(cherry picked from commit b821a3c8fc
)
[Trivial conflict in include/trace/hooks/sched.h due to new code added.
And in vendor_hooks.c due to code ordering]
Signed-off-by: Qais Yousef <qyousef@google.com>
This commit is contained in:
parent
9ad961ed05
commit
9f6cb7cdd8
|
@ -99,6 +99,7 @@
|
||||||
#include <linux/ksm.h>
|
#include <linux/ksm.h>
|
||||||
#include <linux/cpufreq_times.h>
|
#include <linux/cpufreq_times.h>
|
||||||
#include <trace/events/oom.h>
|
#include <trace/events/oom.h>
|
||||||
|
#include <trace/hooks/sched.h>
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
#include "fd.h"
|
#include "fd.h"
|
||||||
|
|
||||||
|
@ -345,13 +346,24 @@ static ssize_t get_task_cmdline(struct task_struct *tsk, char __user *buf,
|
||||||
size_t count, loff_t *pos)
|
size_t count, loff_t *pos)
|
||||||
{
|
{
|
||||||
struct mm_struct *mm;
|
struct mm_struct *mm;
|
||||||
|
bool prio_inherited = false;
|
||||||
|
int saved_prio;
|
||||||
ssize_t ret;
|
ssize_t ret;
|
||||||
|
|
||||||
mm = get_task_mm(tsk);
|
mm = get_task_mm(tsk);
|
||||||
if (!mm)
|
if (!mm)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* access_remote_vm() holds the hot mmap_sem lock which can cause the
|
||||||
|
* task for which we read cmdline etc for by some debug deamon to slow
|
||||||
|
* down and suffer a performance hit. Especially if the reader task has
|
||||||
|
* a low nice value.
|
||||||
|
*/
|
||||||
|
trace_android_vh_prio_inheritance(tsk, &saved_prio, &prio_inherited);
|
||||||
ret = get_mm_cmdline(mm, buf, count, pos);
|
ret = get_mm_cmdline(mm, buf, count, pos);
|
||||||
|
if (prio_inherited)
|
||||||
|
trace_android_vh_prio_restore(saved_prio);
|
||||||
mmput(mm);
|
mmput(mm);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
@ -459,6 +459,14 @@ DECLARE_RESTRICTED_HOOK(android_rvh_update_rt_rq_load_avg,
|
||||||
TP_PROTO(u64 now, struct rq *rq, struct task_struct *tsk, int running),
|
TP_PROTO(u64 now, struct rq *rq, struct task_struct *tsk, int running),
|
||||||
TP_ARGS(now, rq, tsk, running), 1);
|
TP_ARGS(now, rq, tsk, running), 1);
|
||||||
|
|
||||||
|
DECLARE_HOOK(android_vh_prio_inheritance,
|
||||||
|
TP_PROTO(struct task_struct *p, int *saved_prio, bool *prio_inherited),
|
||||||
|
TP_ARGS(p, saved_prio, prio_inherited));
|
||||||
|
|
||||||
|
DECLARE_HOOK(android_vh_prio_restore,
|
||||||
|
TP_PROTO(int saved_prio),
|
||||||
|
TP_ARGS(saved_prio));
|
||||||
|
|
||||||
/* macro versions of hooks are no longer required */
|
/* macro versions of hooks are no longer required */
|
||||||
|
|
||||||
#endif /* _TRACE_HOOK_SCHED_H */
|
#endif /* _TRACE_HOOK_SCHED_H */
|
||||||
|
|
|
@ -117,3 +117,5 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_update_rt_rq_load_avg);
|
||||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_uclamp_validate);
|
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_uclamp_validate);
|
||||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_set_sugov_sched_attr);
|
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_set_sugov_sched_attr);
|
||||||
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_set_iowait);
|
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_set_iowait);
|
||||||
|
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_prio_inheritance);
|
||||||
|
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_prio_restore);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user