Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3087260rwb; Mon, 15 Aug 2022 17:49:11 -0700 (PDT) X-Google-Smtp-Source: AA6agR5+XIBWrzeCst61peXiQkK6AG+C4Xxn4Zv6Sjsnv6zyLbHs6TKTfTBn4tNzj7xZuoJmzDd0 X-Received: by 2002:a17:90b:4acc:b0:1f5:7f05:12e8 with SMTP id mh12-20020a17090b4acc00b001f57f0512e8mr20540439pjb.92.1660610951221; Mon, 15 Aug 2022 17:49:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660610951; cv=none; d=google.com; s=arc-20160816; b=mxDD9S61CXOi6Gjo1gVICQnA/zUe0VUtzeFB2/LdvNOfHYbXxjbUHtdghZ3K2Ubl4S R03HjG5InnHU89Df3anIm0yyxN4uillyiSCC0xr5CFqepEdgQ58pOhmvrzXp1yl5GRDn Zbc49NWcAEvtGJKmQBRXGgI7aQcVaELZfp4wBdHQ1Wa6CPxK6fRDHA3OweGCVkFigOlT luNbvfmo9UKCb97Bm+a4nXDnn/hj+d3EGWQ+scfkqpX9aHPA4LDMtvWCiokrCZvxDZYv zIZ/xsEJgpMPvR3jDsdpDhvyT3b12K3PCf4Iv2Wu7mA4vSQg0rfl3eELN/kP/knKo45m NIQA== 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=SlaiWNqTZoWL+lFJCamcfLR1t+u+g8gF/zBXqP5yDPc=; b=Pk7RN/PyqyLGrseZuODe/uwqs/3ffbmamMjYCj2z8u7Nikho6pi+bR1hWhRxZPULol qqMgGRQGAKUg9z3P2SByAVzgFe+vL3QDlWLYiNavhFreW0LApOqhZ/05OHPU5utrTFBa XSw2sjQJn9YJWj6fZ39JxuSiZ8+RoRKv3BCZdnz4no32htVYlO+frVVb44GkRyfrfuzE PNtfCaKyM6MSh8BUoXPNohOkaUIFucRcN+ALB55OvwuwFSWi+CwMguSPseeZEZjDiihg 36hVX8JiishVdrYuZ4qf4+5gcVvjA/u2bmsVxqJaeAg9DV0k0QEnpxlttTpRCBXBzty2 WZbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b="TobsT/D9"; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o3-20020a170903300300b001714f0dbebdsi10141764pla.523.2022.08.15.17.49.00; Mon, 15 Aug 2022 17:49:11 -0700 (PDT) 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=@google.com header.s=20210112 header.b="TobsT/D9"; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349413AbiHOWc7 (ORCPT + 99 others); Mon, 15 Aug 2022 18:32:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41334 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350984AbiHOW1X (ORCPT ); Mon, 15 Aug 2022 18:27:23 -0400 Received: from mail-vs1-xe2c.google.com (mail-vs1-xe2c.google.com [IPv6:2607:f8b0:4864:20::e2c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0447C6C755 for ; Mon, 15 Aug 2022 12:45:59 -0700 (PDT) Received: by mail-vs1-xe2c.google.com with SMTP id o123so8175260vsc.3 for ; Mon, 15 Aug 2022 12:45:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc; bh=SlaiWNqTZoWL+lFJCamcfLR1t+u+g8gF/zBXqP5yDPc=; b=TobsT/D9AeL7kSYxDLQc8dWGrs6dhRGxGd3qfeoVBiFnMLiGP4TJxthchSbOuUE4mO ciq12U98VGy1yn3HhrlJKkkyZR5AViNPjPtC/i+oaXTBKsGT1Z//fflwTW+agfEf6+Mf tFKCy0Uk2HKm013Snihtw1eqLih0ekayliUMdPfmGRUR1LTtQ50/6+a10XYInPDqLLuA PdzMyoco4dkxGORhencXVHU3cclCDq7rA5AyfLsTjG71zpiyvU2Hlq7twfJJWbNlX/nc VL4cGtrRWRxEul0n8MxpAvCOFeZ4ucv6j4IOXqzIeRxtzM0OsP38XSvjqP6hmNZQL3A0 vBSQ== 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; bh=SlaiWNqTZoWL+lFJCamcfLR1t+u+g8gF/zBXqP5yDPc=; b=oGkqFoD6LbAJtpo/Vp1E/uXo22akfPldxB0AnIHyiC7F36IW+Hv9mu2/GfSbCLxXp7 c+vWhLk9v//StL3zqz7gymJQLMIo+1FUeSp8h6thJlpDFHxV8LoAuBSmU0/ridhkhnm8 soVg7bwnKKEdVEGqe02pb/wwNeiKw1ruaAZ//tPgdahYZmYtOgi38CkunHxw1swXvDn8 obpCDRAmrMbkuDWhALbaA1nNyklR9VJ3p3Dr5grtPVV27gMjHM1voI5foiErTg2pm5pT 1DhgXC23JN++wUk4+DyxwD5ZU9EzDeI9Y+fcesYw/cKI9HDdB4vF26ZJr+D2aHb6gjzp dLsQ== X-Gm-Message-State: ACgBeo1GR2/SO0s9U9H9ij18pU4Z1wzcTOS93ItZFfpxykdCI768sUI+ zv52zZxUPUAC1sawP8s2uodw7J/2h9SZvHj2X3HSuw== X-Received: by 2002:a67:a408:0:b0:38a:dbca:760 with SMTP id n8-20020a67a408000000b0038adbca0760mr1557770vse.54.1660592758029; Mon, 15 Aug 2022 12:45:58 -0700 (PDT) MIME-Version: 1.0 References: <20220810210656.2799243-1-eranian@google.com> <0267c94e-7989-ca92-4175-d820d1d63a0c@linux.intel.com> <48297c1e-6e44-53f1-da7d-4437ed87cf6f@linux.intel.com> <2fc8dc1d-6922-e2e0-8b5d-fad25ab12cbd@linux.intel.com> <6ebd8b96-b589-cded-58f0-76e56a64081c@linux.intel.com> In-Reply-To: <6ebd8b96-b589-cded-58f0-76e56a64081c@linux.intel.com> From: Stephane Eranian Date: Mon, 15 Aug 2022 12:45:46 -0700 Message-ID: Subject: Re: [PATCH] perf/x86/intel/lbr: fix branch type encoding To: "Liang, Kan" Cc: Andi Kleen , linux-kernel@vger.kernel.org, peterz@infradead.org, kan.liang@intel.com, acme@redhat.com, namhyung@kernel.org, irogers@google.com Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL 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 Sun, Aug 14, 2022 at 12:37 PM Liang, Kan wrote: > > > > On 2022-08-12 4:16 a.m., Andi Kleen wrote: > > > >> > >> I think the option is to avoid the overhead of disassembling of branch > >> instruction. See eb0baf8a0d92 ("perf/core: Define the common branch type > >> classification") > >> "Since the disassembling of branch instruction needs some overhead, > >> a new PERF_SAMPLE_BRANCH_TYPE_SAVE is introduced to indicate if it > >> needs to disassemble the branch instruction and record the branch > >> type." > > > > > > Thanks for digging it out. So it was only performance. > > > >> > >> I have no idea how big the overhead is. If we can always be benefit from > >> the branch type. I guess we can make it default on. > > > > I thought even arch LBR had one case where it had to disassemble, but > > perhaps it's unlikely enough because it's pre filtered. If yes it may be > > ok to enable it there unconditionally at the kernel level. > > > > Yes, Arch LBR should have much less overhead than the previous > platforms. The most common branches, JCC and near JMP/CALL, are from the > HW. Only the other branches, e.g., far call, SYS* etc, which still rely > on the SW disassemble. The number of the other branches should not be > big. I agree that we should enable the branch type for the Arch LBR > unconditionally at the kernel level. > > Peter? Stephane? What do you think? > > > Still have to decide if we want older parts to have more overhead by > > default. I guess would need some data on that. > I don't think you want that. It is okay to have it when it is free. Otherwise it is best if it remains opt-in. > > The previous LBR already has high overhead. The branch type overhead > will make it worse. I think it's better keep it default off. I think we > can make it clear in the document that the branch type is only default > on for the new platforms with Arch LBR support (12th-Gen+ client or > 4th-Gen Xeon+ server). > I am okay with that.