Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp1442015rwr; Fri, 5 May 2023 14:19:41 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ51u2NXXG5CDONQPeki0R0hJC4HQ+aOCbMmn4YCOGhvsG87aWDaGYaSF+Z8SaveJtfPlB7y X-Received: by 2002:a17:902:7482:b0:1aa:f43f:e60 with SMTP id h2-20020a170902748200b001aaf43f0e60mr2910308pll.36.1683321581327; Fri, 05 May 2023 14:19:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683321581; cv=none; d=google.com; s=arc-20160816; b=m/xaQB9xrXPfAEm7VThKT3iSNr5cZZcHZhwNj+dmkIcoD3H9n1mp3/VkoIKq2nS1Tj NZDeyG4Olki2PXfMMQCDvsrd3EkZ4qTpalV5yOfsb86F0oarf02kM7JiBKLZUABiLqAs CuqO6ESxgi+JkJcSfQGSCcUr/SH12VcQ+2Qq/RXdBWqniH3qZDHFfVJF+/Wymq/sqqH0 gTI9neBBYsPF1XJ2v4BFkMq8/w4BSskntd0c8gheEJjf93ClH+fpUpG9ISMgxhjA5FGf A15pWXqCrNZoiA96Dy6c62aD0/cG7vccE8TE9uTSBJ6waPEhafroi8yxZWYkWjeuGG82 JfOg== 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=+/s9My8H4cCPZPBiY4BlplIQfiwdkVVysMC+ak2ie9Q=; b=ME6eY6bhntyidcYwBk1EH18JqVMRbKGjQYijFzMhgKikBg6Clj1JlCUxnsIskSSqLK kwEswkpUyafMdby8pEyY2VZII0Y2pkA3zLbCNAUDb4Ls0C0ijCzsTBPksOiJTU7xd/Jk TrCkh87CSQw0F6rbIhtxdf5ZzpuOLpXyHHuI8zjLD4gpS2VIF7t3zkZNNmWx38lMCEcQ Y2Nrkg4KU4SxDHLHVCSvkHQiNJeKU6Y01AvD2Rq3kHpb6Pa/X10GQElDrcaMKvR60MTO G5fAxETQ7mbTmNM56LrKFNdPfcTM3yq/LZ+A3v9N+VxmMxQCXMBIMV15wxYg+1OPywU4 jQ2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=Fb3LMCNa; 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 jf21-20020a170903269500b001aafaf1a917si2267628plb.472.2023.05.05.14.19.26; Fri, 05 May 2023 14:19:41 -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=Fb3LMCNa; 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 S229694AbjEEUqp (ORCPT + 99 others); Fri, 5 May 2023 16:46:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38944 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229870AbjEEUqo (ORCPT ); Fri, 5 May 2023 16:46:44 -0400 Received: from mail-qt1-x831.google.com (mail-qt1-x831.google.com [IPv6:2607:f8b0:4864:20::831]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C43AA4ECD for ; Fri, 5 May 2023 13:46:42 -0700 (PDT) Received: by mail-qt1-x831.google.com with SMTP id d75a77b69052e-3ef36d814a5so1180721cf.0 for ; Fri, 05 May 2023 13:46:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1683319602; x=1685911602; 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=+/s9My8H4cCPZPBiY4BlplIQfiwdkVVysMC+ak2ie9Q=; b=Fb3LMCNaqBZ3DDFbg4Q/J3CLGNRHc83iTyOzQujFh6ddgRVuMufM/52DLIUzM5IrMN R/5EPlW71DMij+/t8o7M6KlZ3zdO5wGPfIyG3AjVg6cn4RTPU2jqsY50kuhVQsmBydsc xaPmgoJi7xeY+yZG8nAeshcAQNHabwFnaFcCk7IZYBj0ifRWIlTL8XmsQAQaA+506QuE Pi3xGmPQhZQd7IsajszL4jQIQw1whX0PocM1Ser2fnyHtWIIczu/7BfnMYOAvluJEWZW xn1rBBOMAupCVC0xmOwGhyNxaguRtQ/h+nybpW1GcS2KqYfLWWV3R7vavM/b1sxM6toM wn8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683319602; x=1685911602; 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=+/s9My8H4cCPZPBiY4BlplIQfiwdkVVysMC+ak2ie9Q=; b=RFj5jupoPOtg6fOIvuseRotyAzjuStEGIfasUQcIilK+IRh/BPm9AgpMx1CfeAQVqK oxNJGb9vM7h8yFSkoLpoGKnKK/XIxGi9UAiV8YJ2ZE+lJQAqHUYhseesXwcrK6v2n6uo QfFcG+mG3epHAePLuPy5GG8DWnuNi4gEpnkIJHY0ds7jz+zqrqbLJ0zhn7g/lJ701H13 AtawLfeiqYQRlebQXFs259hZB79vDZ/VDZdvX65Ju9WpyI7/wjPZ8lJrV2Sc2Ut7DyZk UPasHqcAR08U0RLCN0FGt0OfMVkP3iMHimyFQw8GuolD6zaYp1AYxTH8TaY2v/0+rTEw lvJA== X-Gm-Message-State: AC+VfDznDFDiXC+IWQM57YIIfuMqjLBjJSJjk0/3mtkKRHpMQndi+Bsq e8NiBYmXTw/+GJ0pYJm5/vlMuu/Kq+amvvV+p57kBA== X-Received: by 2002:a05:622a:14d4:b0:3ef:2f55:2204 with SMTP id u20-20020a05622a14d400b003ef2f552204mr85499qtx.6.1683319601659; Fri, 05 May 2023 13:46:41 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Ian Rogers Date: Fri, 5 May 2023 13:46:30 -0700 Message-ID: Subject: Re: [PATCH RFC/RFT] perf bpf skels: Stop using vmlinux.h generated from BTF, use subset of used structs + CO-RE. was Re: BPF skels in perf .Re: [GIT PULL] perf tools changes for v6.4 To: Jiri Olsa Cc: Arnaldo Carvalho de Melo , Linus Torvalds , Andrii Nakryiko , Namhyung Kim , Song Liu , Andrii Nakryiko , Ingo Molnar , Thomas Gleixner , Clark Williams , Kate Carcia , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Adrian Hunter , Changbin Du , Hao Luo , James Clark , Kan Liang , Roman Lozko , Stephane Eranian , Thomas Richter , Arnaldo Carvalho de Melo , bpf , Alexei Starovoitov , Yang Jihong , Mark Rutland , Paul Clarke 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=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 Fri, May 5, 2023 at 1:43=E2=80=AFPM Jiri Olsa wrote= : > > On Fri, May 05, 2023 at 10:04:47AM -0700, Ian Rogers wrote: > > On Fri, May 5, 2023 at 9:56=E2=80=AFAM Arnaldo Carvalho de Melo wrote: > > > > > > Em Fri, May 05, 2023 at 10:33:15AM -0300, Arnaldo Carvalho de Melo es= creveu: > > > > Em Fri, May 05, 2023 at 01:03:14AM +0200, Jiri Olsa escreveu: > > > > That with the preserve_access_index isn't needed, we need just the > > > > fields that we access in the tools, right? > > > > > > I'm now doing build test this in many distro containers, without the = two > > > reverts, i.e. BPF skels continue as opt-out as in my pull request, to > > > test build and also for the functionality tests on the tools using su= ch > > > bpf skels, see below, no touching of vmlinux nor BTF data during the > > > build. > > > > > > - Arnaldo > > > > > > From 882adaee50bc27f85374aeb2fbaa5b76bef60d05 Mon Sep 17 00:00:00 200= 1 > > > From: Arnaldo Carvalho de Melo > > > Date: Thu, 4 May 2023 19:03:51 -0300 > > > Subject: [PATCH 1/1] perf bpf skels: Stop using vmlinux.h generated f= rom BTF, > > > use subset of used structs + CO-RE > > > > > > Linus reported a build break due to using a vmlinux without a BTF elf > > > section to generate the vmlinux.h header with bpftool for use in the = BPF > > > tools in tools/perf/util/bpf_skel/*.bpf.c. > > > > > > Instead add a vmlinux.h file with the structs needed with the fields = the > > > tools need, marking the structs with __attribute__((preserve_access_i= ndex)), > > > so that libbpf's CO-RE code can fixup the struct field offsets. > > > > > > In some cases the vmlinux.h file that was being generated by bpftool > > > from the kernel BTF information was not needed at all, just including > > > linux/bpf.h, sometimes linux/perf_event.h was enough as non-UAPI > > > types were not being used. > > > > > > To keep te patch small, include those UAPI headers from the trimmed d= own > > > vmlinux.h file, that then provides the tools with just the structs an= d > > > the subset of its fields needed for them. > > > > > > Testing it: > > > > > > # perf lock contention -b find / > /dev/null > > I tested perf lock con -abv -L rcu_state sleep 1 > and needed fix below > > jirka I thought this was fixed by: https://lore.kernel.org/lkml/20230427234833.1576130-1-namhyung@kernel.org/ but I think that is just in perf-tools-next. Thanks, Ian > --- > From b12aea55f1171dc09cde2957f9019c84bda7adbb Mon Sep 17 00:00:00 2001 > From: Jiri Olsa > Date: Fri, 5 May 2023 13:28:46 +0200 > Subject: [PATCH] perf tools: Fix lock_contention bpf program > > We need to define empty 'struct rq' so the runqueues gets > resolved properly: > > # ./perf lock con -b > libbpf: extern (var ksym) 'runqueues': incompatible types, expected [99= ] fwd rq, but kernel has [19783] struct rq > libbpf: failed to load object 'lock_contention_bpf' > libbpf: failed to load BPF skeleton 'lock_contention_bpf': -22 > Failed to load lock-contention BPF skeleton > > Also rq__old/rq__new need additional '_' so the suffix is ignored > properly. > > Signed-off-by: Jiri Olsa > --- > tools/perf/util/bpf_skel/lock_contention.bpf.c | 10 ++++++---- > 1 file changed, 6 insertions(+), 4 deletions(-) > > diff --git a/tools/perf/util/bpf_skel/lock_contention.bpf.c b/tools/perf/= util/bpf_skel/lock_contention.bpf.c > index 8911e2a077d8..c2bf24c68c14 100644 > --- a/tools/perf/util/bpf_skel/lock_contention.bpf.c > +++ b/tools/perf/util/bpf_skel/lock_contention.bpf.c > @@ -416,13 +416,15 @@ int contention_end(u64 *ctx) > return 0; > } > > +struct rq {}; > + > extern struct rq runqueues __ksym; > > -struct rq__old { > +struct rq___old { > raw_spinlock_t lock; > } __attribute__((preserve_access_index)); > > -struct rq__new { > +struct rq___new { > raw_spinlock_t __lock; > } __attribute__((preserve_access_index)); > > @@ -434,8 +436,8 @@ int BPF_PROG(collect_lock_syms) > > 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; > + struct rq___new *rq_new =3D (void *)rq; > + struct rq___old *rq_old =3D (void *)rq; > > if (rq =3D=3D NULL) > break; > -- > 2.40.1 >