[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230414132940.chjmsuiurnygajxs@techsingularity.net>
Date: Fri, 14 Apr 2023 14:29:40 +0100
From: Mel Gorman <mgorman@...hsingularity.net>
To: Matthew Wilcox <willy@...radead.org>
Cc: Andrew Morton <akpm@...ux-foundation.org>,
Vlastimil Babka <vbabka@...e.cz>,
Michal Hocko <mhocko@...e.com>,
Oscar Salvador <OSalvador@...e.com>,
Yuanxi Liu <y.liu@...uida.com>,
David Hildenbrand <david@...hat.com>,
Linux-MM <linux-mm@...ck.org>,
LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] mm: page_alloc: Assume huge tail pages are valid when
allocating contiguous pages
On Fri, Apr 14, 2023 at 01:22:06PM +0100, Matthew Wilcox wrote:
> On Fri, Apr 14, 2023 at 09:22:22AM +0100, Mel Gorman wrote:
> > + /*
> > + * Do not migrate huge pages that span the size of the region
> > + * being allocated contiguous. e.g. Do not migrate a 1G page
> > + * for a 1G allocation request. CMA is an exception as the
> > + * region may be reserved for hardware that requires physical
> > + * memory without a MMU or scatter/gather capability.
> > + *
> > + * Note that the compound check is race-prone versus
> > + * free/split/collapse but it should be safe and result in
> > + * a premature skip or a useless migration attempt.
> > + */
> > + if (PageHuge(page) && compound_nr(page) >= nr_pages &&
>
> This confuses me. PageHuge() can be called on tail pages, but if
> compound_nr() is called on a tail page, it returns 1.
Given the calling context is a linear scan, the head page will be scanned
first so the value for compound_nr() called on a tail page shouldn't occur.
> So I'm not
> sure why this works. Also, do you really want PageHuge (ie only
> hugetlbfs pages), or do you really just want to check PageCompound(),
> which would also be true for THP?
>
For now I only want hugetlbfs pages as the fix is for a regression when
allocating 1G hugetlbfs pages and previous behaviour avoided existing
hugetlbfs pages. THP pages can be split+migrated of course but the cost
of the 1G allocation attempt may be excessive relative to any benefit.
--
Mel Gorman
SUSE Labs
Powered by blists - more mailing lists