mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Changwoo Min <changwoo@igalia.com>
To: Andrea Righi <arighi@nvidia.com>
Cc: tj@kernel.org, void@manifault.com, kernel-dev@igalia.com,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 2/2] sched_ext: Add trace point to track sched_ext core events
Date: Tue, 4 Mar 2025 19:39:02 +0900	[thread overview]
Message-ID: <9db68100-65d0-43e5-a1c0-2aff771f173f@igalia.com> (raw)
In-Reply-To: <Z8agpJNFR30DmJG4@gpd3>

Hi Andrea,

On 25. 3. 4. 15:41, Andrea Righi wrote:
> Hi Changwoo,
> 
> On Tue, Mar 04, 2025 at 10:27:40AM +0900, Changwoo Min wrote:
>> Add tracing support to track sched_ext core events
>> (/sched_ext/sched_ext_event). This may be useful for debugging sched_ext
>> schedulers that trigger a particular event.
>>
>> The trace point can be used as other trace points, so it can be used in,
>> for example, `perf trace` and BPF programs, as follows:
>>
>> ======
>> $> sudo perf trace -e sched_ext:sched_ext_event --filter 'name == "SCX_EV_ENQ_SLICE_DFL"'
>> ======
>>
>> ======
>> struct tp_sched_ext_event {
>> 	struct trace_entry ent;
>> 	u32 __data_loc_name;
>> 	s64 delta;
>> };
>>
>> SEC("tracepoint/sched_ext/sched_ext_event")
>> int rtp_add_event(struct tp_sched_ext_event *ctx)
>> {
>> 	char event_name[128];
>> 	unsigned short offset = ctx->__data_loc_name & 0xFFFF;
>>          bpf_probe_read_str((void *)event_name, 128, (char *)ctx + offset);
>>
>> 	bpf_printk("name %s   delta %lld", event_name, ctx->delta);
>> 	return 0;
>> }
>> ======
>>
>> Signed-off-by: Changwoo Min <changwoo@igalia.com>
>> ---
>>   include/trace/events/sched_ext.h | 19 +++++++++++++++++++
>>   kernel/sched/ext.c               |  2 ++
>>   2 files changed, 21 insertions(+)
>>
>> diff --git a/include/trace/events/sched_ext.h b/include/trace/events/sched_ext.h
>> index fe19da7315a9..3d04b9819548 100644
>> --- a/include/trace/events/sched_ext.h
>> +++ b/include/trace/events/sched_ext.h
>> @@ -26,6 +26,25 @@ TRACE_EVENT(sched_ext_dump,
>>   	)
>>   );
>>   
>> +TRACE_EVENT(sched_ext_event,
>> +	    TP_PROTO(const char *name, __u64 delta),
> 
> It shouldn't be __s64 here as well?

Ah, my bad. Thank you for catching this!

> 
> Thanks,
> -Andrea
> 
>> +	    TP_ARGS(name, delta),
>> +
>> +	TP_STRUCT__entry(
>> +		__string(name, name)
>> +		__field(	__s64,		delta		)
>> +	),
>> +
>> +	TP_fast_assign(
>> +		__assign_str(name);
>> +		__entry->delta		= delta;
>> +	),
>> +
>> +	TP_printk("name %s delta %lld",
>> +		  __get_str(name), __entry->delta
>> +	)
>> +);
>> +
>>   #endif /* _TRACE_SCHED_EXT_H */
>>   
>>   /* This part must be outside protection */
>> diff --git a/kernel/sched/ext.c b/kernel/sched/ext.c
>> index 686629a860f3..debcd1cf2de9 100644
>> --- a/kernel/sched/ext.c
>> +++ b/kernel/sched/ext.c
>> @@ -1554,6 +1554,7 @@ static DEFINE_PER_CPU(struct scx_event_stats, event_stats_cpu);
>>    */
>>   #define scx_add_event(name, cnt) do {						\
>>   	this_cpu_add(event_stats_cpu.name, cnt);				\
>> +	trace_sched_ext_event(#name, cnt);					\
>>   } while(0)
>>   
>>   /**
>> @@ -1565,6 +1566,7 @@ static DEFINE_PER_CPU(struct scx_event_stats, event_stats_cpu);
>>    */
>>   #define __scx_add_event(name, cnt) do {						\
>>   	__this_cpu_add(event_stats_cpu.name, cnt);				\
>> +	trace_sched_ext_event(#name, cnt);					\
>>   } while(0)
>>   
>>   /**
>> -- 
>> 2.48.1
>>
> 


      reply	other threads:[~2025-03-04 10:39 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-04  1:27 [PATCH v3 0/2] sched_ext: Add trace point to " Changwoo Min
2025-03-04  1:27 ` [PATCH v3 1/2] sched_ext: Change the event type from u64 to s64 Changwoo Min
2025-03-04  1:27 ` [PATCH v3 2/2] sched_ext: Add trace point to track sched_ext core events Changwoo Min
2025-03-04  6:41   ` Andrea Righi
2025-03-04 10:39     ` Changwoo Min [this message]

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=9db68100-65d0-43e5-a1c0-2aff771f173f@igalia.com \
    --to=changwoo@igalia.com \
    --cc=arighi@nvidia.com \
    --cc=kernel-dev@igalia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tj@kernel.org \
    --cc=void@manifault.com \
    /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

all inboxes | Powered by JetHome®