Re:[PATCH] bitmap: fix a unproper remap when mpol_rebind_nodemask()

From: wang.yi59
Date: Wed Jun 15 2022 - 04:55:17 EST


> On Mon, Jun 13, 2022 at 8:45 PM <wang.yi59@xxxxxxxxxx> wrote:
> >
> >
> > - change the bitmap_remap() as this patch did, but this changed the
> > behavior of this routine which looks does the right thing. One good
> > news is this function is only called by mpol_rebind_nodemask().
>
> There are users of bitmap_remap() in drivers/gpio/gpio-xilinx.c
>
> > - don't change the bitmap_remap(), to be honest, I didn't figure out
> > a way. Any suggestions?
>
> I haven't had a chance to play with it (because of my dayjob), but I
> have a strong feeling that the proper solution should come from
> existing functionality.
>
> Did you experiment with MPOL_F_{STATIC,RELATIVE}_NODES?
> Those flags enable nodes_and() and mpol_relative_nodemask()
> paths correspondingly.
>

You are right, adding MPOL_F_STATIC_NODES can fix this situation. So it
seems that we don't need to do anything in kernel now.

Many thanks for your time :)


> What I suggested is:
>
> 328 node_clear(1, pol->w.cpuset_mems_allowed);
> 329 node_clear(3, pol->w.cpuset_mems_allowed);
> 330 nodes_remap(tmp, pol->nodes, pol->w.cpuset_mems_allowed,
> 331 *nodes);
> 332 pol->w.cpuset_mems_allowed = *nodes;
>
> > In the example above, if set cpuset.mems to 0,2 firstly, the nodes
> > binds will change from 1 to 2. And then set cpuset.mems to 1,3, it will
> > change from 2 to 3 again.


---
Best wishes
Yi Wang