Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp13147426rwd; Fri, 23 Jun 2023 16:53:34 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ61jvrCf/JqLJqMKOCPmhGtp59kfuMM7fiz7EXoDx82HtHIZUS0zCKMx4XnG3YR2iM0Hekr X-Received: by 2002:a92:c943:0:b0:342:d7b:4667 with SMTP id i3-20020a92c943000000b003420d7b4667mr22667953ilq.16.1687564414631; Fri, 23 Jun 2023 16:53:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687564414; cv=none; d=google.com; s=arc-20160816; b=sni7vea7vxVPhJR9LMEX+93JxF4jYov31YYjQNPPZ6eEepuy1a7uNB4GYzQbXh1aX8 CfQ8/PXqoihpyeMRdpMlIW4P5gfmOFgN+CHOfzfaA33Hch6B+rG5KiZoFOyOcCmZlcOS G07/4M3NMjxnOjpb2Ug9hNulsfeO7K+26Os8qv/yUXFEwQJs22I9G9zBLjQG54OagtZD YgqkU6aQYpc4uTCd1NdAZbyaijP/+XmHpGntm7WCtjRUJRB8k/oj2Eyy+3HpzdnjyfMp gfsfIecJba/guJ36O3wx5cK0VoDKkBS62rDhtn5U1jm4H1cjwiZ3wjYnmsrjI7I7kuUw MWFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=o5h2Fku8APXH3iOdYKNWdhjGBKRm3o6/JPRIVNrW9qA=; fh=YGe6ZOFH/FqNLRlupQGNLVzQZlOxmT2/tmdCrnzipkI=; b=szI19MzN6LSFCTbVURd2eUEcFcJyk0tsbNf4KTPrF1ENd50u4R76LPFmFJI7fXFNsF TfocE6dcLE4rFA/5j1+VGBZKH9sazyp9dJffHACU0IDSvhQO3TMOw5K1nNyhIls5KR7u xw4slJkEuvU5ovqSx5VhuyGjrLmuGNV/n6tjdGQJ/3jkeU8PcFVLbxi3glP+D6bkcLD4 33N9P+yOafc7lN+ttDVXnphXuk/lM/Lavpgz00JgYxVDZGr33iehrtywSWKbfZaXkMT8 DvSMeKk8Y7bwH397vk1ds7oQhijkKn8K4bQQtd1J9flAC1HDfRt6Hf02D4fsxMGc1tuB JEsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=QFfPEzgV; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w11-20020a62820b000000b0065024e5049bsi198048pfd.334.2023.06.23.16.53.23; Fri, 23 Jun 2023 16:53:34 -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=@gmail.com header.s=20221208 header.b=QFfPEzgV; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229975AbjFWXS5 (ORCPT + 99 others); Fri, 23 Jun 2023 19:18:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48880 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229509AbjFWXS4 (ORCPT ); Fri, 23 Jun 2023 19:18:56 -0400 Received: from mail-yb1-xb31.google.com (mail-yb1-xb31.google.com [IPv6:2607:f8b0:4864:20::b31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E393F1FCC; Fri, 23 Jun 2023 16:18:54 -0700 (PDT) Received: by mail-yb1-xb31.google.com with SMTP id 3f1490d57ef6-bd5f59fb71dso1136022276.3; Fri, 23 Jun 2023 16:18:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1687562334; x=1690154334; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=o5h2Fku8APXH3iOdYKNWdhjGBKRm3o6/JPRIVNrW9qA=; b=QFfPEzgVXYAeQa/6a5IBaDl9QfzWAr6OxLdvn4H9sUUu1YPmlx9TYMKYcOkzf8Dri+ I+EW41qX0D4ZLpiWpESkGo34UvdXh1t4YXWQjbcFDqWssJDjt7mcSlWmal0Io/ON+E4J QYEv3qDTt/TaPxDICboK4LH8hXpS/ZaV3vealWnFLolM7YMeOqg7dpU8bsTECkoLaCAe vdvmxkAQUYI0zrdjEpHv3RFRNQsZzBzcLy4T+Lo0cXVco+/1cQdBdoa9TMn4Az3qKXYR R/2Xy40EeDFEzF5J83APlgmNUsCx/Bt4V/JP3RTpBKSMDAA/ziEa/sGACVr25XR1AUJ8 X54g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687562334; x=1690154334; h=content-transfer-encoding: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=o5h2Fku8APXH3iOdYKNWdhjGBKRm3o6/JPRIVNrW9qA=; b=JkxSxKdNcNey6TEw6A9tN86RTXM7XhAzn9qYm2+VFZVBHF8uRze+KeYKVhQoGTMCmb ok0voCJIYsf/VQe7TSaQeSmxhMotHe4ws7YpHAtGwOfJRq+V3KV9TGULDwvlCrsobz3t fvgw1nS7RC5RWoHWl+HDg8EGP2KNJckOVpGoLJBcnoeSbzhQTM7QjE5Yq691TNX2Stc4 Ch5G5xUoDiHJG2E9BnFYRtJZliU3cc6+otF5pdA8+TLVk2Yn5AHTOm/sRQIoh9GOrmqR z80EQgntGlBt9q5Oog2Ma9zReB+8RUJwjAQ29jwYwTWUc6FKDch3MGTeZC0o0rIqrFLt Pk0Q== X-Gm-Message-State: AC+VfDwy4Fh3MuB24B6QLJp7oyPGRrHr38OBTl7sAgJb8C+408crE5mU v0AW61W7B0Q53nkgmPXO53L//5UAebToHch1QMw= X-Received: by 2002:a25:4050:0:b0:bfe:9259:8f1a with SMTP id n77-20020a254050000000b00bfe92598f1amr10554353yba.50.1687562333975; Fri, 23 Jun 2023 16:18:53 -0700 (PDT) MIME-Version: 1.0 References: <76CB17D0-5A66-4D49-A389-8F40EC830DC0@sladewatkins.net> <85822c3c-2254-52cc-e6b1-9c89adb63771@amd.com> <85aabdc8-07cd-3285-1f3f-605f9ebbab18@amd.com> In-Reply-To: From: Namhyung Kim Date: Fri, 23 Jun 2023 16:18:42 -0700 Message-ID: Subject: Re: Invalid event (cycles:pp) in per-thread mode, enable system wide with '-a'. To: Nick Desaulniers Cc: Ravi Bangoria , Stephane Eranian , Slade Watkins , linux-perf-users , LKML , Ian Rogers , Kees Cook , sandipan.das@amd.com, Bill Wendling , clang-built-linux , Yonghong Song , Peter Zijlstra Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 Hi Nick, On Fri, Jun 23, 2023 at 9:23=E2=80=AFAM Nick Desaulniers wrote: > > On Tue, Oct 11, 2022 at 10:05=E2=80=AFPM Ravi Bangoria wrote: > > > > On 12-Oct-22 9:36 AM, Ravi Bangoria wrote: > > > On 12-Oct-22 3:02 AM, Nick Desaulniers wrote: > > >> 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 pr= ofiling > > >>>>>>> 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 pa= tch. > > >>>>> > > >>>>> Can you confirm that > > >>>>> $ perf record -e cycles:pp --freq=3D128 --call-graph lbr -- > > >>>>> > > >>>>> works with just that patch applied? Or is there more work require= d? > > >>>>> What is the status of that patch? > > >>>>> > > >>>>> For context, we had difficulty upstreaming support for instrument= ation > > >>>>> based profile guided optimizations in the Linux kernel. > > >>>>> https://lore.kernel.org/lkml/CAHk-=3DwhqCT0BeqBQhW8D-YoLLgp_eFY= =3D8Y=3D9ieREM5xx0ef08w@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 approache= s are > > >>>>> architecture / micro architecture issues with sample based profil= e > > >>>>> 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=3D128 --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 t= op > > >>> of event-context rewrite patch[1] should be sufficient to make cycl= es: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 =3D { > > >>> > > >>> static struct perf_ibs perf_ibs_op =3D { > > >>> .pmu =3D { > > >>> - .task_ctx_nr =3D perf_invalid_context, > > >>> + .task_ctx_nr =3D perf_hw_context, > > >>> > > >>> .event_init =3D perf_ibs_init, > > >>> .add =3D perf_ibs_add, > > >>> --- > > >>> > > >>> [1]: https://lore.kernel.org/lkml/20220829113347.295-1-ravi.bangori= a@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 abov= e? > > > > > > Yes Nick. I was planning to send it once the rewrite stuff goes in. > > > > Hi Nick, > > > > Since you have practical use case, would it be possible to run your wor= kflow > > with perf rewrite and IBS patches applied? It will help us in finding/f= ixing > > more bugs and upstreaming these changes. > > Hi Ravi, > Sorry, I'm not able to load a custom kernel image on my employer > provided workstation, and I never got approval to expense hardware for > testing this otherwise. > > Was there ever any update on this? I'm on 6.1.25 now and still cant run > $ perf record -e cycles:pp --call-graph lbr > $ cat /proc/cpuinfo > ... > model name : AMD Ryzen Threadripper PRO 3995WX 64-Cores > ... The commit 30093056f7b2 ("perf/amd/ibs: Make IBS a core pmu") in v6.2. $ git name-rev --tags --refs=3Dv[2-6].* 30093056f7b2 30093056f7b2 v6.2-rc1~176^2~16 https://git.kernel.org/torvalds/c/30093056f7b2 Thanks, Namhyung