
hulk inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/ICAOAT -------------------------------- Add mutex interference track support Signed-off-by: Pu Lehui <pulehui@huawei.com> --- include/linux/cgroup.h | 1 + kernel/cgroup/ifs.c | 3 +++ kernel/locking/mutex.c | 5 +++++ 3 files changed, 9 insertions(+) diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h index f8d65dedcd85..562e222202b2 100644 --- a/include/linux/cgroup.h +++ b/include/linux/cgroup.h @@ -863,6 +863,7 @@ void cgroup_move_task_to_root(struct task_struct *tsk); enum ifs_types { IFS_SPINLOCK, + IFS_MUTEX, IFS_SMT, IFS_RUNDELAY, IFS_WAKELAT, diff --git a/kernel/cgroup/ifs.c b/kernel/cgroup/ifs.c index 82817c7d821a..8af919a63ba5 100644 --- a/kernel/cgroup/ifs.c +++ b/kernel/cgroup/ifs.c @@ -201,6 +201,9 @@ static const char *ifs_type_name(int type) case IFS_SPINLOCK: name = "spinlock"; break; + case IFS_MUTEX: + name = "mutex"; + break; case IFS_SMT: name = "smt"; break; diff --git a/kernel/locking/mutex.c b/kernel/locking/mutex.c index d973fe6041bf..1003afe8dd74 100644 --- a/kernel/locking/mutex.c +++ b/kernel/locking/mutex.c @@ -24,6 +24,7 @@ #include <linux/sched/rt.h> #include <linux/sched/wake_q.h> #include <linux/sched/debug.h> +#include <linux/cgroup.h> #include <linux/export.h> #include <linux/spinlock.h> #include <linux/interrupt.h> @@ -572,6 +573,7 @@ __mutex_lock_common(struct mutex *lock, unsigned int state, unsigned int subclas { struct mutex_waiter waiter; struct ww_mutex *ww; + u64 ifs_clock; int ret; if (!use_ww_ctx) @@ -647,6 +649,7 @@ __mutex_lock_common(struct mutex *lock, unsigned int state, unsigned int subclas set_current_state(state); trace_contention_begin(lock, LCB_F_MUTEX); + cgroup_ifs_enter_lock(&ifs_clock); for (;;) { bool first; @@ -719,6 +722,7 @@ __mutex_lock_common(struct mutex *lock, unsigned int state, unsigned int subclas skip_wait: /* got the lock - cleanup and rejoice! */ lock_acquired(&lock->dep_map, ip); + cgroup_ifs_leave_lock(ifs_clock, IFS_MUTEX); trace_contention_end(lock, 0); if (ww_ctx) @@ -732,6 +736,7 @@ __mutex_lock_common(struct mutex *lock, unsigned int state, unsigned int subclas __set_current_state(TASK_RUNNING); __mutex_remove_waiter(lock, &waiter); err_early_kill: + cgroup_ifs_leave_lock(ifs_clock, IFS_MUTEX); trace_contention_end(lock, ret); raw_spin_unlock(&lock->wait_lock); debug_mutex_free_waiter(&waiter); -- 2.34.1