Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp917943rdh; Sun, 24 Sep 2023 18:46:14 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFebLqoBCp1KQ0Ui1kxgckYgrj5Kwmfd0lL28YislsiI0J/CEuCc9Mt+CvBLjcI351GZqIx X-Received: by 2002:a25:ce12:0:b0:d4c:6b49:fed7 with SMTP id x18-20020a25ce12000000b00d4c6b49fed7mr4859302ybe.45.1695606374091; Sun, 24 Sep 2023 18:46:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695606374; cv=none; d=google.com; s=arc-20160816; b=wtj2dBuvlHUuZlX6zpxSuKADyK2xTBi7ymZQO14OdeiO5uRzCGGvh55DnMjnppxiRs ewNBkDQZ1MRAidrzj8s3clUH4CUW7C7Ir7onAYehmBoVpwAwmDUDLZ8GXKcG42aMu+hA UhDatOwogYm0RsOXMgn1rdNyTWuvi/+vEp0eD99Mw6m5/KZr7WZe74iFk1xZiWR3ekWQ E6yd14F0MIFNqfREIWZeNOgh18ChC2UXP2lUJYctJZ7/7KrTH2epHF3aczUS3otlhHWn R68kRiciYWyi8+xBLONZbc7x3Locv+EinSBas8HZhdaCoqTuk4E1WZ1mJ4oGFfUmCXCT REZQ== 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=sFnymHRtoiSLSE6xlXlPfUo1MSdkdwnizEDkqFjEp5M=; fh=vXy/zKLYS8CIT5S93PT42H9kmQ6ohgipR/F8r41ABBw=; b=E6nY299944DfNFiXstBsiARYl+vdprmc9Wh/pK6/rxhdAcJqBVU38oPryfZ/N+L9b5 PRuTDk9OIvRrJ4e/f/32M1Y7FbhCrxGx1V2M/0Geg6xaASLwbItI/p6EidxyTF2nlbhB eRiTvt2TFU1kzGXGzYQBe2l3yR5Hhb/cFW6XLWZgDH+yWqUUEpVMirhfwglQQteN6msk JQolhnxKiD7eh9zsz4AM6NVEJtII54HLRg83R0LxZsupEgCz8NhcSnVq/kyPKQwFx1TN /I1vy7EJ5pgSpxYkwrUS98Bnz1imYtX508C+2hwQxs2X50/McsnyWxcroQDanvqpi1jM Dppw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=0N12PufI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id bz16-20020a056a02061000b00578bb93aa4fsi10723962pgb.730.2023.09.24.18.46.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Sep 2023 18:46:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=0N12PufI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 49347819AD8A; Sun, 24 Sep 2023 11:03:43 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230220AbjIXSDm (ORCPT + 99 others); Sun, 24 Sep 2023 14:03:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47492 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229437AbjIXSDl (ORCPT ); Sun, 24 Sep 2023 14:03:41 -0400 Received: from mail-qt1-x834.google.com (mail-qt1-x834.google.com [IPv6:2607:f8b0:4864:20::834]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4E760FC for ; Sun, 24 Sep 2023 11:03:34 -0700 (PDT) Received: by mail-qt1-x834.google.com with SMTP id d75a77b69052e-41513d2cca7so316651cf.0 for ; Sun, 24 Sep 2023 11:03:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1695578613; x=1696183413; darn=vger.kernel.org; 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=sFnymHRtoiSLSE6xlXlPfUo1MSdkdwnizEDkqFjEp5M=; b=0N12PufIVMADzpR5JvZrVR1zBlw3XeOS0LiFKjxachJfNLZIhXtRQzCDpapBxqeN/N KOc1wyj3fz/Ng9libyDmqF6fKVTpgF0ldnPHb18GIKQM16jZZNFrlfv3OeSGIOETR1z9 z92OZJSBn9IweU/o5n5BizcPtqgTRoFKwvVaRp7S1Bt2dDx4rjb9wijBUs8QF0E6IILx F138fTwNd1RBoe8crEm1bo7VibmUQmvqR4u+WTZwDdCNgQ6UW2KOVJqpR0Z8CvqBbWWw gFyjKrPTbPDIdHj9cBQ7wvqW3ADh+w10ULYMN3MDx3EAo0ciOjqkkUQtHO62iCSSSgOn Vaqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695578613; x=1696183413; 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=sFnymHRtoiSLSE6xlXlPfUo1MSdkdwnizEDkqFjEp5M=; b=CsL8bLggbOo84IyjnSejR+eAeehviTPdK8mHjn3qRREMn4PiacMPlkLFtTkuqASq81 HY3wf8LqAJu5WtYPW+mSCuybLNqyX1zvF6WrqwHndq+OroD+gPW6sq974eH7FIqiK+Dy D7I4lpmsy5qPbqY3N1d3d0+9ktJa7vJCuK/s+pQMEhLcxQnWFLEN53z85QMsCcVown/P NbgflyMXM7QWhkxtOdPUiPfx3RkQclPjhVx6uC+di8Uq+NYFxl5iuDTib9XUmT3jvDLn 8rZK+IWTHakXCo56iTFnPTHQWSmkIJH9gJW6FQbWwCak2kBuTpvqNZJethuWzv+lpeXm 5QqQ== X-Gm-Message-State: AOJu0YzuorKKM+WEMogCxA4HVqDYnRliwiG+TKgoBN+A5NaYD1jWKlmx YjtSsiiUXNVuaT/V3eMeuhIibNKnPRXlgOnPPsuimg== X-Received: by 2002:a05:622a:111:b0:3f0:af20:1a37 with SMTP id u17-20020a05622a011100b003f0af201a37mr308189qtw.15.1695578613246; Sun, 24 Sep 2023 11:03:33 -0700 (PDT) MIME-Version: 1.0 References: <20230922234444.3115821-1-namhyung@kernel.org> In-Reply-To: <20230922234444.3115821-1-namhyung@kernel.org> From: Ian Rogers Date: Sun, 24 Sep 2023 11:03:20 -0700 Message-ID: Subject: Re: [PATCH] perf record: Fix BTF type checks in the off-cpu profiling To: Namhyung Kim Cc: Arnaldo Carvalho de Melo , Jiri Olsa , Adrian Hunter , Peter Zijlstra , Ingo Molnar , LKML , linux-perf-users@vger.kernel.org, Song Liu , Hao Luo , bpf@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Sun, 24 Sep 2023 11:03:43 -0700 (PDT) On Fri, Sep 22, 2023 at 4:44=E2=80=AFPM Namhyung Kim = wrote: > > The BTF func proto for a tracepoint has one more argument than the > actual tracepoint function since it has a context argument at the > begining. So it should compare to 5 when the tracepoint has 4 > arguments. > > typedef void (*btf_trace_sched_switch)(void *, bool, struct task_struct= *, struct task_struct *, unsigned int); > > Also, recent change in the perf tool would use a hand-written minimal > vmlinux.h to generate BTF in the skeleton. So it won't have the info > of the tracepoint. Anyway it should use the kernel's vmlinux BTF to > check the type in the kernel. > > Fixes: b36888f71c85 ("perf record: Handle argument change in sched_switch= ") > Cc: Song Liu > Cc: Hao Luo > CC: bpf@vger.kernel.org > Signed-off-by: Namhyung Kim Reviewed-by: Ian Rogers > --- > tools/perf/util/bpf_off_cpu.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/tools/perf/util/bpf_off_cpu.c b/tools/perf/util/bpf_off_cpu.= c > index 01f70b8e705a..21f4d9ba023d 100644 > --- a/tools/perf/util/bpf_off_cpu.c > +++ b/tools/perf/util/bpf_off_cpu.c > @@ -98,7 +98,7 @@ static void off_cpu_finish(void *arg __maybe_unused) > /* v5.18 kernel added prev_state arg, so it needs to check the signature= */ > static void check_sched_switch_args(void) > { > - const struct btf *btf =3D bpf_object__btf(skel->obj); > + const struct btf *btf =3D btf__load_vmlinux_btf(); > const struct btf_type *t1, *t2, *t3; > u32 type_id; > > @@ -116,7 +116,8 @@ static void check_sched_switch_args(void) > return; > > t3 =3D btf__type_by_id(btf, t2->type); > - if (t3 && btf_is_func_proto(t3) && btf_vlen(t3) =3D=3D 4) { > + /* btf_trace func proto has one more argument for the context */ > + if (t3 && btf_is_func_proto(t3) && btf_vlen(t3) =3D=3D 5) { > /* new format: pass prev_state as 4th arg */ nit: does this comment need updating? > skel->rodata->has_prev_state =3D true; > } > -- > 2.42.0.515.g380fc7ccd1-goog >