Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp1394136rwr; Thu, 27 Apr 2023 17:33:34 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4aI4aWxqd10tiAvLRHwPpjut2grfK6Vi5tgAtrudk04UlcL2DBcf3mU1rWGOBd15omRUTA X-Received: by 2002:a05:6a20:12d5:b0:ee:e61f:cb6a with SMTP id v21-20020a056a2012d500b000eee61fcb6amr4636148pzg.31.1682642014037; Thu, 27 Apr 2023 17:33:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682642014; cv=none; d=google.com; s=arc-20160816; b=eXKYbKrGieSk2egR3wBCNQd5NcfSP1GRPLqjxGrcDyfkoI/zVNF0RQzMcjI5ytPbi+ ARpg2kiftRDXjau4IJc4SGiFLhU44f8wDeeiTQ2ORqauvIZPOtNlw/KHs2pudj1KEU+5 KO5lLUOY/7i95xwtTqXTuS+huSZv3vS2XwNH2PRWiBHe+Ek9oIra3vHC0xLXQC0eRmT3 b0pf517lPO27+IXRpZovMihZiGYKZZRP9mYHacG9ZAQnJ2sH/gpu5nlS5cR0cR/79GTw Jlmm24tZXIKL9uPMZxiwoktT49mKeApaPHhE63UUiutoGrcbb9c65Bq0CGt7VsMyBMq6 6jHw== 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=kJaY9sgaqKLUmeW0DT4PpZqe8svi0MLaSjCCEjhIrtI=; b=zMYl1vF0E1TjD9aY4xuqMdDz/m7ZDcndmDVIaLr17tEsfvv+huu1L+mn/N40mzqQdK RsYhgAHJiq+shFw+aSfAknVA7+pXK4vmvMEhlZg+jCBwjxRFjXqH7Ala3LO2D8nP563d MFwGJcMJewg5OIBfI/2FKxv/48IUyRNdxzvPcbHgOsal+epoFYkkrrfAq6nXsnXrWtlp R5lJu2hOxH6TymwGmXKXS0V12iJO9F3XB+AkAOLSmxFv05f38QoRpBGiuOYXtGUcl8d1 S1fYoWTJY4AWE6nQaiaBSWvUj9nOFyRLJlKJI2FD0gbggd3l/UEH5F3NbWRz0w+4BOg2 aKhw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=pfVTkOVN; 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 k186-20020a6384c3000000b0051b1d717745si20248428pgd.759.2023.04.27.17.33.22; Thu, 27 Apr 2023 17:33: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=@google.com header.s=20221208 header.b=pfVTkOVN; 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 S1344544AbjD1AdN (ORCPT + 99 others); Thu, 27 Apr 2023 20:33:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35268 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344555AbjD1AdJ (ORCPT ); Thu, 27 Apr 2023 20:33:09 -0400 Received: from mail-qt1-x836.google.com (mail-qt1-x836.google.com [IPv6:2607:f8b0:4864:20::836]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C560E46AB for ; Thu, 27 Apr 2023 17:32:39 -0700 (PDT) Received: by mail-qt1-x836.google.com with SMTP id d75a77b69052e-3f0a2f8216fso869361cf.0 for ; Thu, 27 Apr 2023 17:32:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1682641957; x=1685233957; 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=kJaY9sgaqKLUmeW0DT4PpZqe8svi0MLaSjCCEjhIrtI=; b=pfVTkOVNi1QXcT1uTFiTcD8+HIfY8ZOmRtmS4qP4m5u3RIksUetT36jzwry0hhMOzj ocKVJzhrS7E1VrRRfNhRFD57wImEa0XLNL1YWX40M7B+arP1Iq7nv2c73KDgP/H0AfmS fcsOFoejBQyETzM7aaJPz23RiAojihr611xMC1rlyOP1liMzRFizIUFveFWx9qF1jsGJ yifRJYeZHlUlyEbdn3SZHT2Lr2bSEt+roEW96PEpSaNrtV+k1m1v8tUcz2xMSjyPdJyO 826dqo3oPIO7h8pIyb14hTh5/3mnPUN8q8IKNAdWLRMqcNinaIk6LjQj4Wqm7VWnU5cP /qBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682641957; x=1685233957; 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=kJaY9sgaqKLUmeW0DT4PpZqe8svi0MLaSjCCEjhIrtI=; b=LfG/RgL9pbSCcIbhSzYEIObD1H1hbgMHAPQSdhkvFQFvYo+0tjiKEDjCrhK8qv3HIc zxHiZYZCjysQRTFKUyzqmBytySiU95ARL5fnTkTC4nQdGMi+JU5/jXIYqO1uk257aptl vEstMm/HVSit8rQ7kuWSokdYDyGc3V680/pVEjv+/Xkp3+Uz3699uCQYvZ+mtUHAk7b/ gkAP7YL4rr45tKYzlyIA3tzu/NETi950IbrQcBFq1UVQh8cMTmCcsJ4hCkg1Rl0MzaKg yxyXPuf+Zghwkstfl9gcvOFFwjxXjO4lGQauJYkJWFakSVPtBKEBUWvxg+pQBYEblA4/ 5k5g== X-Gm-Message-State: AC+VfDxP2Ay56/FhOVgORMWG0YwmxpVVptQ4piuSahaffUKrW5nU7DKy 5Vd64hw57pHDnH0W8KRPGQ8AwIl5yNZ74YiK6P5f6Q== X-Received: by 2002:a05:622a:1a0e:b0:3ef:3510:7c3a with SMTP id f14-20020a05622a1a0e00b003ef35107c3amr73868qtb.3.1682641957523; Thu, 27 Apr 2023 17:32:37 -0700 (PDT) MIME-Version: 1.0 References: <20230427234833.1576130-1-namhyung@kernel.org> <20230427234833.1576130-2-namhyung@kernel.org> In-Reply-To: <20230427234833.1576130-2-namhyung@kernel.org> From: Ian Rogers Date: Thu, 27 Apr 2023 17:32:26 -0700 Message-ID: Subject: Re: [PATCH 2/2] perf lock contention: Rework offset calculation with BPF CO-RE To: Namhyung Kim Cc: Arnaldo Carvalho de Melo , Jiri Olsa , Adrian Hunter , Peter Zijlstra , Ingo Molnar , LKML , linux-perf-users@vger.kernel.org, bpf@vger.kernel.org, Andrii Nakryiko , Hao Luo , Song Liu , Andrii Nakryiko Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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=unavailable 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, Apr 27, 2023 at 4:48=E2=80=AFPM Namhyung Kim = wrote: > > It seems BPF CO-RE reloc doesn't work well with the pattern that gets > the field-offset only. Use offsetof() to make it explicit so that > the compiler would generate the correct code. > > Fixes: 0c1228486bef ("perf lock contention: Support pre-5.14 kernels") > Co-developed-by: Andrii Nakryiko > Signed-off-by: Namhyung Kim Acked-by: Ian Rogers Thanks, Ian > --- > tools/perf/util/bpf_skel/lock_contention.bpf.c | 14 +++++++------- > 1 file changed, 7 insertions(+), 7 deletions(-) > > diff --git a/tools/perf/util/bpf_skel/lock_contention.bpf.c b/tools/perf/= util/bpf_skel/lock_contention.bpf.c > index 30c193078bdb..8d3cfbb3cc65 100644 > --- a/tools/perf/util/bpf_skel/lock_contention.bpf.c > +++ b/tools/perf/util/bpf_skel/lock_contention.bpf.c > @@ -429,21 +429,21 @@ struct rq___new { > SEC("raw_tp/bpf_test_finish") > int BPF_PROG(collect_lock_syms) > { > - __u64 lock_addr; > + __u64 lock_addr, lock_off; > __u32 lock_flag; > > + if (bpf_core_field_exists(struct rq___new, __lock)) > + lock_off =3D offsetof(struct rq___new, __lock); > + else > + lock_off =3D offsetof(struct rq___old, lock); > + > for (int i =3D 0; i < MAX_CPUS; i++) { > struct rq *rq =3D bpf_per_cpu_ptr(&runqueues, i); > - struct rq___new *rq_new =3D (void *)rq; > - struct rq___old *rq_old =3D (void *)rq; > > if (rq =3D=3D NULL) > break; > > - if (bpf_core_field_exists(rq_new->__lock)) > - lock_addr =3D (__u64)&rq_new->__lock; > - else > - lock_addr =3D (__u64)&rq_old->lock; > + lock_addr =3D (__u64)(void *)rq + lock_off; > lock_flag =3D LOCK_CLASS_RQLOCK; > bpf_map_update_elem(&lock_syms, &lock_addr, &lock_flag, B= PF_ANY); > } > -- > 2.40.1.495.gc816e09b53d-goog >