From: Alan Maguire <alan.maguire@oracle.com>
To: dtrace@lists.linux.dev
Cc: dtrace-devel@oss.oracle.com, Alan Maguire <alan.maguire@oracle.com>
Subject: [PATCH v3 dtrace 4/4] sched: fix on-cpu firing for kernels < 5.16
Date: Wed, 16 Oct 2024 16:54:09 +0100 [thread overview]
Message-ID: <20241016155409.4038017-5-alan.maguire@oracle.com> (raw)
In-Reply-To: <20241016155409.4038017-1-alan.maguire@oracle.com>
The solution for sched:::on-cpu firing (probing
__perf_event_task_sched_in) only works on 5.16 and later as
the relevant function is not in available_filter_functions
in earlier kernels.
Instead use the fbt::finish_task_switch:return probe as this
will cover .isra.0-suffixed optimizations if they are applied
to finish_task_switch().
Signed-off-by: Alan Maguire <alan.maguire@oracle.com>
---
libdtrace/dt_prov_sched.c | 23 ++---------------------
1 file changed, 2 insertions(+), 21 deletions(-)
diff --git a/libdtrace/dt_prov_sched.c b/libdtrace/dt_prov_sched.c
index 4fbd24ab..796f39af 100644
--- a/libdtrace/dt_prov_sched.c
+++ b/libdtrace/dt_prov_sched.c
@@ -28,7 +28,7 @@ static probe_dep_t probes[] = {
{ "off-cpu",
DTRACE_PROBESPEC_NAME, "rawtp:sched::sched_switch" },
{ "on-cpu",
- DTRACE_PROBESPEC_NAME, "fbt::__perf_event_task_sched_in:entry" },
+ DTRACE_PROBESPEC_NAME, "fbt:vmlinux:finish_task_switch:return" },
{ "surrender",
DTRACE_PROBESPEC_NAME, "fbt::do_sched_yield:entry" },
{ "tick",
@@ -157,26 +157,7 @@ static int trampoline(dt_pcb_t *pcb, uint_t exitlbl)
*/
static void enable(dtrace_hdl_t *dtp, dt_probe_t *prp)
{
- struct perf_event_attr attr = {};
- int swfd;
-
- if (strcmp(prp->desc->prb, "on-cpu") != 0)
- return dt_sdt_enable(dtp, prp);
-
- memset(&attr, 0, sizeof(attr));
- attr.size = sizeof(attr);
- attr.type = PERF_TYPE_SOFTWARE;
- attr.config = PERF_COUNT_SW_CONTEXT_SWITCHES;
- attr.freq = 1;
- attr.sample_freq = 1000;
- attr.context_switch = 1;
-
- swfd = dt_perf_event_open(&attr, -1, 0, -1, 0);
- if (swfd < 0)
- dt_dprintf("perf event open failed for context_switch: %d\n", errno);
- else
- prp->prv_data = (void *)(long)swfd;
- dt_sdt_enable(dtp, prp);
+ return dt_sdt_enable(dtp, prp);
}
static void detach(dtrace_hdl_t *dtp, const dt_probe_t *prp)
--
2.43.5
next prev parent reply other threads:[~2024-10-16 15:54 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-16 15:54 [PATCH v3 dtrace 0/4] kprobe support for .isra.0, sched fix Alan Maguire
2024-10-16 15:54 ` [PATCH v3 dtrace 1/4] dt_provider_tp: add optional event data, freed on tp free Alan Maguire
2024-11-14 5:26 ` [DTrace-devel] " Kris Van Hees
2024-11-14 16:45 ` Alan Maguire
2024-10-16 15:54 ` [PATCH v3 dtrace 2/4] fbt: support "."-suffixed functions for kprobes Alan Maguire
2024-11-28 2:22 ` Kris Van Hees
2024-11-28 9:58 ` Alan Maguire
2024-10-16 15:54 ` [PATCH v3 dtrace 3/4] fbt: avoid mix of kprobe, fprobe implementations for used probes Alan Maguire
2024-10-16 15:54 ` Alan Maguire [this message]
2024-10-18 15:41 ` [PATCH v3 dtrace 0/4] kprobe support for .isra.0, sched fix Kris Van Hees
2024-10-18 16:15 ` Alan Maguire
2024-10-18 18:38 ` Kris Van Hees
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241016155409.4038017-5-alan.maguire@oracle.com \
--to=alan.maguire@oracle.com \
--cc=dtrace-devel@oss.oracle.com \
--cc=dtrace@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox