Re: [External] : Re: [PATCH v2 06/28] gup: Fix some contiguous memmap assumptions

From: Mike Kravetz
Date: Mon Jan 10 2022 - 14:05:42 EST


On 1/10/22 05:37, Matthew Wilcox wrote:
> On Mon, Jan 10, 2022 at 12:29:58AM -0800, Christoph Hellwig wrote:
>> On Mon, Jan 10, 2022 at 04:23:44AM +0000, Matthew Wilcox (Oracle) wrote:
>>> Several functions in gup.c assume that a compound page has virtually
>>> contiguous page structs. This isn't true for SPARSEMEM configs unless
>>> SPARSEMEM_VMEMMAP is also set. Fix them by using nth_page() instead of
>>> plain pointer arithmetic.
>>
>> So is this an actualy bug that need a Fixes tag, or do all architectures
>> that support THP and sparsemem use SPARSEMEM_VMEMMAP?
>
> As far as I can tell (and I am by no means an expert in this area),
> this problem only affects pages of order MAX_ORDER or higher. That is,
> somebody using regular 2MB hugepages on x86 won't see a problem, whether
> they're using VMEMMAP or not. It only starts to become a problem for
> 1GB hugepages.
>
> Since THPs are (currently) only allocated from the page allocator, it's
> never a problem for THPs, only hugetlbfs. Correcting the places which
> can't see a 1GB page is just defense against copy-and-paste programming.
>
> So I'll defer to Mike -- does this ever affect real systems and thus
> warrant a backport? I know this doesn't affect UEK because we enable
> SPARSEMEM_VMEMMAP.

I guess it all depends on your definition of 'real' systems. I am unaware
of any distros that disable SPARSEMEM_VMEMMAP, but I do not know or have
access to them all.

In arch specific Kconfig files, SPARSEMEM_VMEMMAP is enabled by default
(if sparsemem is enabled). However, it is 'possible' to configure a kernel
with SPARSEMEM and without SPARSEMEM_VMEMMAP.

This issue came up almost a year ago in this thread:
https://lore.kernel.org/linux-mm/20210217184926.33567-1-mike.kravetz@xxxxxxxxxx/

In practice, I do not recall ever seeing this outside of debug environments
specifically trying to hit the issue.
--
Mike Kravetz