Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp4945041rwb; Tue, 17 Jan 2023 07:22:55 -0800 (PST) X-Google-Smtp-Source: AMrXdXub5XpZIabLeNFvnvFQZe3kt+dbEnFjtqGC8ulIUXMtf2mbmZ7d0DYFzoMHbrVotUXkwEa6 X-Received: by 2002:a17:902:efc5:b0:188:f47f:ac06 with SMTP id ja5-20020a170902efc500b00188f47fac06mr3773183plb.19.1673968974929; Tue, 17 Jan 2023 07:22:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673968974; cv=none; d=google.com; s=arc-20160816; b=kd9z7Vx/j4mFAS3brTnssO1Scz2EluEJosQDdOqxFSNGIzk7zxqu2AwKuMmLxVXJBz uGDNofvsgudLDYpyacXSncLSZseZ4MdgRmV0OEL4IiG+FcdvBU+zoU4ISRTXCvQ+gv2a IbY3IoeK1tD1rVgRIjsOA/iaLp88zogeAXncCRA07xSlKX9PSEENwzoyoL6zFWFYzPeD e3uHkV92m1LJx09vVggyKAlvBRZI0hK99f+k/Xj/1H6f6gU9NDR67bu1ska+jc4wqlc4 N+jaXfc8VEHQrHfwO2xnDtzcKDwBteddJrfd1dKa6vI6jzZtZr+Qc5ETXfqEY8NW5H8M gUqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=5+3UmVpJ/NPgTANSiP8D8SxxRAS1Zk6/SaoSNtIaTLY=; b=HNi0SJpLcoM2ou5qestkTvsNhaX2kcO0qLyqGlF4vMIB2FopUfDy1Z1ioudYrIMDS9 RwdW8i/L68BomPXzItfVeVH3tT4dyexcfBHJMVNN90vpaFu9ejrG6YG0dvbFvfWRdHvP FXZ4vpjVwHMeOkyLfqEiiSk6vDMfxqO2Km4cwj6EcLadgAvWS6UkKQkLS9SxlwfGvPXT dvKdoX630PTA121JhKXC1+Mtu8alkpSOEzwMpY7rbBx70AKi/gIquErVuXlU8UuvBZUS 00qVkFG/iPE0wvZ0TbGcczvfdd9hr/IvHkgx/WjgiMF8ZT3iXIWT2KecqmfUv50rWyAY kFGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=MoNRwLc0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h124-20020a636c82000000b0049ca25d4963si32433156pgc.468.2023.01.17.07.22.49; Tue, 17 Jan 2023 07:22:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=MoNRwLc0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230284AbjAQN7E (ORCPT + 48 others); Tue, 17 Jan 2023 08:59:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52216 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231678AbjAQN56 (ORCPT ); Tue, 17 Jan 2023 08:57:58 -0500 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7C3913C29D for ; Tue, 17 Jan 2023 05:57:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1673963837; x=1705499837; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=a4ci5njmq6NGUXQ2uAOHjFrB6MTLa2x7EivsU39sALs=; b=MoNRwLc02kZv5JgIxwm8RSVmd2hcsILeckF1Wk0GqJL/4WcH7Q/nw2r5 tFSsHeTz0W8kJs34Daif4d2n+ITmMT5Tpvk4Y9mK36D69ME75mO2mMDdV iBv2hWDFQSQZJRykifyGbnPD61ns1yLzfZubg7KlrRkztXrLpX3gKRraF Dxinu2NDoOgwn2K5bEInKmDUWxY0spjNM8BINWfJG8mgKAWXcoOSN65Rb VMa2VJNIgeSzxCFALw5y25xDcz04G7xXZ3/xINA+LR/4jzI2IRL4tlgcL GX5WgqiHIpM8uh2yFViTNDaG+kNnertQtsKth6AoNAyKEKXsrjccZ5sSN A==; X-IronPort-AV: E=McAfee;i="6500,9779,10592"; a="325973000" X-IronPort-AV: E=Sophos;i="5.97,224,1669104000"; d="scan'208";a="325973000" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jan 2023 05:57:11 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10592"; a="783246688" X-IronPort-AV: E=Sophos;i="5.97,224,1669104000"; d="scan'208";a="783246688" Received: from btaubert-mobl1.ger.corp.intel.com (HELO box.shutemov.name) ([10.251.222.122]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jan 2023 05:57:06 -0800 Received: by box.shutemov.name (Postfix, from userid 1000) id CFEA11070EC; Tue, 17 Jan 2023 16:57:03 +0300 (+03) Date: Tue, 17 Jan 2023 16:57:03 +0300 From: "Kirill A. Shutemov" To: Peter Zijlstra Cc: 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 , Bharata B Rao , Jacob Pan , Ashok Raj , Linus Torvalds , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCHv14 08/17] x86/mm: Reduce untagged_addr() overhead until the first LAM user Message-ID: <20230117135703.voaumisreld7crfb@box> References: <20230111123736.20025-1-kirill.shutemov@linux.intel.com> <20230111123736.20025-9-kirill.shutemov@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jan 17, 2023 at 02:05:22PM +0100, Peter Zijlstra wrote: > On Wed, Jan 11, 2023 at 03:37:27PM +0300, Kirill A. Shutemov wrote: > > > #define __untagged_addr(untag_mask, addr) > > u64 __addr = (__force u64)(addr); \ > > - s64 sign = (s64)__addr >> 63; \ > > - __addr &= untag_mask | sign; \ > > + if (static_branch_likely(&tagged_addr_key)) { \ > > + s64 sign = (s64)__addr >> 63; \ > > + __addr &= untag_mask | sign; \ > > + } \ > > (__force __typeof__(addr))__addr; \ > > }) > > > > #define untagged_addr(addr) __untagged_addr(current_untag_mask(), addr) > > Is the compiler clever enough to put the memop inside the branch? Hm. You mean current_untag_mask() inside static_branch_likely()? But it is preprocessor who does this, not compiler. So, yes, the memop is inside the branch. Or I didn't understand your question. -- Kiryl Shutsemau / Kirill A. Shutemov