lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAOUHufa=H4WF9=xk9GXK5G4uHVghxikV1zqwO4BMQR=f_3_itA@mail.gmail.com>
Date: Tue, 29 Oct 2024 10:49:40 -0600
From: Yu Zhao <yuzhao@...gle.com>
To: Johannes Weiner <hannes@...xchg.org>, Andrew Morton <akpm@...ux-foundation.org>
Cc: Vlastimil Babka <vbabka@...e.cz>, linux-mm@...ck.org, linux-kernel@...r.kernel.org, 
	Link Lin <linkl@...gle.com>, David Rientjes <rientjes@...gle.com>
Subject: Re: [PATCH mm-unstable v3] mm/page_alloc: keep track of free highatomic

On Tue, Oct 29, 2024 at 10:46 AM Johannes Weiner <hannes@...xchg.org> wrote:
>
> On Mon, Oct 28, 2024 at 12:26:53PM -0600, Yu Zhao wrote:
> > OOM kills due to vastly overestimated free highatomic reserves were
> > observed:
> >
> >   ... invoked oom-killer: gfp_mask=0x100cca(GFP_HIGHUSER_MOVABLE), order=0 ...
> >   Node 0 Normal free:1482936kB boost:0kB min:410416kB low:739404kB high:1068392kB reserved_highatomic:1073152KB ...
> >   Node 0 Normal: 1292*4kB (ME) 1920*8kB (E) 383*16kB (UE) 220*32kB (ME) 340*64kB (E) 2155*128kB (UE) 3243*256kB (UE) 615*512kB (U) 1*1024kB (M) 0*2048kB 0*4096kB = 1477408kB
> >
> > The second line above shows that the OOM kill was due to the following
> > condition:
> >
> >   free (1482936kB) - reserved_highatomic (1073152kB) = 409784KB < min (410416kB)
> >
> > And the third line shows there were no free pages in any
> > MIGRATE_HIGHATOMIC pageblocks, which otherwise would show up as type
> > 'H'. Therefore __zone_watermark_unusable_free() underestimated the
> > usable free memory by over 1GB, which resulted in the unnecessary OOM
> > kill above.
> >
> > The comments in __zone_watermark_unusable_free() warns about the
> > potential risk, i.e.,
> >
> >   If the caller does not have rights to reserves below the min
> >   watermark then subtract the high-atomic reserves. This will
> >   over-estimate the size of the atomic reserve but it avoids a search.
> >
> > However, it is possible to keep track of free pages in reserved
> > highatomic pageblocks with a new per-zone counter nr_free_highatomic
> > protected by the zone lock, to avoid a search when calculating the
> > usable free memory. And the cost would be minimal, i.e., simple
> > arithmetics in the highatomic alloc/free/move paths.
> >
> > Note that since nr_free_highatomic can be relatively small, using a
> > per-cpu counter might cause too much drift and defeat its purpose,
> > in addition to the extra memory overhead.
> >
> > Reported-by: Link Lin <linkl@...gle.com>
> > Signed-off-by: Yu Zhao <yuzhao@...gle.com>
> > Acked-by: David Rientjes <rientjes@...gle.com>
>
> Acked-by: Johannes Weiner <hannes@...xchg.org>
>
> > @@ -642,6 +644,9 @@ static inline void account_freepages(struct zone *zone, int nr_pages,
> >
> >       if (is_migrate_cma(migratetype))
> >               __mod_zone_page_state(zone, NR_FREE_CMA_PAGES, nr_pages);
> > +
> > +     if (is_migrate_highatomic(migratetype))
> > +             WRITE_ONCE(zone->nr_free_highatomic, zone->nr_free_highatomic + nr_pages);
>
> Minor nit, the page can only be of one migratetype, so `else if' would
> be better.

Right (copied and pasted without thinking).

Andrew, could you please fix this up in place? Thank you!

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ