Re: [PATCH v4 05/10] sched/topology: Define and assign sched_domain flag metadata
From: Valentin Schneider
Date: Fri Aug 07 2020 - 20:19:35 EST
On 06/08/20 17:18, Valentin Schneider wrote:
> In the grand scheme of things I'd actually like to have this file output
> the names of the flags rather than their values (since I now save them when
> SCHED_DEBUG=y), but I didn't find a simple way to hack the existing SD ctl
> table (sd_alloc_ctl_domain_table() and co) into doing this.
>
I "just" had to spend some more time grokking how the whole ctl
proc_handler thing is supposed to work; I now have a mostly working
solution, i.e. on my Juno:
$ cat /proc/sys/kernel/sched_domain/cpu0/domain*/flags
SD_BALANCE_NEWIDLE SD_BALANCE_EXEC SD_BALANCE_FORK SD_WAKE_AFFINE SD_SHARE_PKG_RESOURCES
SD_BALANCE_NEWIDLE SD_BALANCE_EXEC SD_BALANCE_FORK SD_WAKE_AFFINE SD_ASYM_CPUCAPACITY SD_PREFER_SIBLING
I'll clean that up and go for the automagic ordering I previously
described.
>
> Now as to making this fully automagic, I *think* I could do something like
> having a first enum to set up an ordering:
>
> #define SD_FLAG(name, ...) __##name,
> enum {
> #include <linux/sched/sd_flags.h>
> };
>
> A second one to have powers of 2:
>
> #define SD_FLAG(name, ...) name = 1 << __##name,
> enum {
> #include <linux/sched/sd_flags.h>
> };
>
> And finally the metadata array assignment might be doable with:
>
> #define SD_FLAG(_name, mflags) [__##_name] = { .meta_flags = mflags, .name = #_name },
>
> Or, if there is a way somehow to directly get powers of 2 out of an enum:
>
> #define SD_FLAG(_name, mflags) [_ffs(_name)] = { .meta_flags = mflags, .name = #_name },
>
>>> +#ifdef CONFIG_SCHED_DEBUG
>>> +#define SD_FLAG(_name, idx, mflags) [idx] = {.meta_flags = mflags, .name = #_name},
>>
>> s/{./{ .
>> s/e}/e }
>>
>> Thanks,
>>
>> Ingo