From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9F4DE23F405 for ; Sun, 23 Nov 2025 11:53:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763898794; cv=none; b=neRHz662LlCkwqEINnBo0j1aoYRBr2W+OR16ltrXMU1Zxdp84kPz7oDZLwYGmeuWf7CNp4zVGOuZCwKx5SfP4/mOVtHeGD2xMQ7NBBg29uQUd8j6KaFXjPoHmLyDoyZWeuU4rRrzws4BOp5qy52SNCce0kGQHFpc5pirnEsqURc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763898794; c=relaxed/simple; bh=wxpdkaDYxQIyo5t/dwdCFKbHIbIlcAaOrc4r4NjwJzA=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=UW4FQbpQu6s7RLvsHfSjQMBu/5VziIBq6+cnPbPsCTtSzNZw1wLuwx5OafukS2DvcG3/1lDol7AvkY/jsBBFhdRSUAj0tlTtTtZETxiDHoz51dcoraNcOi/6CocGymrSkEQb9ibPaM5IoiiOQYYHgIzUBTl/HxK00C0fGPnyHiw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=eZ4SJBw7; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="eZ4SJBw7" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BA784C113D0; Sun, 23 Nov 2025 11:53:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1763898794; bh=wxpdkaDYxQIyo5t/dwdCFKbHIbIlcAaOrc4r4NjwJzA=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=eZ4SJBw7QvTeJNUqGNKocSCXulo0iDES6F3pYOF34DTDBILBSvEObkJySh33G9Aot /rQ1WmD4/UvaJ4YEH2zsRH77JsmHmriB60Fh/5kLEHJv3AGIJ6Du25TSY6puZrwf4G v+VMatk3ebQKaWXVAZ+MHFYP8gvTMF/xBhFpJvWOsbu7XzS9ZVpB6FvSkfB0SZtqJq qpKljlMf84fLH3A6zTNIFI8hk4oksZNSfJ77pkXBS6pT4n4U60lKhRQcFnKvZy7ZcZ QUM1REs+EdlaX/1HfKSTP6kTrENAXkgCKbWJn0E11vWZ+bexVtvboO+JZ2quaBOc6P xcRcxPY3qnisw== Message-ID: <189bc218-8f19-4686-b2ee-5ddc6a0b4684@kernel.org> Date: Sun, 23 Nov 2025 12:53:07 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v9 1/7] treewide: provide a generic clear_user_page() variant To: Ankur Arora , linux-kernel@vger.kernel.org, linux-mm@kvack.org, x86@kernel.org Cc: akpm@linux-foundation.org, david@kernel.org, bp@alien8.de, dave.hansen@linux.intel.com, hpa@zytor.com, mingo@redhat.com, mjguzik@gmail.com, luto@kernel.org, peterz@infradead.org, tglx@linutronix.de, willy@infradead.org, raghavendra.kt@amd.com, boris.ostrovsky@oracle.com, konrad.wilk@oracle.com References: <20251121202352.494700-1-ankur.a.arora@oracle.com> <20251121202352.494700-2-ankur.a.arora@oracle.com> From: "Christophe Leroy (CS GROUP)" Content-Language: fr-FR In-Reply-To: <20251121202352.494700-2-ankur.a.arora@oracle.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Le 21/11/2025 à 21:23, Ankur Arora a écrit : > From: David Hildenbrand > > Let's drop all variants that effectively map to clear_page() and > provide it in a generic variant instead. > > We'll use the macro clear_user_page to indicate whether an architecture > provides it's own variant. > > We have to be a bit careful if an architecture provides a custom > clear_user_highpage(), because then it's very likely that some special > flushing magic is happening behind the scenes. > > Maybe at some point these should be CONFIG_ options. > > Note that for parisc, clear_page() and clear_user_page() map to > clear_page_asm(), so we can just get rid of the custom clear_user_page() > implementation. There is a clear_user_page_asm() function on parisc, > that seems to be unused. Not sure what's up with that. > > Signed-off-by: David Hildenbrand > Signed-off-by: Ankur Arora ... > diff --git a/include/linux/mm.h b/include/linux/mm.h > index 7c79b3369b82..6fa6c188f99a 100644 > --- a/include/linux/mm.h > +++ b/include/linux/mm.h > @@ -3879,6 +3879,28 @@ static inline void clear_page_guard(struct zone *zone, struct page *page, > unsigned int order) {} > #endif /* CONFIG_DEBUG_PAGEALLOC */ > > +#ifndef clear_user_page > +/** > + * clear_user_page() - clear a page to be mapped to user space > + * @addr: the address of the page > + * @vaddr: the address of the user mapping > + * @page: the page > + */ > +static inline void clear_user_page(void *addr, unsigned long vaddr, struct page *page) > +{ > +#ifdef clear_user_highpage > + /* > + * If an architecture defines its own clear_user_highpage() variant, > + * then we have to be a bit more careful here and cannot simply > + * rely on clear_page(). > + */ > + clear_user_highpage(page, vaddr); > +#else > + clear_page(addr); > +#endif > +} > +#endif > + > #ifdef __HAVE_ARCH_GATE_AREA > extern struct vm_area_struct *get_gate_vma(struct mm_struct *mm); > extern int in_gate_area_no_mm(unsigned long addr); Isn't it chicken and egg with clear_user_highpage() in linux/highmem.h ? : #ifndef clear_user_highpage static inline void clear_user_highpage(struct page *page, unsigned long vaddr) { void *addr = kmap_local_page(page); clear_user_page(addr, vaddr, page); kunmap_local(addr); } #endif And at the end this function is the only caller of clear_user_page() so there is apparently no need for a generic clear_user_page(), at least not when clear_user_highpage() is defined. I think is would be simpler and cleaner to instead add the following in linux/highmem.c: #ifndef clear_user_page /** * clear_user_page() - clear a page to be mapped to user space * @addr: the address of the page * @vaddr: the address of the user mapping * @page: the page */ static inline void clear_user_page(void *addr, unsigned long vaddr, struct page *page) { clear_page(addr); } #endif