From: Tejun Heo <tj@kernel.org>
To: Changwoo Min <changwoo@igalia.com>
Cc: void@manifault.com, arighi@nvidia.com, kernel-dev@igalia.com,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/7] sched_ext: Implement event counter infrastructure and add an event
Date: Fri, 17 Jan 2025 06:24:45 -1000 [thread overview]
Message-ID: <Z4qETRVdvJLDSUHg@slm.duckdns.org> (raw)
In-Reply-To: <16a9e631-22c0-454a-b56f-c5206ec3d1dc@igalia.com>
Hello,
On Fri, Jan 17, 2025 at 04:08:45PM +0900, Changwoo Min wrote:
> $COMPONENT_$EVENT sounds more systematic. Thanks for the
> suggestion. What about SELECT_CPU_FALLBACK?
Sounds good.
> > This feels a bit odd to me. Why does it need both the struct fields and
> > indices? Can we do either one of those?
>
> Before submitting the patch set, I tested one approach using
> purely enums storing the actual counters in an array and another
> (current) approach using struct fields. I rejected the first
> approach because the BPF verifier does not allow changing the
> array size, causing the BPF binary compatibility problem. The
That makes sense. It'd be useful to note that on top of the struct
definition.
> second approach is satisfactory regarding the BPF binary
> compatibility by CO-RE. However, it is a little bit cumbersome to
> iterate all the events, so I added the enums. I know the enums
> are only usable in the kernel code due to the binary
> compatibility, but I thought adding the enums rather than
> bloating the scx_dump_state() code at the end would be better.
> Does it make sense to you?
Let's just use the structs and open code dumping. We can pack the dump
output better that way too and I don't think BPF scheds would have much use
for enum iterations.
...
> > > +/**
> > > + * scx_add_event - Increase an event counter for 'name' by 'cnt'
> > > + * @name: an event name defined in struct scx_event_stat
> > > + * @cnt: the number of the event occured
> > > + */
> > > +#define scx_add_event(name, cnt) ({ \
> > > + struct scx_event_stat *__e; \
> > > + __e = get_cpu_ptr(&event_stats); \
> > > + WRITE_ONCE(__e->name, __e->name+ (cnt)); \
> > > + put_cpu_ptr(&event_stats); \
> >
> > this_cpu_add()?
>
> That's handier. I will change it.
Note that there's __this_cpu_add() too which can be used from sections of
code that already disables preemption. On x86, both variants cost the same
but on arm __this_cpu_add() is cheaper as it can skip preemption off/on.
Given that most of these counters are modified while holding rq lock, it may
make sense to provide __ version too.
...
> > Also, I'm not sure this is a useful event to count. False ops_cpu_valid()
> > indicates that the returned CPU is not even possible and the scheduler is
> > ejected right away. What's more interesting is
> > kernel/sched/core.c::select_task_rq() tripping on !is_cpu_allowed() and
> > falling back using select_fallback_rq().
> >
> > We can either hook into core.c or just compare the ops.select_cpu() picked
> > CPU against the CPU the task ends up on in enqueue_task_scx().
>
> Modifying core.c will be more direct and straightforward. Also,
> I think it would be better to separate this commit into two: one
> for the infra-structure and another for the SELECT_CPU_FALLBACK
> event, which touches core.c. I will move the necessary code in
> the infrastructure into kernel/sched/sched.h, so we can use
> scx_add_event() in core.c.
Hmm.... yeah, both approaches have pros and cons but I kinda like the idea
of restricting the events within ext.c and here detecting the fallback
condition is pretty trivial. I don't know.
Thanks.
--
tejun
next prev parent reply other threads:[~2025-01-17 16:24 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-16 15:15 [PATCH 0/7] sched_ext: Implement core event counters Changwoo Min
2025-01-16 15:15 ` [PATCH 1/7] sched_ext: Implement event counter infrastructure and add an event Changwoo Min
2025-01-17 1:33 ` Tejun Heo
2025-01-17 7:08 ` Changwoo Min
2025-01-17 16:24 ` Tejun Heo [this message]
2025-01-18 0:27 ` Changwoo Min
2025-01-22 0:42 ` Tejun Heo
2025-01-22 1:37 ` Changwoo Min
2025-01-17 9:49 ` Andrea Righi
2025-01-17 16:26 ` Tejun Heo
2025-01-18 0:00 ` Changwoo Min
2025-01-21 15:00 ` Leonardo Temperanza
2025-01-22 1:45 ` Changwoo Min
2025-01-16 15:15 ` [PATCH 2/7] sched_ext: Add an event, SCX_EVENT_OFFLINE_LOCAL_DSQ Changwoo Min
2025-01-17 1:37 ` Tejun Heo
2025-01-17 7:11 ` Changwoo Min
2025-01-16 15:15 ` [PATCH 3/7] sched_ext: Add an event, SCX_EVENT_CNTD_RUN_WO_ENQ Changwoo Min
2025-01-17 1:39 ` Tejun Heo
2025-01-17 7:12 ` Changwoo Min
2025-01-16 15:15 ` [PATCH 4/7] sched_ext: Add an event, SCX_EVENT_ENQ_LOCAL_EXITING Changwoo Min
2025-01-17 1:40 ` Tejun Heo
2025-01-17 7:12 ` Changwoo Min
2025-01-16 15:15 ` [PATCH 5/7] sched_ext: Add an event, SCX_EVENT_RQ_BYPASSING_OPS Changwoo Min
2025-01-17 1:41 ` Tejun Heo
2025-01-17 7:31 ` Changwoo Min
2025-01-17 16:14 ` Tejun Heo
2025-01-16 15:15 ` [PATCH 6/7] sched_ext: Add scx_bpf_event_stat() and scx_read_event() for BPF schedulers Changwoo Min
2025-01-16 15:15 ` [PATCH 7/7] sched_ext: Print core event count in scx_central scheduler Changwoo Min
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=Z4qETRVdvJLDSUHg@slm.duckdns.org \
--to=tj@kernel.org \
--cc=arighi@nvidia.com \
--cc=changwoo@igalia.com \
--cc=kernel-dev@igalia.com \
--cc=linux-kernel@vger.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®