Re: [PATCH v2] sched/debug: Add new tracepoint to track cpu_capacity

From: Qais Yousef
Date: Mon Sep 07 2020 - 06:48:55 EST


Hi Dietmar

On 09/02/20 12:44, Dietmar Eggemann wrote:
> + Phil Auld <pauld@xxxxxxxxxx>
>
> On 28/08/2020 19:26, Qais Yousef wrote:
> > On 08/28/20 19:10, Dietmar Eggemann wrote:
> >> On 28/08/2020 12:27, Qais Yousef wrote:
> >>> On 08/28/20 10:00, vincent.donnefort@xxxxxxx wrote:
> >>>> From: Vincent Donnefort <vincent.donnefort@xxxxxxx>
>
> [...]
>
> >> Can you remind me why we have all these helper functions like
> >> sched_trace_rq_cpu_capacity?
> >
> > struct rq is defined in kernel/sched/sched.h. It's not exported. Exporting
> > these helper functions was the agreement to help modules trace internal info.
> > By passing generic info you decouple the tracepoint from giving specific info
> > and allow the modules to extract all the info they need from the same
> > tracepoint. IE: if you need more than just cpu_capacity from this tracepoint,
> > you can get that without having to continuously add extra arguments everytime
> > you need an extra piece of info. Unless this info is not in the rq of course.
>
> I think this decoupling is not necessary. The natural place for those
> scheduler trace_event based on trace_points extension files is
> kernel/sched/ and here the internal sched.h can just be included.
>
> If someone really wants to build this as an out-of-tree module there is
> an easy way to make kernel/sched/sched.h visible.
>
> CFLAGS_sched_tp.o := -I$KERNEL_SRC/kernel/sched
>
> all:
> make -C $KERNEL_SRC M=$(PWD) modules

Sorry for the late response. Was on holiday.

IMHO the above is a hack. Out-of-tree modules should rely on public headers and
exported functions only. What you propose means that people who want to use
these tracepoints in meaningful way must have a prebuilt kernel handy. Which is
maybe true for us who work in the embedded world. But users who run normal
distro kernels (desktop/servers) will fail to build against
`/lib/modules/$(uname -r)/build` where that internal header file is not
exported. IOW, we're putting extra hoops for a large class of users here to be
able to access these internal data. They have to maintain their out-of-tree
definition of these structures.

FWIW, I did raise this concern with Peter in 2019 OSPM and he was okay with the
exports as it's still not a contract and they can disappear anytime we want.
Migrating to using BTF is the right way forward IMO. I don't think what we have
here is out-of-control yet. Though I agree they're annoying.

Cheers

--
Qais Yousef