Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp2855703rwi; Tue, 11 Oct 2022 14:35:15 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7o6wFRIcPq8x2OFQbAHF2fVrFBs51tzoUxZm/HzLI2ZgU9aA29omx9mhPg49gP5L+vVd6+ X-Received: by 2002:a17:902:be18:b0:178:b9c9:97b8 with SMTP id r24-20020a170902be1800b00178b9c997b8mr25509660pls.38.1665524115354; Tue, 11 Oct 2022 14:35:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665524115; cv=none; d=google.com; s=arc-20160816; b=Rymfe7Dq+jYQhK0GQEaywWh9J515zLZoA/O2FWzrff+1J5P0SaEL/3lY0+OVvB0WiX nLNowBvWeoUpGK1rFBNK9O0u8XM1Xc0FamyU+csYDohJzsGFLlha/GIn2qUrmQi0aC+L lMHOkBxbKsq9mItQREo27sJAxfYIU3fOpdC7xOcKjDWXaa05O/17TGfHVxpf6M6/PqyR +678zyVrBnGlhYYqU8AZeTrDXTTWa5vHm59j+jN9tFoQR4lCRLfkCT97CkvisoIA3FdT awH6MRGecOILFIPAxi7YOe1K+WObJS1QhuS2UTwRwamdQKLvr+8PyCof8S99SrnYEqeB PaOw== 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=ikGBgko34MK8Q4AzkK3JoVI5yFlG4OFIaLI3Bh2Pdvk=; b=AmWYa77TCfVO0seKQzMsIVMbC7o968jNBL6qia+qlylhT54CZ9MkeKFXiJZ2Sj6c+Z DCSjpx1NVwdPYrhGXeEhSSudqBItY1gYGHdI+2w3qF4TlPrAeWBWxKxKYTMIaHUppqvk aIN2+9NEV/QS5WR7Uuwjq/wwNIhwRoKzsnPzInD2S0KM6A8+7D59HW38wJLQYWWbNST+ l9FK4QkktqMTM/aQRIzxmWtMl5cEPt97y7XAuZoKnZt6S4FblbVTwuJnTPigM87ieGBW 6h2YuQP/VMENvEYhlvKRuL3j5utIJS24DxYM7xjvd26DomC8mhn/UAge2VwybPsXhfLm 4SAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=TBVibUTb; 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 i13-20020a633c4d000000b0043c2621ee86si16163850pgn.494.2022.10.11.14.35.03; Tue, 11 Oct 2022 14:35:15 -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=TBVibUTb; 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 S229589AbiJKVc1 (ORCPT + 99 others); Tue, 11 Oct 2022 17:32:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58396 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229469AbiJKVcY (ORCPT ); Tue, 11 Oct 2022 17:32:24 -0400 Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 71F0092594 for ; Tue, 11 Oct 2022 14:32:23 -0700 (PDT) Received: by mail-pj1-x102e.google.com with SMTP id fw14so13597784pjb.3 for ; Tue, 11 Oct 2022 14:32:23 -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:subject:date:message-id:reply-to; bh=ikGBgko34MK8Q4AzkK3JoVI5yFlG4OFIaLI3Bh2Pdvk=; b=TBVibUTb+e+fqcJcnLpSEAgXBwg/5lAvgViQjDw5VSZnqEIJ4ZYFGy4Lx0WWSlruVY yYzo8d5UsknaIBJ05dROYJNKw1IBdsNHfqJWTX6aTAEtpa7LdQlExy5dwrWW2IvCN++Z wNfDaDvn7TdNqXf6R0909mywmpJJaswv6WKub/g4xXrPsVkVxQhimgJZwoMZsiFJYRIB Dha6Hx7uzVLNRRM8Zk1iwJbchU2+cUjtjyDI66jRw8z4tJMBs8+Xi/zyW3X9nPVrI5Ij hD61P6ACVj5QHawphHPWH1Kf73y6Zdz9FwntK8yUZDl9TiXYytbelmNFNSyQdnSdfbsT u0lg== 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=ikGBgko34MK8Q4AzkK3JoVI5yFlG4OFIaLI3Bh2Pdvk=; b=YgYjd5I6t5GrYKQG14+mvVmYh8c61WfQ/NErDFFW/+FSVSYlsH1cm6vL0KkYQFrTq5 RRC3EZx2f4OLy7PFXoUQgNz++3yzqNXoH+HiMJ+IFdijH2GOQRfym96f9cqNuv837hsz izTR962hMeVHxAF54sruWhHaCAHGr45HB15/ioyz55TtLArHYD/IM2rSdimYPtmtgFSj OpXW531WsrEQuNPfLgoYzp9hYwgH61pav1jcfOIv+nH57BY/pWBhQHCpLIc2f53ULtzB ZLMamUbjiROwqMJungJyTzhiRUMK3kRSZKKU69/caEnPgN0+hLW+hDn4Z3lkezOkB1XJ ocog== X-Gm-Message-State: ACrzQf3WeKwKlvaFTk3bPGXHossgCkw7E/jM1Kl9PcK+XBn0tzlEw+kF Bk9C22A8ZQyHS0tGGBfBXRPgiEifxYzbYwdrTzhyBQ== X-Received: by 2002:a17:902:b218:b0:184:710c:8c52 with SMTP id t24-20020a170902b21800b00184710c8c52mr92201plr.95.1665523942762; Tue, 11 Oct 2022 14:32:22 -0700 (PDT) MIME-Version: 1.0 References: <76CB17D0-5A66-4D49-A389-8F40EC830DC0@sladewatkins.net> <85822c3c-2254-52cc-e6b1-9c89adb63771@amd.com> In-Reply-To: <85822c3c-2254-52cc-e6b1-9c89adb63771@amd.com> From: Nick Desaulniers Date: Tue, 11 Oct 2022 14:32:11 -0700 Message-ID: Subject: Re: Invalid event (cycles:pp) in per-thread mode, enable system wide with '-a'. To: Ravi Bangoria Cc: Stephane Eranian , Slade Watkins , linux-perf-users , LKML , Ian Rogers , Namhyung Kim , Kees Cook , sandipan.das@amd.com, Bill Wendling , clang-built-linux , Yonghong Song , Peter Zijlstra 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, 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 Thu, Oct 6, 2022 at 8:56 PM Ravi Bangoria wrote: > > +cc: PeterZ > > >>>>> +Ravi who may be able to say if there are any issues with the precise > >>>>> sampling on AMD. > >>>> > >>>> Afaik cvcles:pp will use IBS but it doesn't support per-task profiling > >>>> since it has no task context. Ravi is working on it.. > >>> > >>> Right. > >>> https://lore.kernel.org/lkml/20220829113347.295-1-ravi.bangoria@amd.com > >> > >> Cool, thanks for working on this Ravi. > >> > >> I'm not sure yet whether I may replace the kernel on my corporate > >> provided workstation, so I'm not sure yet I can help test that patch. > >> > >> Can you confirm that > >> $ perf record -e cycles:pp --freq=128 --call-graph lbr -- > >> > >> works with just that patch applied? Or is there more work required? > >> What is the status of that patch? > >> > >> For context, we had difficulty upstreaming support for instrumentation > >> based profile guided optimizations in the Linux kernel. > >> https://lore.kernel.org/lkml/CAHk-=whqCT0BeqBQhW8D-YoLLgp_eFY=8Y=9ieREM5xx0ef08w@mail.gmail.com/ > >> We'd like to be able to use either instrumentation or sampling to > >> optimize our builds. The major barrier to sample based approaches are > >> architecture / micro architecture issues with sample based profile > >> data collection, and bitrot of data processing utilities. > >> https://github.com/google/autofdo/issues/144 > > > > On existing AMD Zen2, Zen3 the following cmdline: > > $ perf record -e cycles:pp --freq=128 --call-graph lbr -- > > > > does not work. I see two reasons: > > > > 1. cycles:pp is likely converted into IBS op in cycle mode. > > Current kernels do not support IBS in per-thread mode. > > This is purely a kernel limitation > > Right, it's purely a kernel limitation. And below simple patch on top > of event-context rewrite patch[1] should be sufficient to make cycles:pp > working in per-process mode on AMD Zen. > > --- > diff --git a/arch/x86/events/amd/ibs.c b/arch/x86/events/amd/ibs.c > index c251bc44c088..de01b5d27e40 100644 > --- a/arch/x86/events/amd/ibs.c > +++ b/arch/x86/events/amd/ibs.c > @@ -665,7 +665,7 @@ static struct perf_ibs perf_ibs_fetch = { > > static struct perf_ibs perf_ibs_op = { > .pmu = { > - .task_ctx_nr = perf_invalid_context, > + .task_ctx_nr = perf_hw_context, > > .event_init = perf_ibs_init, > .add = perf_ibs_add, > --- > > [1]: https://lore.kernel.org/lkml/20220829113347.295-1-ravi.bangoria@amd.com Hi Ravi, I didn't see the above diff in https://lore.kernel.org/lkml/20221008062424.313-1-ravi.bangoria@amd.com/ Was there another distinct patch you were going to send for the above? -- Thanks, ~Nick Desaulniers