Re: + lib-group_cpus-rework-group_cpus_evenly.patch added to mm-nonmm-unstable branch

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Jan 17, 2024 at 8:45 AM Breno Leitao <leitao@xxxxxxxxxx> wrote:
>
> Hello Yury,
>
> On Wed, Jan 10, 2024 at 10:15:59AM -0800, Yury Norov wrote:
> > diff --git a/lib/group_cpus.c b/lib/group_cpus.c
> > index 3a0db0f51f09..c9c95b21e6c6 100644
> > --- a/lib/group_cpus.c
> > +++ b/lib/group_cpus.c
> > @@ -353,8 +353,8 @@ struct cpumask *group_cpus_evenly(unsigned int numgrps)
> >  {
> >       cpumask_var_t *node_to_cpumask __free(free_node_to_cpumask) = alloc_node_to_cpumask();
> >       struct cpumask *masks __free(kfree) = kcalloc(numgrps, sizeof(*masks), GFP_KERNEL);
> > -     cpumask_var_t npresmsk __free(free_cpumask_var);
> > -     unsigned int curgrp, nr_present, nr_others;
> > +     cpumask_var_t npresmsk __free(free_cpumask_var) = NULL;
>
> I am testing the akpm's mm-everything branch, and I am seeing this
> compilation error when compiling with clang.
>
>         lib/group_cpus.c: In function ‘group_cpus_evenly’:
>         ./include/linux/stddef.h:8:14: error: invalid initializer
>          #define NULL ((void *)0)
>                       ^
>         lib/group_cpus.c:356:52: note: in expansion of macro ‘NULL’
>           cpumask_var_t npresmsk __free(free_cpumask_var) = NULL;
>                                                             ^~~~
> It seems related to this patch. Are you aware of it?
>
> Reverting one of the change above "solves" the error:
>
>         diff --git a/lib/group_cpus.c b/lib/group_cpus.c
>         index c9c95b21e6c6..7644bd99085d 100644
>         --- a/lib/group_cpus.c
>         +++ b/lib/group_cpus.c
>         @@ -353,7 +353,7 @@ struct cpumask *group_cpus_evenly(unsigned int numgrps)
>          {
>                 cpumask_var_t *node_to_cpumask __free(free_node_to_cpumask) = alloc_node_to_cpumask();
>                 struct cpumask *masks __free(kfree) = kcalloc(numgrps, sizeof(*masks), GFP_KERNEL);
>         -       cpumask_var_t npresmsk __free(free_cpumask_var) = NULL;
>         +       cpumask_var_t npresmsk __free(free_cpumask_var);
>                 int curgrp, nr_present, nr_others;
>
>                 if (!masks || !node_to_cpumask || !alloc_cpumask_var(&npresmsk, GFP_KERNEL))

Hi Guys,

+ Nathan

Thanks for the reports.

The problem is that cpumask_var_t, depending on OFFSTACK config, may
be declared as
a pointer or as an array, So simply assigning it to NULL as I did in
this problem patch wouldn't
work if OFFSTACK is off. On the other hand, __free() machinery
requires a variable to be
initialized at declaration.

Sorry for this mess, and please allow me a couple days to figure out a
better solution. Either it
would be a macro for initialization, or something else. - I need to experiment.

As a side note, the idea of having different types for the same
variable depending on some
config is not the best, and we'd better avoid it.

Thanks,
Yury





[Index of Archives]     [Kernel Archive]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]

  Powered by Linux