Re: [PATCH v5 2/3] sched/topology: Introduce for_each_numa_hop_mask()

Valentin Schneider
2022-10-21T14:07:08Z

On 21/10/22 16:34, Andy Shevchenko wrote:
> On Fri, Oct 21, 2022 at 04:16:17PM +0300, Andy Shevchenko wrote:
>> On Fri, Oct 21, 2022 at 01:19:26PM +0100, Valentin Schneider wrote:
>
> ...
>
>> > +#define for_each_numa_hop_mask(mask, node) \
>> > + for (unsigned int __hops = 0; \
>> > + /* \
>> > + * Unsightly trickery required as we can't both initialize \
>> > + * @mask and declare __hops in for()'s first clause \
>> > + */ \
>> > + mask = __hops > 0 ? mask : \
>> > + node == NUMA_NO_NODE ? \
>> > + cpu_online_mask : sched_numa_hop_mask(node, 0), \
>> > + !IS_ERR_OR_NULL(mask); \
>>
>> > + __hops++, \
>> > + mask = sched_numa_hop_mask(node, __hops))
>>
>> This can be unified with conditional, see for_each_gpio_desc_with_flag() as
>> example how.
>
> Something like
>
> mask = (__hops || node != NUMA_NO_NODE) ? sched_numa_hop_mask(node, __hops) : cpu_online_mask
>

That does simplify things somewhat, thanks!

> --
> With Best Regards,
> Andy Shevchenko