From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8AC94C83030 for ; Fri, 4 Jul 2025 09:04:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E20296B0330; Fri, 4 Jul 2025 05:04:42 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DF8276B0331; Fri, 4 Jul 2025 05:04:42 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D0DBA6B0332; Fri, 4 Jul 2025 05:04:42 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id B9BE16B0330 for ; Fri, 4 Jul 2025 05:04:42 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 4CCC6AC30F for ; Fri, 4 Jul 2025 09:04:42 +0000 (UTC) X-FDA: 83625996804.10.C4B0D26 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.10]) by imf10.hostedemail.com (Postfix) with ESMTP id A0DD3C0007 for ; Fri, 4 Jul 2025 09:04:39 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=J05VE2oa; spf=none (imf10.hostedemail.com: domain of kirill.shutemov@linux.intel.com has no SPF policy when checking 192.198.163.10) smtp.mailfrom=kirill.shutemov@linux.intel.com; dmarc=pass (policy=none) header.from=intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1751619880; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=c18NVsnzcyBUbtrgNOiQPEXauk8zoNvEx0/mnmk8dTc=; b=JaPfwlvb9VQF4Hatws7RKZrjU8wQvm8jRvu8iqceTVUxaVZsRi94Un3E3A9DWd3AMUtk3W rxzp6xaPx9uk3jbP2KaDk4lfSrsmhBwy56mpTN7z9IwDqeFA9gmxwBNp9B71KP/mTfZzPw 2hSUuXHMgfq5lpE/AIPO66kQOwN3Ktg= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=J05VE2oa; spf=none (imf10.hostedemail.com: domain of kirill.shutemov@linux.intel.com has no SPF policy when checking 192.198.163.10) smtp.mailfrom=kirill.shutemov@linux.intel.com; dmarc=pass (policy=none) header.from=intel.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1751619880; a=rsa-sha256; cv=none; b=nyigkXxYmsgEuu9FrHCwLj1duxS7NTwfat4UEhvh6hp4qVpbw2JkxmP155Wshar1z5WLOV F7uXYkW8FJ1Oe+QWu+MocnYD02WbCO+wr7C9gNQP4yB8dZiFTPZd0uxxRgFgo7gE47s6Y5 Zaxyiy+K40dq/nEpcouVVEKvuJ9SLjo= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1751619880; x=1783155880; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=b0XOHjTaiA2dtm2Vi8CMqXmXSSVJ5m5uh5A07ReI5Oo=; b=J05VE2oa0b98IVgQiR1gQegkoRhb0g0c599RTVvpuDoysrWe771doUJt dBXEcIU31oWOdasDjk8CstuOfKWtOIVJR1k39oVX0BxrZfbSjcdW+unV2 Gbxxqn9GfNl4rI9P/vFwYM7AQrXd6eLI7XjNfbhtCxkW81Sl59XrTPpI/ Q5iWwBiSFDwNn9JhsHL3J+jzFOfUtFCHDhtpl9T9vmrskXkLe/T5T1y9L xvAFJO+9Mu/gkJWgMzOzEbWSE5wyPuCshp4t9l5zGCZRzlVQ85OmungfH JpC1x/7X2FfKXuVJ4PFARDwOugvzbEYGlEW3BlfmF7vlf5eNNoy03YDZZ Q==; X-CSE-ConnectionGUID: uxA+aKZ+SUGP/UH6kc6MKQ== X-CSE-MsgGUID: 2DtDKYOiQ0Co8wilU2hong== X-IronPort-AV: E=McAfee;i="6800,10657,11483"; a="65303551" X-IronPort-AV: E=Sophos;i="6.16,286,1744095600"; d="scan'208";a="65303551" Received: from fmviesa001.fm.intel.com ([10.60.135.141]) by fmvoesa104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Jul 2025 02:04:38 -0700 X-CSE-ConnectionGUID: vht6bwzzRjSkxR+/fOABPA== X-CSE-MsgGUID: Kh8fGGBpRLih/m3GU7b5pw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.16,286,1744095600"; d="scan'208";a="185553991" Received: from black.fi.intel.com ([10.237.72.28]) by fmviesa001.fm.intel.com with ESMTP; 04 Jul 2025 02:04:26 -0700 Received: by black.fi.intel.com (Postfix, from userid 1000) id 70B4015D; Fri, 04 Jul 2025 12:04:25 +0300 (EEST) Date: Fri, 4 Jul 2025 12:04:25 +0300 From: "Kirill A. Shutemov" To: Dave Hansen Cc: Andy Lutomirski , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Peter Zijlstra , Ard Biesheuvel , "Paul E. McKenney" , Josh Poimboeuf , Xiongwei Song , Xin Li , "Mike Rapoport (IBM)" , Brijesh Singh , Michael Roth , Tony Luck , Alexey Kardashevskiy , Alexander Shishkin , Jonathan Corbet , Sohil Mehta , Ingo Molnar , Pawan Gupta , Daniel Sneddon , Kai Huang , Sandipan Das , Breno Leitao , Rick Edgecombe , Alexei Starovoitov , Hou Tao , Juergen Gross , Vegard Nossum , Kees Cook , Eric Biggers , Jason Gunthorpe , "Masami Hiramatsu (Google)" , Andrew Morton , Luis Chamberlain , Yuntao Wang , Rasmus Villemoes , Christophe Leroy , Tejun Heo , Changbin Du , Huang Shijie , Geert Uytterhoeven , Namhyung Kim , Arnaldo Carvalho de Melo , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-efi@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCHv8 02/17] x86/asm: Introduce inline memcpy and memset Message-ID: References: <20250701095849.2360685-1-kirill.shutemov@linux.intel.com> <20250701095849.2360685-3-kirill.shutemov@linux.intel.com> <49f7c370-1e28-494b-96a9-f45e06ed4631@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <49f7c370-1e28-494b-96a9-f45e06ed4631@intel.com> X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: A0DD3C0007 X-Stat-Signature: 8613fdqe473er6y9cbgxis5pz56cwfad X-Rspam-User: X-HE-Tag: 1751619879-732854 X-HE-Meta: U2FsdGVkX18wZ/XQMuFz4Q0l5tlFB29JaV2G1OWxfGL2QiTP8IyFc+TZXDc2Mw7HAtFiLa446D6K+SOl8MmHXpDsQg18B9ycwTKllK9mJPbph/FuKwsecC155rpKy0+uVKkqZgGjpjanzu5NEkf0i7je0XYkMHDfLuwZMm+hFiuZuzuxmjpNz0BW3E+4d0o0psNzONy7N+uUvSb4peFxGfqMnUlP1KQ9i1My+uKqKpzSyCjXIWXz21fGsC8W7OTQE73Q4GoN1kays2EpVyeUMSIVxDH/aq5RmVBjhEPqxm8CWJBrxHql3BbHsHRM8Ive1C2o6Q3c8WY2qdoS3y4eLrKy5jtIe0y3uODMuE6nrPIBdPdvkkF7V1TpPTgPbWpsnVyrEw3rX0n2A/nnMaQuHReysmEIUWU/YBx/9UDr+CJDTPF5oXT0soPp3nJQLWy85x6CJ7EokjKZknPLZeJFqV7BviDdqyTLx+uQLrDpLWa1ZczhX/ZRkoWQGVSIX02EuUHVriymdnp69ff7YD/ntw4gNDimZeaqWZomMKU2wNPPGlKAUECeYc/w1gxL9gAsJkTKQJW2azTDYK9yE3QO/NPs5NCpSLOH1umfIS5iT3zPi7T1B+torWMeTwR+iy6+TxnUwbO5FpKj09G9UADJ69JRtfcVEd2LQ3j2Qz7NusQF3ZhXrzfKLeUky22vRLG7XTG6psn9ScA/G5Alcbswt7I3nBRiBww28FGdD3Ahd7LGQ00qEAjP2dBq5Tfu5ORNnET9ictLN/eDqXCd3zjNog6kcFA53YxHCgyyUM9u1ulNzsegNWetxliFmxkWHu1h5CUFPi+DLKnBnkEhLxX1MBSj1llUE/O7jBun93txauETRQiGDfWE2MdADe9+kg1LA7CQLiq8lVsymS/K0iKQ9IjNcbAteMMcCuloS+T+vtZoQ7uzyOGk0fREGy+b7J273pB2AT9GZ/yZc41y6O/ qP5JD3SK hy/hdtCD8ouf6RxBl/ER6EBqP8pMbYik5HiKdzUbs+1YYUBBkaIjWLrjzhEJTUM4amQbeiOEus5hLCsmZ98YiKbYN6fgKIltqaZg0DdZJI/SiPQP8hWs7JimvE3zGDH6OkydCXO9NFmrUwJMp9vqoaFC77g+lXu1QcmQbi+ZI0+XZ0289TM4UZ2/jhYwNBQ6Y5OOUkQtstZb3zTTrb50C8JyKyb6hWD+baXX8 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Thu, Jul 03, 2025 at 10:13:44AM -0700, Dave Hansen wrote: > On 7/1/25 02:58, Kirill A. Shutemov wrote: > > Extract memcpy and memset functions from copy_user_generic() and > > __clear_user(). > > > > They can be used as inline memcpy and memset instead of the GCC builtins > > whenever necessary. LASS requires them to handle text_poke. > > Why are we messing with the normal user copy functions? Code reuse is > great, but as you're discovering, the user copy code is highly > specialized and not that easy to reuse for other things. > > Don't we just need a dirt simple chunk of code that does (logically): > > stac(); > asm("rep stosq..."); > clac(); > > Performance doesn't matter for text poking, right? It could be stosq or > anything else that you can inline. It could be a for() loop for all I > care as long as the compiler doesn't transform it into some out-of-line > memset. Right? Yeah, performance doesn't matter for text poking. And this approach simplifies the code quite a bit. I will use direct asm() for text poke. -- Kiryl Shutsemau / Kirill A. Shutemov