Re: [PATCH v5 02/11] mm/mempolicy: introduce MPOL_WEIGHTED_INTERLEAVE for weighted interleaving

From: Gregory Price
Date: Wed Dec 27 2023 - 14:52:34 EST


On Tue, Dec 26, 2023 at 02:01:57AM -0500, Gregory Price wrote:
> On Wed, Dec 27, 2023 at 04:32:37PM +0800, Huang, Ying wrote:
> > Gregory Price <gourry.memverge@xxxxxxxxx> writes:
>
> Barrier is to stabilize nodemask on the stack, but yes i'll carry the
> comment from interleave_nid into this barrier as well.
>
> > > +
> > > + /* first ensure we have a valid nodemask */
> > > + nid = first_node(nodemask);
> > > + if (nid == MAX_NUMNODES)
> > > + return nid;
> >
> > It appears that this isn't necessary, because we can check whether
> > weight_total == 0 after the next loop.
> >
>
> fair, will snip.
>

Follow up - this is only possible if the nodemask is invalid / has no
nodes, so it's better to check for this explicitly. If nodemask is
valid, then it's not possible to have a weight_total of 0, because
weights cannot be 0.

~Gregory