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 7B89C28682 for ; Mon, 24 Nov 2025 14:02:57 +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=1763992977; cv=none; b=Mi2ZoZFYGESXKXt0p6jpATaRc9P6jlAetwPFUoXSz0Pa5Iq60gLAviWlZVr09lyZybDW3mo44PeGjLdZ/q3RTbp5mf0l9zDgJfMXtmoLKAMkf0tCu4Nzo4uu8pSgwU4G1Rp/vo4KrPmxaHPaJSiZYHDZCa/HkdPpCv/F2jyVDLQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763992977; c=relaxed/simple; bh=YqylCEeliEvlrC1kKw4Lw3JI+SCsfpARExAMAiItCrQ=; h=Message-ID:Date:MIME-Version:Subject:From:To:Cc:References: In-Reply-To:Content-Type; b=bztwqr+UfpcdRTun2SFLp4BLAb1jMdic26V5iuwWZtiYx2S/0/29BE/fLgqV32wN26+uZEXbl0okjX8ncToYxXcfOs4GJnM6qVAXXDbkDBjq73qOeyecWKj580RTdfZtko6+/MiYXITXKmDabKvSgEHzXOxGtBj/uw+Qd1L4hVg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Tk0B7VIl; 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="Tk0B7VIl" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 255FBC4CEF1; Mon, 24 Nov 2025 14:02:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1763992977; bh=YqylCEeliEvlrC1kKw4Lw3JI+SCsfpARExAMAiItCrQ=; h=Date:Subject:From:To:Cc:References:In-Reply-To:From; b=Tk0B7VIlEUDDN2U3FV4pUKTeQsuTqvT4R/mnOJ2XNo00BuWSlKlsxf1vc63Mbl1j+ tl9lO2sIHAiPxITXujuPruVokMbX+TW8F1K2MLEETyo1PQomIyCT71jNp43MdSr7ii DsiY2IoMnfhvQ8qs4u6S88ewRv60/rfWkl+zMX7tz7jYsAdnAf4hqRF1RoGrHSIIv4 LFBqPbdfWO9gRktjIkr+weNioG4P7IXJO8N6A/L+VWxZUJBMtcVI6L2dQf0Fqdg9a3 bEeI8vd8tI36SgIpIWy3UdqbRkYks3Vng4EsuztKrjfNmZCm13/fJr7/JSnwFNXvyp wPtrQFAItlUrA== Message-ID: Date: Mon, 24 Nov 2025 15:02:51 +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 From: "David Hildenbrand (Red Hat)" To: "Christophe Leroy (CS GROUP)" , Ankur Arora , linux-kernel@vger.kernel.org, linux-mm@kvack.org, x86@kernel.org Cc: akpm@linux-foundation.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> <189bc218-8f19-4686-b2ee-5ddc6a0b4684@kernel.org> Content-Language: en-US In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 11/24/25 11:17, David Hildenbrand (Red Hat) wrote: > On 11/23/25 12:53, Christophe Leroy (CS GROUP) wrote: >> >> >> 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 ? : > > No really, because we make use of clear_user_highpage() only when the > arch defines it, so the highmem.h variant is ignored? > > Not that I particularly enjoy this way of handling it, so something > cleaner would be nice :) > > (in particular, relying on highmem.h defines in mm.h is a bit suboptimal) Correction: there is no highmem.h dependency, as clear_user_highpage() comes directly from the architecture helpers in page.h -- Cheers David