Re: [PATCH v3] mm/page_alloc: detect allocation forbidden by cpuset and bail out early

From: Michal Hocko
Date: Tue Sep 14 2021 - 04:18:11 EST


On Tue 14-09-21 10:01:26, Vlastimil Babka wrote:
> On 9/14/21 05:40, Feng Tang wrote:
[...]
> > +/* Whether the 'nodes' are all movable nodes */
> > +static inline bool movable_only_nodes(nodemask_t *nodes)
> > +{
> > + struct zonelist *zonelist;
> > + struct zoneref *z;
> > +
> > + if (nodes_empty(*nodes))
> > + return false;
> > +
> > + zonelist =
> > + &NODE_DATA(first_node(*nodes))->node_zonelists[ZONELIST_FALLBACK];
> > + z = first_zones_zonelist(zonelist, ZONE_NORMAL, nodes);
> > + return (!z->zone) ? true : false;
> > +}
>
> Hmm, could all that become just this?
>
> !nodes_intersects(&node_states[N_NORMAL_MEMORY], nodes)

Maybe yes but I find the zonelist approach much easier to follow even
though the code looks more complex at first sight. It talks about an
empty zone list for ZONE_NORMAL request which is quite clear from the
scribble. I always have to re-learn how the N*MEMORY works TBH. Maybe
this is just me though.
--
Michal Hocko
SUSE Labs