[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <87cy6zfc0a.fsf@oracle.com>
Date: Mon, 06 Oct 2025 23:43:01 -0700
From: Ankur Arora <ankur.a.arora@...cle.com>
To: David Hildenbrand <david@...hat.com>
Cc: Ankur Arora <ankur.a.arora@...cle.com>, linux-kernel@...r.kernel.org,
linux-mm@...ck.org, x86@...nel.org, akpm@...ux-foundation.org,
bp@...en8.de, dave.hansen@...ux.intel.com, hpa@...or.com,
mingo@...hat.com, mjguzik@...il.com, luto@...nel.org,
peterz@...radead.org, acme@...nel.org, namhyung@...nel.org,
tglx@...utronix.de, willy@...radead.org, raghavendra.kt@....com,
boris.ostrovsky@...cle.com, konrad.wilk@...cle.com
Subject: Re: [PATCH v7 12/16] arm: mm: define clear_user_highpages()
David Hildenbrand <david@...hat.com> writes:
>>>> assumes one of the following:
>>>> 1. clear_user_highpages is defined by the architecture or,
>>>> 2. HIGHMEM => arch defines clear_user_highpage or clear_user_page
>>>> 3. !HIGHMEM => arch defines clear_user_pages or clear_user_page
>>>> Case 2 is fine, since ARM has clear_user_highpage().
>>>> Case 3 runs into a problem since ARM doesn't have clear_user_pages()
>>>> or clear_user_page() (it does have the second, but only with !CONFIG_MMU).
>>>
>>> I think we should look into having a generic fallback version in common code
>>> instead for that case, and not require the arch to implement such a loop around
>>> clear_user_highpage().
>> So, as you suggested, I moved clear_user_pages() to mm/utils.c and
>> conditioned it on clear_user_page() also existing.
>> #if defined(clear_user_page) && !defined(clear_user_pages)
>> void clear_user_pages(void *addr, unsigned long vaddr, struct page *page,
>> unsigned int npages) {
>> ...
>> }
>> #endif
>> That fixed this issue as well since there's no more bogus reference to
>> clear_user_page().
>
> I'll have to see the resulting code to comment on details, but if we can handle it in
> common code, all good.
>
>> Are there cases in which (TRANSPARENT_HUGEPAGE || HUGETLB) might be enabled
>> on ARM?
>
> Arm has
>
> arch/arm/Kconfig: select HAVE_ARCH_TRANSPARENT_HUGEPAGE if ARM_LPAE
>
> and supports hugetlb. So yes on both.
I tried to figure out a way forward for arm with THP/HUGETLB and AFAICS
the cleanest approach would be to have some version of this patch.
Just to reiterate the problem with arch/arm: it defines
clear_user_highpage(), but does not define clear_user_page().
This means that common code cannot usefully define clear_user_pages().
And the common definition of clear_user_highpages() either needs to use:
- for HIGHMEM, clear_user_highpage()
- for !HIGHMEM, clear_user_pages()
The first works but I don't see how to make the second work without adding
some such special handling:
static inline void clear_user_highpages(struct page *page, unsigned long vaddr,
unsigned int npages)
vaddr, page, npages);
return;
}
#endif
do {
clear_user_highpage(page, vaddr);
vaddr += PAGE_SIZE;
page++;
} while (--npages);
}
(Even this is a bit contorted, as common code shouldn't really need to
have an associated #define for clear_user_pages().)
Thanks
--
ankur
Powered by blists - more mailing lists