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

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

 



On Fri 24-09-21 14:10:54, Feng Tang wrote:
> Hi Michal,
> 
> On Tue, Sep 14, 2021 at 10:50:42AM +0200, Michal Hocko wrote:
> > On Tue 14-09-21 11:40:28, Feng Tang wrote:
> [SPIN]
> > > The OOM killer cannot help to resolve the situation as there is no
> > > usable memory for the request in the cpuset scope. The only reasonable
> > > measure to take is to fail the allocation right away and have the caller
> > > to deal with it.
> > > 
> > > So add a check for cases like this in the slowpath of allocation, and
> > > bail out early returning NULL for the allocation.
> > > 
> > > As page allocation is one of the hottest path in kernel, this check
> > > will hurt all users with sane cpuset configuration, add a static branch
> > > check and detect the abnormal config in cpuset memory binding setup so
> > > that the extra check in page allocation is not paid by everyone.
> > > 
> > > [thanks to Micho Hocko and David Rientjes for suggesting not handle
> > >  it inside OOM code, adding cpuset check, refining comments]
> > > 
> > > Suggested-by: Michal Hocko <mhocko@xxxxxxxx>
> > > Signed-off-by: Feng Tang <feng.tang@xxxxxxxxx>
> > 
> > Acked-by: Michal Hocko <mhocko@xxxxxxxx>
>  
> Thank you!
> 
> > Minor nit below
> > [...]
> > > +/* 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;
> > 
> > This would read easier to me
> > 	/*
> > 	 * We can chose arbitrary node from the nodemask to get a
> > 	 * zonelist as they are interlinked. We just need to find
> > 	 * at least one zone that can satisfy kernel allocations.
> > 	 */
> > 	node = NODE_DATA(first_node(*nodes));
> > 	zonelist = node_zonelist(node, GFP_KERNEL);
> > 	z = first_zones_zonelist(zonelist, ZONE_NORMAL, nodes);
> 
> When working on the v4 patch, I see some compile warning
> that 'node_zonelist()' and 'GFP_KERNEL' are either implicit
> or undeclared, as they are from "gfp.h".
> 
> So we may need to move this function to gfp.h or keep the
> current code with slight modification?
> 
> 	nid = first_node(*nodes);
> 	zonelist = &NODE_DATA(nid)->node_zonelists[ZONELIST_FALLBACK];
> 	z = first_zones_zonelist(zonelist, ZONE_NORMAL,	nodes);
> 	return (!z->zone) ? true : false;

I would put it into gfp.h but I can see how this might be not really
loved there. Both ways work with me.
-- 
Michal Hocko
SUSE Labs



[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]     [Monitors]

  Powered by Linux