提交 7b00adb6 编写于 作者: C Chen Wandun 提交者: Zheng Zengkai

psi, tracepoint: introduce tracepoints for psi_memstall_{enter, leave}

hulk inclusion
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I562O9
CVE: NA
backport: openEuler-22.03-LTS

--------------------------------

Two tracepoints are added we can easily use other tools
such as ebpf, ftrace, perf to monitor the memstall data
and do some analysis.

The output of these tracepoints is,
      kcompactd0-58      [001] ....   902.709565: psi_memstall_enter: kcompactd
         kswapd0-132     [003] ....   902.709569: psi_memstall_leave: balance_pgdat
      kcompactd0-58      [001] ....   902.775230: psi_memstall_leave: kcompactd
         kswapd0-132     [003] ....  1337.754598: psi_memstall_enter: balance_pgdat
         kswapd0-132     [003] ....  1337.756076: psi_memstall_leave: balance_pgdat
      kcompactd0-58      [003] ....  1337.756213: psi_memstall_enter: kcompactd
      kcompactd0-58      [003] ....  1337.893188: psi_memstall_leave: kcompactd
Signed-off-by: NChen Wandun <chenwandun@huawei.com>
Reviewed-by: NKefeng Wang <wangkefeng.wang@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 915777f4
...@@ -705,6 +705,33 @@ DECLARE_TRACE(sched_update_nr_running_tp, ...@@ -705,6 +705,33 @@ DECLARE_TRACE(sched_update_nr_running_tp,
TP_PROTO(struct rq *rq, int change), TP_PROTO(struct rq *rq, int change),
TP_ARGS(rq, change)); TP_ARGS(rq, change));
DECLARE_EVENT_CLASS(psi_memstall_template,
TP_PROTO(unsigned long function),
TP_ARGS(function),
TP_STRUCT__entry(
__field(unsigned long, function)
),
TP_fast_assign(
__entry->function = function;
),
TP_printk("%ps", (void *)__entry->function)
);
DEFINE_EVENT(psi_memstall_template, psi_memstall_enter,
TP_PROTO(unsigned long function),
TP_ARGS(function)
);
DEFINE_EVENT(psi_memstall_template, psi_memstall_leave,
TP_PROTO(unsigned long function),
TP_ARGS(function)
);
#endif /* _TRACE_SCHED_H */ #endif /* _TRACE_SCHED_H */
/* This part must be outside protection */ /* This part must be outside protection */
......
...@@ -142,6 +142,8 @@ ...@@ -142,6 +142,8 @@
#include <linux/psi.h> #include <linux/psi.h>
#include "sched.h" #include "sched.h"
#include <trace/events/sched.h>
static int psi_bug __read_mostly; static int psi_bug __read_mostly;
DEFINE_STATIC_KEY_FALSE(psi_disabled); DEFINE_STATIC_KEY_FALSE(psi_disabled);
...@@ -904,6 +906,8 @@ void psi_memstall_enter(unsigned long *flags) ...@@ -904,6 +906,8 @@ void psi_memstall_enter(unsigned long *flags)
*flags = current->in_memstall; *flags = current->in_memstall;
if (*flags) if (*flags)
return; return;
trace_psi_memstall_enter(_RET_IP_);
/* /*
* in_memstall setting & accounting needs to be atomic wrt * in_memstall setting & accounting needs to be atomic wrt
* changes to the task's scheduling state, otherwise we can * changes to the task's scheduling state, otherwise we can
...@@ -933,6 +937,8 @@ void psi_memstall_leave(unsigned long *flags) ...@@ -933,6 +937,8 @@ void psi_memstall_leave(unsigned long *flags)
if (*flags) if (*flags)
return; return;
trace_psi_memstall_leave(_RET_IP_);
/* /*
* in_memstall clearing & accounting needs to be atomic wrt * in_memstall clearing & accounting needs to be atomic wrt
* changes to the task's scheduling state, otherwise we could * changes to the task's scheduling state, otherwise we could
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册