Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp5256181rwb; Tue, 17 Jan 2023 11:06:46 -0800 (PST) X-Google-Smtp-Source: AMrXdXs/2MAiaig4AbuisA32pGjhBI7JN472s8bALwbEDu6Srsf1Xr+dgdbxmclt4DHAhRktj1lo X-Received: by 2002:a17:906:698:b0:861:9b5b:4c3b with SMTP id u24-20020a170906069800b008619b5b4c3bmr17982191ejb.17.1673982406496; Tue, 17 Jan 2023 11:06:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673982406; cv=none; d=google.com; s=arc-20160816; b=DHHpevTvXEEjgxFw2djF5QR0R/bbIqjT+wTGuaQHnjm0b7kb5IKHHQvVAR4Z918t/U TuTl4pbJXnWs+6PJtfel3D8I92LOKMP/M2iHDEWrYxwOgCgQhYQn9U8TgJCc2rhiTfPz SHEW63PJV9d6KI6/R/CNTvhSUoYWOmH8ZynspHj0Njngp/s9FiiUZNy0vA0mfmWEbMdA ibOB4R0I62OuY4qnLEAguInaH9F4qL6Pay/SGc1i5thz/q/qUkwA53xcvY0Xps473sBA Q+r5oF/w3UyHUEp2dvRmZKDTcpS96Jq2pJyQFd8F3HJS9pmDAuMvZT6GMhqu1ZvUnggp 72cQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=prNnNsy5T4xsGuSVCbHAoEeKQx9E2Oycb0EFwKlDuO8=; b=OSJfaonKm9gNPBpdmlECUZDypW5f0AW6F/LMXud+ANzQnfN8akdWZDXY+AewgdV3LL I76758ezXztg8zCg9YFUsIxI5AG7W1OlWGSPL35DmwrC3gt6vWEz3wTD44QoiqbGIwld XTyKp+1q6opOp9AFy3eyVB3yuLHruTLbYqaSIJAx9Zt+QZqa6kKVKHguRyDd0sgkHGOd WylZ+nxisyHkI3TjTwiE7amFs66iZDFuIyK17y8PMQmkPHWoTEYw9ZGZpSMdkwzr1xzh ISCikVe9TF6Kmnj+yUiMziNWEe+8XCVUPftK47GyA/O5tpPvSFgi3dD8t1CDKyhv0Dcj LLIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=cBXaoSjv; 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 l4-20020a170906794400b00873553bd0f0si1533833ejo.719.2023.01.17.11.06.34; Tue, 17 Jan 2023 11:06:46 -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=@linux-foundation.org header.s=google header.b=cBXaoSjv; 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 S230035AbjAQRqL (ORCPT + 48 others); Tue, 17 Jan 2023 12:46:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34716 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235514AbjAQRp0 (ORCPT ); Tue, 17 Jan 2023 12:45:26 -0500 Received: from mail-io1-xd2e.google.com (mail-io1-xd2e.google.com [IPv6:2607:f8b0:4864:20::d2e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 71ADC53F93 for ; Tue, 17 Jan 2023 09:35:22 -0800 (PST) Received: by mail-io1-xd2e.google.com with SMTP id p66so15234765iof.1 for ; Tue, 17 Jan 2023 09:35:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=prNnNsy5T4xsGuSVCbHAoEeKQx9E2Oycb0EFwKlDuO8=; b=cBXaoSjv+haWHr24w4kmz0KG5HEm76xSSB94stcm2gzSbvIQWrxVUPu/ybPXmVDqw+ sWSz470KzDgVRCuSsXdGDl8U5o99BT8waqFmlR72/cTKlpgRz6UnLNxqQ7r7Nx4RHePN a8Dk5piW3FOS3mk9DurMYeox+YIRIzoIW/vTQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=prNnNsy5T4xsGuSVCbHAoEeKQx9E2Oycb0EFwKlDuO8=; b=xKPbQiDvPsfT0fR84GwUTLHFnBLJU0xYjCDM09nfbjZsIoHYLAmduYQil2LlM3nOak ormoEpQ3SWa4OmI3zHH66D3BjKMrVCxAamx6tVCvnByJUKUqpE9Xbb5g1CyYfvEdCWwb iGWGE720XC5nlz96UruUtHLsLzpPWv84jhBL30GHRlUW9reHJE4rdlS+OlV1zmZNNIOl WmO2ow0jiqP+FglBbOEAWxtPQerDsuxRZoxcsfYvt89mpCPsS9sF11X5XnsenKtoJEyz AGQvGqp1g6NpHJdycHgReShOq13JoqcHUVaDCeAHTEJs3VpRVx36iSaRg/JYTnr27vnV cVBA== X-Gm-Message-State: AFqh2koHH+h62kIYNvDYxdTFa48F/p2cGXmLbbfZa7U0BKfD58r5iaJP Q2ZOx75s4NQs2IUrxyJiCP+joWcc7ycTjN3k X-Received: by 2002:a05:6602:368e:b0:704:6e73:d9af with SMTP id bf14-20020a056602368e00b007046e73d9afmr19065749iob.15.1673976921265; Tue, 17 Jan 2023 09:35:21 -0800 (PST) Received: from mail-io1-f42.google.com (mail-io1-f42.google.com. [209.85.166.42]) by smtp.gmail.com with ESMTPSA id d16-20020a6b6810000000b006de73a731dbsm10485401ioc.51.2023.01.17.09.35.21 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 17 Jan 2023 09:35:21 -0800 (PST) Received: by mail-io1-f42.google.com with SMTP id i70so5999441ioa.12 for ; Tue, 17 Jan 2023 09:35:21 -0800 (PST) X-Received: by 2002:a05:620a:99d:b0:705:efa8:524c with SMTP id x29-20020a05620a099d00b00705efa8524cmr178735qkx.594.1673976555002; Tue, 17 Jan 2023 09:29:15 -0800 (PST) MIME-Version: 1.0 References: <20230111123736.20025-1-kirill.shutemov@linux.intel.com> <20230111123736.20025-9-kirill.shutemov@linux.intel.com> <20230117135703.voaumisreld7crfb@box> In-Reply-To: From: Linus Torvalds Date: Tue, 17 Jan 2023 09:28:59 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCHv14 08/17] x86/mm: Reduce untagged_addr() overhead until the first LAM user To: Peter Zijlstra Cc: "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 , Bharata B Rao , Jacob Pan , Ashok Raj , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Sami Tolvanen , ndesaulniers@google.com, joao@overdrivepizza.com Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=no 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 9:18 AM Linus Torvalds wrote: > > The reason clang seems to generate saner code is that clang seems to > largely ignore the whole "__builtin_expect()", at least not to the > point where it tries to make the unlikely case be out-of-line. Side note: that's not something new or unusual. It's been the case since I started testing clang - we have several code-paths where we use "unlikely()" to try to get very unlikely cases to be out-of-line, and clang just mostly ignores it, or treats it as a very weak hint. I think the only way to get clang to treat it as a *strong* hint is to use PGO. And in this case it actually made code generation look better, probably because this particular use of static_branch_likely() is a bit confused about which side should be the preferred one. It's using the static branch to make the old case not have the masked load, but then it's saying that the new case is the likely one. So clang ignoring the likely() hint is probably the right thing here, and then the wrong thing in some other places. Linus