Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp2347518rdh; Tue, 26 Sep 2023 22:53:53 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF6JZ9USFNPOED5ix+YJzUMQnmo8FzlT6uL6xd9z30xNIoVf2QRmpeuv1cUwgbTIMtK1z7I X-Received: by 2002:a67:eb01:0:b0:452:58a1:112 with SMTP id a1-20020a67eb01000000b0045258a10112mr1125428vso.3.1695794033016; Tue, 26 Sep 2023 22:53:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695794032; cv=none; d=google.com; s=arc-20160816; b=AwnNgO6VVBCQcV4RZoFsfbdrfZsAPuOI+hUYLyKyYp6H8FJh0wr9iAeVqu9AihvBV2 Y0/E8v1+ay7r58Z1cM9k1jR7yGFEKfEmL8qypr7U791X/K/egTvWp21lusdiPh1A1bSy pzd1dq0iunfQ9jjvXE7YLxK1XKyxbR7I+BGv4YLEilvwiT6YWOz+RcWsAUJtHsCsKYpy Z3200tqUDjdQ06PGfzb9hu8YXiWihWCCCr0m3RavhAa6v28E+anhYf8oEu2+GaZfXO/g Yy8i9U7flNZA492VqHTlD+hK7cB+NVsB4ibksc+uSTAO+MX/Sn5WOsrSYc+xvbbWiWfZ +pgQ== 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; bh=cOxASzxJL1VxODl7Dqpqf1YK1AMl6T/G5/C5L5fqSEo=; fh=MpjG9Wiybpn9JgJQqZwq0UVa0bUF9Z0uS2xe0LfPMSA=; b=BOLZrDzCfVl2E2wW76+dVVxBf/q5dd5I1kelLAEKE1yjzX1MGXtisGUta+muUw10yN OgOHZ8Lt1hmIAc3D1s5KsIvobmlouK0SsCN2zwDdb3H1MPLAmgP/9HsZ6AJnTAWRi35L h/f48cw860Tb+VNhx1g7u4liYb486mgA7B64R4pZisi2n7SQyMJWTQlgb8B5yd2M23hT u36oadMrqr3WpxZKT9Vmj0nHBVSOgp5f5j4I/dJbfDauB5NxoxZnGzFyVAFA6SQAtRlq hH5sIRdq2rTCOAbFPbuAq8jZ4Sq6c50pPx9RJ/94KdlwQal8Sg8n2dvF4JxjgLTgSPOu seUQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id bz14-20020a056a02060e00b00578b6e32b60si17085514pgb.126.2023.09.26.22.53.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Sep 2023 22:53:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 544F1801BB57; Tue, 26 Sep 2023 22:42:47 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229525AbjI0Fmc convert rfc822-to-8bit (ORCPT + 99 others); Wed, 27 Sep 2023 01:42:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36358 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229527AbjI0Flu (ORCPT ); Wed, 27 Sep 2023 01:41:50 -0400 Received: from mail-io1-f53.google.com (mail-io1-f53.google.com [209.85.166.53]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 658D13C21; Tue, 26 Sep 2023 17:50:41 -0700 (PDT) Received: by mail-io1-f53.google.com with SMTP id ca18e2360f4ac-79f989480e0so314028139f.3; Tue, 26 Sep 2023 17:50:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695775840; x=1696380640; 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=49VLLRdtyvTR9zrUZJfnDfe9+Yw6E25El1lehQytcPs=; b=mM77ZXb39cItcCMSR6Vg7Yska+rnHCXT8ffib6LbemqdyTUEFR96NbIhNjAjJSoD0f nMmnxjz0uMzD3GL675fYRPekQwRqWaEc8XULgTWV/09XyrDjYOGdZwRCZvNCa4LFBCXY 31b9p3S3eUhpAYaK1Ke+cw6hBCtE+ZzDlQO1bbcjyXgvifmluK0FdV86xE/jXXMO17sT gz5W6cbAi2tOwy9nvgefLIV1Hlt4lZoOc+BHtDzNMRF9/d1c3acNk+xOAMmH5836NLXa VKke8Unq5H6xfyi5JKEHMf6GPx7zTj7o8bT92Yz3IdrZ36KSLz3qoEgkmBkIDfTJ+EUu Hpyg== X-Gm-Message-State: AOJu0YzCI7mC4IfjvxGxd/DTW4vljDoa+o2RFpV7UB7meHTpQdBui3C/ QvZ9fQMPhR/CI5RT38DkcFVNtcUatz1YwA6aMuo= X-Received: by 2002:a6b:6806:0:b0:79f:b6b3:9dde with SMTP id d6-20020a6b6806000000b0079fb6b39ddemr481066ioc.9.1695775840642; Tue, 26 Sep 2023 17:50:40 -0700 (PDT) MIME-Version: 1.0 References: <20230922234444.3115821-1-namhyung@kernel.org> In-Reply-To: From: Namhyung Kim Date: Tue, 26 Sep 2023 17:50:29 -0700 Message-ID: Subject: Re: [PATCH] perf record: Fix BTF type checks in the off-cpu profiling To: Ian Rogers 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: 8BIT X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.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 (lipwig.vger.email [0.0.0.0]); Tue, 26 Sep 2023 22:42:47 -0700 (PDT) Hi Ian, On Sun, Sep 24, 2023 at 11:03 AM Ian Rogers wrote: > > On Fri, Sep 22, 2023 at 4:44 PM 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 Thanks for the review! > > > --- > > 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 = bpf_object__btf(skel->obj); > > + const struct btf *btf = 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 = btf__type_by_id(btf, t2->type); > > - if (t3 && btf_is_func_proto(t3) && btf_vlen(t3) == 4) { > > + /* btf_trace func proto has one more argument for the context */ > > + if (t3 && btf_is_func_proto(t3) && btf_vlen(t3) == 5) { > > /* new format: pass prev_state as 4th arg */ > > nit: does this comment need updating? No, it's the 4th arg and the sched_switch is called like. trace_sched_switch(sched_mode & SM_MASK_PREEMPT, prev, next, prev_state); Thanks, Namhyung