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 24686ECAAD5 for ; Mon, 5 Sep 2022 15:35:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 71307801EF; Mon, 5 Sep 2022 11:35:25 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6C256801E6; Mon, 5 Sep 2022 11:35:25 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 56298801EF; Mon, 5 Sep 2022 11:35:25 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 4A733801E6 for ; Mon, 5 Sep 2022 11:35:25 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 26B80AC4EB for ; Mon, 5 Sep 2022 15:35:25 +0000 (UTC) X-FDA: 79878431010.02.50905F1 Received: from wout4-smtp.messagingengine.com (wout4-smtp.messagingengine.com [64.147.123.20]) by imf01.hostedemail.com (Postfix) with ESMTP id A219440069 for ; Mon, 5 Sep 2022 15:35:24 +0000 (UTC) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 941AF3200939; Mon, 5 Sep 2022 11:35:21 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Mon, 05 Sep 2022 11:35:23 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shutemov.name; h=cc:cc:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm3; t=1662392121; x=1662478521; bh=TM ae4UrAehFIdNxLvvM/JWw7tJKL6ziDhN9OKwFTLro=; b=jb3b5uDOnBZid2q+gv UGQi4iFnUXvQ83BSf2ZaVDPdwHOB0GMOqugRzLSMKPoG+96oWjYeD8OJm37GH6z8 jk8Cj/PL1vuR4MOdZWDdO8eRhi4IRrUKLCQ2AmspiBdw1yUOb/fQCCh+aUbMr+lR a+mO+AtXnSu/h++cMIohjMVY2RLx1ZVqT5tcF8+MfzmrnVoHw+bkvGHbc2/VB59X E3Y8LckWgfYysN70/pzgyDaiT0rlvmDYyNrLUjkbMY+wig/Jxb5Sa9IXDK2zqFyu q6X0PWVLG8yydmT/wdHGU7vl9vgas8iVa/pZVODqsGW/3k8hYSrUwyOo9vNjwouu Vn6g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:feedback-id :feedback-id:from:from:in-reply-to:in-reply-to:message-id :mime-version:references:reply-to:sender:subject:subject:to:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; t=1662392121; x=1662478521; bh=TMae4UrAehFIdNxLvvM/JWw7tJKL 6ziDhN9OKwFTLro=; b=yStOOqdXgkt/Whf2Q6KslPMVEHSN/1Cy5u7Ze3zbmBBt DrxHZJkTLXwTlublFZMAkI4YT/kvWUd7azFtBT8i/qA0RZERd8/eQKOQJuGCXI/h EqYalWg2mSKc1HODh/ErbavaduRgieOvOgeMNr9kuQbCv18o/wttqy3/staW+nMq E7rbRUeIdCuUyu+iL8S49gsSx4QcOffzEndEPzoxc57eQX9vQbtP5esJ4t6rAflW PcViMaJXghBcHlu75gWYC2kciVLmII60VXWjbogggBzUYhsl3SW8RdQgtcQuBt9u zL2Um0URwtWKm59mG5PwVEnPG/7t2nFztcnFnNyKzQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrvdeliedgleefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvfevuffkfhggtggujgesthdttddttddtvdenucfhrhhomhepfdfmihhr ihhllhcutedrucfuhhhuthgvmhhovhdfuceokhhirhhilhhlsehshhhuthgvmhhovhdrnh grmhgvqeenucggtffrrghtthgvrhhnpeelgffhfeetlefhveffleevfffgtefffeelfedu udfhjeduteeggfeiheefteehjeenucffohhmrghinhepkhgvrhhnvghlrdhorhhgnecuve hluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepkhhirhhilhhl sehshhhuthgvmhhovhdrnhgrmhgv X-ME-Proxy: Feedback-ID: ie3994620:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 5 Sep 2022 11:35:20 -0400 (EDT) Received: by box.shutemov.name (Postfix, from userid 1000) id DC94B1040BF; Mon, 5 Sep 2022 18:35:17 +0300 (+03) Date: Mon, 5 Sep 2022 18:35:17 +0300 From: "Kirill A. Shutemov" To: Peter Zijlstra Cc: Bharata B Rao , ananth.narayan@amd.com, "Kirill A. Shutemov" , Dave Hansen , Andy Lutomirski , x86@kernel.org, Kostya Serebryany , Andrey Ryabinin , Andrey Konovalov , Alexander Potapenko , Taras Madan , Dmitry Vyukov , "H . J . Lu" , Andi Kleen , Rick Edgecombe , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCHv8 00/11] Linear Address Masking enabling Message-ID: <20220905153517.k6ctaqqtkcyu2zmn@box.shutemov.name> References: <20220830010104.1282-1-kirill.shutemov@linux.intel.com> <20220904010001.knlcejmw4lg2uzy3@box.shutemov.name> <64519d0b-b696-db47-52c2-303451e10c09@amd.com> <20220905134457.a2f7uluq42frsgwe@box.shutemov.name> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1662392124; 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=TMae4UrAehFIdNxLvvM/JWw7tJKL6ziDhN9OKwFTLro=; b=hCSy3xvKmzyXW/MH1q9+KpR5ZbwyY5LD84Cmh30P+xiX+Pz5+UXnX0yYQ80k6HVNY7VCWG +VlqbIkWRg6ZsW6VUSU9gKmWhGHxMc2F8WaGDs+1p3T2vArXjfYiY/q64jKLbcjR5Mj38x cfErPFLleQGKEXJsnzYHiqhoP39JrdY= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=shutemov.name header.s=fm3 header.b=jb3b5uDO; dkim=pass header.d=messagingengine.com header.s=fm1 header.b=yStOOqdX; spf=pass (imf01.hostedemail.com: domain of kirill@shutemov.name designates 64.147.123.20 as permitted sender) smtp.mailfrom=kirill@shutemov.name; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1662392124; a=rsa-sha256; cv=none; b=xK+ePkVHxPBpSlAljPsHqAitE2SaovlFGV7Djn0ZpFwsvGcJe+6R/iLTJYjc5dWBejIdZZ hWR11atBC8fXIKkQzBaD7yE9ducORQUXJkYvQFwdXMwaAxwHMmoH6v5IDrbmeReC3j3nwz jRdazEKE5uUXusevyB4awnFfHvRZ6so= X-Rspam-User: X-Stat-Signature: 11dwwufb7cizyawf1nzxqxqksqagpdai X-Rspamd-Queue-Id: A219440069 Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=shutemov.name header.s=fm3 header.b=jb3b5uDO; dkim=pass header.d=messagingengine.com header.s=fm1 header.b=yStOOqdX; spf=pass (imf01.hostedemail.com: domain of kirill@shutemov.name designates 64.147.123.20 as permitted sender) smtp.mailfrom=kirill@shutemov.name; dmarc=none X-Rspamd-Server: rspam04 X-HE-Tag: 1662392124-45010 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: On Mon, Sep 05, 2022 at 04:30:25PM +0200, Peter Zijlstra wrote: > On Mon, Sep 05, 2022 at 04:44:57PM +0300, Kirill A. Shutemov wrote: > > On Mon, Sep 05, 2022 at 10:35:44AM +0530, Bharata B Rao wrote: > > > Hi Kirill, > > > > > > On 9/4/2022 6:30 AM, Kirill A. Shutemov wrote: > > > > On Tue, Aug 30, 2022 at 04:00:53AM +0300, Kirill A. Shutemov wrote: > > > >> Linear Address Masking[1] (LAM) modifies the checking that is applied to > > > >> 64-bit linear addresses, allowing software to use of the untranslated > > > >> address bits for metadata. > > > >> > > > >> The patchset brings support for LAM for userspace addresses. Only LAM_U57 at > > > >> this time. > > > >> > > > >> Please review and consider applying. > > > >> > > > >> git://git.kernel.org/pub/scm/linux/kernel/git/kas/linux.git lam > > > > > > > > +Bharata, Ananth. > > > > > > > > Do you folks have any feedback on the patchset? > > > > > > > > Looks like AMD version of the tagged pointers feature does not get > > > > traction as of now, but I want to be sure that the interface introduced > > > > here can be suitable for your future plans. > > > > > > > > Do you see anything in the interface that can prevent it to be extended to > > > > the AMD feature? > > > > > > The arch_prctl() extensions is generic enough that it should be good. > > > > > > The untagged_addr() macro looks like this from one of the callers: > > > > > > start = untagged_addr(mm, start); > > > ffffffff814d39bb: 48 8b 8d 40 ff ff ff mov -0xc0(%rbp),%rcx > > > ffffffff814d39c2: 48 89 f2 mov %rsi,%rdx > > > ffffffff814d39c5: 48 c1 fa 3f sar $0x3f,%rdx > > > ffffffff814d39c9: 48 0b 91 50 03 00 00 or 0x350(%rcx),%rdx > > > ffffffff814d39d0: 48 21 f2 and %rsi,%rdx > > > ffffffff814d39d3: 49 89 d6 mov %rdx,%r14 > > > > > > Can this overhead of a few additional instructions be removed for > > > platforms that don't have LAM feature? I haven't measured how much > > > overhead this effectively contributes to in real, but wonder if it is > > > worth optimizing for non-LAM platforms. > > > > I'm not sure how the optimization should look like. I guess we can stick > > static_cpu_has() there, but I'm not convinced that adding jumps there will > > be beneficial. > > I suppose the critical bit is the memory load. That can stall and then > you're sad. A jump_label is easy enough to add. What about something like this? diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h index 803241dfc473..868d2730884b 100644 --- a/arch/x86/include/asm/uaccess.h +++ b/arch/x86/include/asm/uaccess.h @@ -30,8 +30,10 @@ static inline bool pagefault_disabled(void); */ #define untagged_addr(mm, addr) ({ \ u64 __addr = (__force u64)(addr); \ - s64 sign = (s64)__addr >> 63; \ - __addr &= (mm)->context.untag_mask | sign; \ + if (static_cpu_has(X86_FEATURE_LAM)) { \ + s64 sign = (s64)__addr >> 63; \ + __addr &= (mm)->context.untag_mask | sign; \ + } \ (__force __typeof__(addr))__addr; \ }) -- Kiryl Shutsemau / Kirill A. Shutemov