Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp4760597rwb; Tue, 17 Jan 2023 05:17:43 -0800 (PST) X-Google-Smtp-Source: AMrXdXuAHX4DFOJJH5EA9M77MWCrHECcttqXsAErCTQ0DXZwHaqc0Hvc6YfY4aZ2WnqU/3S8heq4 X-Received: by 2002:a05:6402:e8c:b0:463:e2cd:a8b5 with SMTP id h12-20020a0564020e8c00b00463e2cda8b5mr3074587eda.11.1673961463242; Tue, 17 Jan 2023 05:17:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673961463; cv=none; d=google.com; s=arc-20160816; b=oREQPHVk16zN/mheWtWSY3ghIQCK3N30ugUcRz1Rzi5hNRJ9l9LqZ8X7oNVGg7SlfI U/eaGMzzXiwK4ya4Tr3/Q7hd0rNgcpMfNb9jw21Yp9TmMzcGZCIPKZRCmQJF6RueCxhU hwMr+0odVXwnxqsFQUNyKes70J/Al7t96JblKOR7yFen4hJe058duVb4jJMEVGYTLqjT oMgFfxk04t0DLRN1fi9xq4pX4G/LIm2GTZT2evqAw42Ddc+qytINbI8+2OT6wgd7JaS7 7klgqaOch1SmEjglMpLswQDLIq2B2rzFnjHXxT+yLY3cmI6+tSTOypgHsUwZkBrWOE8e ZtAw== 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=Jme9zz2lpphQFdQzWSwDey8PeXCFcOvKT0bkE6Mbk38=; b=OETHcUKKEdzeEX0qE+ffl15H7a0/iUt68OlR8RS1qjtGf6hCZcSBZcos2jHwQvpEq8 AaS6b+7yaZR4J8UiZfrYpB07tdq9axtXtK2pDWbN5JlRrr8t3m6SbmjKu38HQex9KF3j 6PRK0xPnxICo7kyQZTv8JKFBhen/LZVnY8GJowPBUdFl4nmk53yGolMjUsTGtLk7sS20 UY0WftHheZZszkkWrVQVMfS/cASwn5GtEEc/PbMNMVkhaxFi4WnxzsqoRnPhfzm54mmo Ae2E6ABMCVR2RXDJYtoGEPv+cEK1rxV4tswJSX6oOP98M9pwr2uFfLDFuOj8X3t/XDHw TShQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=Ba3guL0B; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q2-20020aa7d442000000b0049e02ae1365si9032578edr.117.2023.01.17.05.17.31; Tue, 17 Jan 2023 05:17:43 -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=@infradead.org header.s=desiato.20200630 header.b=Ba3guL0B; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236858AbjAQNFy (ORCPT + 48 others); Tue, 17 Jan 2023 08:05:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48020 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236788AbjAQNFu (ORCPT ); Tue, 17 Jan 2023 08:05:50 -0500 Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 85F1930EA3 for ; Tue, 17 Jan 2023 05:05:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=Jme9zz2lpphQFdQzWSwDey8PeXCFcOvKT0bkE6Mbk38=; b=Ba3guL0BWUgd+jP/llCnOAhXLF Hnv6WeFYTdqcpMKQlUG9YGrc0FO1Bv3t7ux7SiCcujeC1p1NOV6VZ0bNJpfJ7wT/j62DCMuGfUNFD RvkZjmcqXsXp5GGw/QCeOt+zQia8tysEgFE7TZQxtwXbqJp0F5I2HmEVxEuQdtdyX4DNpzrRHXCl7 /CV2MTTSradvHELrV5oyiE2gadTyfn5NJiN3qbNHX0RzEqMh3z9BJFkQj3uqk/MFkolkUQ9TysK3+ E64xzeM9j+54aHPwWsl41/OSc3ueHtPADUWus2j2m5f4zJe06yEMjdZfZs2t3IQqHReZRwPLFdNSx sJqMYJIA==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1pHleN-005wDX-0T; Tue, 17 Jan 2023 13:05:15 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id A6581300094; Tue, 17 Jan 2023 14:05:22 +0100 (CET) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 7A24B264FC770; Tue, 17 Jan 2023 14:05:22 +0100 (CET) Date: Tue, 17 Jan 2023 14:05:22 +0100 From: Peter Zijlstra To: "Kirill A. Shutemov" 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: 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: <20230111123736.20025-9-kirill.shutemov@linux.intel.com> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,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 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?