Re: [RFC PATCH] mm/oom: detect and kill task which has allocation forbidden by cpuset limit

From: Feng Tang
Date: Tue Aug 31 2021 - 22:44:07 EST


Hi David and Michal,

On Tue, Aug 31, 2021 at 06:06:17PM -0700, David Rientjes wrote:
> On Tue, 31 Aug 2021, Michal Hocko wrote:
>
> > I do not like this solution TBH. We know that that it is impossible to
> > satisfy the allocation at the page allocator level so dealing with it at
> > the OOM killer level is just a bad layering and a lot of wasted cycles
> > to reach that point. Why cannot we simply fail the allocation if cpusets
> > filtering leads to an empty zone intersection?
>
> Cpusets will guarantee our effective nodemask will include at least one
> node in N_MEMORY (cpuset_mems_allowed()) so we'll always have at least one
> zone in our zonelist.
>
> Issue in this case appears to be that the zone will never satisfy
> non-movable allocations. I think this would be very similar to a GFP_DMA
> allocation when bound to a node without lowmem, in which case we get a
> page allocation failure. We don't kill current like this patch.

Thanks for sharing the case, the DMA case is quite simliar. And in our usage,
the allocating task is finally killed after many OS routine/GUI tasks get
killed.

> So I'd agree in this case that it would be better to simply fail the
> allocation.

I agree with yours and Michal's comments, putting it in the OOM code
is a little late and wastes cpu cycles.

> Feng, would you move this check to __alloc_pages_may_oom() like the other
> special cases and simply fail rather than call into the oom killer?

Will explore more in this direction, thanks!

- Feng