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 D3C38334C2B for ; Thu, 26 Mar 2026 17:49:56 +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=1774547396; cv=none; b=BMPldl9/+Rt68gp/+G/rpJKrD+O4hA1nBU0ainG4Jaj3sF6AXMrL9d3cconjwelHV+NsCRpt+fzlFeeJE5WvCCt7rX9q8orXJlcGZ85PC5kxv+s7/HaQt6o8xA5VBHzw+2+zfaM5+uTQh6+hT7cgaroIQDA+iqu4RiXNMFtY2qQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774547396; c=relaxed/simple; bh=1Tske1Cd3w6DOQ8+5TNSTdJekQL1p4RydR8s4XRrkyY=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=dwXTFNIj1ggg17m6SQ6NOHU0ZDyqG4m6bt/Wo2OVOoF4trIB4NrhTt3Xf9w0WMjn0tmbBAaortlsGLK5JfuIAQQZ6ydrAC3Ptg70FKSat8jUsmAH/toERv6D7zgVuQ/e8eqsOoB8fgpfSUV7BzR5Ety2+PGs4bq4xNb3xAY/CX0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=hAcQGaBk; 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="hAcQGaBk" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E8BDDC116C6; Thu, 26 Mar 2026 17:49:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1774547396; bh=1Tske1Cd3w6DOQ8+5TNSTdJekQL1p4RydR8s4XRrkyY=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=hAcQGaBk3GXCwsbrQNqv93rhXRWUngjpOGr5m+b3OYG6MF1pKdz2ScAvdjk+nPRCO xf4O3y1t4RyP5e1JAikChV/JnhZv1b2/zWeNbldxrV8ceelxwWqi081RjWITgSmZAc UxOUIRKNTajfobfd1pd+D2jKM//eh2hfpOD/5OmZ4SPMXRZKcFtMS2HMi7ICa7bh4t pIrYKWWPb6xPuwecnu9MB6oeVKZLmwGPc0xpYu6JKl/9WqCByl/zS1aQ/5esABM7+i YyoQsmIoxhsbPNwR21RcAwC3KX+YnuTxDiluWHn++Sg4aFb6Ok/NTjgPtGyps7w8un Ieh6oUJuAouWw== Message-ID: <0f9567b8-d598-40fc-b364-418e739b1f9f@kernel.org> Date: Thu, 26 Mar 2026 18:49:50 +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 1/2] uaccess: unify inline vs outline copy_{from,to}_user() selection To: Yury Norov Cc: Andrew Morton , Thomas Gleixner , "Peter Zijlstra (Intel)" , Mathieu Desnoyers , Alice Ryhl , Viktor Malik , Randy Dunlap , David Laight , linux-kernel@vger.kernel.org, Yury Norov References: <20260325163313.749336-1-ynorov@nvidia.com> <20260325163313.749336-2-ynorov@nvidia.com> <6ce733b4-5fae-49ac-ab0e-9c87e620e830@kernel.org> Content-Language: fr-FR From: "Christophe Leroy (CS GROUP)" In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Le 26/03/2026 à 18:29, Yury Norov a écrit : > On Thu, Mar 26, 2026 at 02:44:40PM +0100, Christophe Leroy (CS GROUP) wrote: >> >> >> Le 25/03/2026 à 17:33, Yury Norov a écrit : >>> The kernel allows arches to select between inline and outline >>> implementations of the copy_{from,to}_user() by defining individual >>> INLINE_COPY_FROM_USER and INLINE_COPY_TO_USER, correspondingly. >>> However, all arches enable or disable them always together. >>> >>> Without the real use-case for one helper being inlined while the other >>> outlined, having independent controls is excessive and error prone. >>> >>> Switch the codebase to the single unified INLINE_COPY_USER control. >> >> Could we use a (non user selectable) Kconfig item instead, e.g. >> CONFIG_ARCH_WANT_OUTLINE_USER_COPY ? > > This sounds interesting. I need to wrap it around my head for a while. > Right now, I believe, the best solution is to isolate this setting > from the sources as much as we can, and your suggestion looks like a > step forward. > > Overall, I'm puzzled why some arches enable this while the others > don't. The next question is why copy_{from,to}_user is so special. > If this function benefits from being inlined for that particular > arch or compiler, which functions would also benefit and why? > > Reasoning logically, if this WANT_INLINE thing makes sense, it would > make much more sense if we create a machinery for something like: > > unsigned long __arch_inline copy_to_user(); > >> Also, looks like only powerpc doesn't select INLINE_COPY. Would it be >> cleaner to change the logic to a flag for OUTLINE_COPY ? > > How that? x86_64 outlines it. Check it yourself: > > @@ -206,7 +206,9 @@ _inline_copy_to_user(void __user *to, const void *from, unsigned long n) > #ifdef INLINE_COPY_USER > # define _copy_to_user _inline_copy_to_user > # define _copy_from_user _inline_copy_from_user > +#error INLINE_COPY_USER > #else > +#error OUTLINE_COPY_USER > extern __must_check unsigned long > _copy_from_user(void *, const void __user *, unsigned long); > > If it was really a single arch, it would be worth to discuss what for do > we need this customization at all. Hum ... You are right. I don't know why, I thought powerpc was the only one. Nevertheless, among the 21 architectures in arch/ , 17 of them select INLINE_COPY_FROM_USER, which means only 4 don't define it. So might still be interesting to reverse the logic, then only 4 arches will have to select it, similar to the exemple below with powerpc: diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index ad7a2fe63a2a..58743cb0e305 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig @@ -186,6 +186,7 @@ config PPC select ARCH_WANT_IRQS_OFF_ACTIVATE_MM select ARCH_WANT_LD_ORPHAN_WARN select ARCH_WANT_OPTIMIZE_DAX_VMEMMAP if PPC_RADIX_MMU + select ARCH_WANT_OUTLINE_USER_COPY select ARCH_WANTS_MODULES_DATA_IN_VMALLOC if PPC_BOOK3S_32 || PPC_8xx select ARCH_WEAK_RELEASE_ACQUIRE select BINFMT_ELF diff --git a/lib/Kconfig b/lib/Kconfig index 0f2fb9610647..0106c1facfa4 100644 --- a/lib/Kconfig +++ b/lib/Kconfig @@ -550,6 +550,9 @@ config ARCH_HAS_UACCESS_FLUSHCACHE config ARCH_HAS_COPY_MC bool +config ARCH_WANT_OUTLINE_USER_COPY + bool + # Temporary. Goes away when all archs are cleaned up config ARCH_STACKWALK bool Christophe