Message ID | 168657113778.3038017.12245893750241701312.stgit@mhiramat.roam.corp.google.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp2546178vqr; Mon, 12 Jun 2023 05:22:07 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7DqmLnGk9SC9ZWcjghG3ZwzIc3d2HwW8iawi4Qb3go3Ro683ucUQe2wKOb/Ysbs/lREpkp X-Received: by 2002:a17:90a:ab81:b0:256:845f:333a with SMTP id n1-20020a17090aab8100b00256845f333amr8840187pjq.19.1686572527037; Mon, 12 Jun 2023 05:22:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686572527; cv=none; d=google.com; s=arc-20160816; b=fGxyCgspBNQI0xXIau2g1khA8QtI3FXxfv+pwwUsFdTNO6g9APms9vF17hUsJ7lUdW BbApO+XEhbvw7YtQLqtQ/XtSV1BKp1z2xFk5E1W55sDTWQDWCwWIQpRPxw/7FRVelz82 Hchgqwj+hR9pR3zn8Jp12CydvCSOsu1vGP9a1dWKuGGRHIXKvErrB2dBKZcN2E4Oar1Q h6IU+J+uGPay3OoQnvPlHpnv+NNfY5iUOUzpGH43Wy7vh6od96empPFqD1NjNnqCU5vf iZ+BxDL+rjSeR+WnqPFjZ+lx1q5BrJqScyX4Zgh6npI2hi+x8vKWvKHTnga07dOvKIm8 fhsw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:message-id:date:subject:cc:to:from:dkim-signature; bh=1120lWzNsX6AS1kuTRF6AylTZYOIN37+vPiD3J/9rEc=; b=RXgiBFvMXLHMRi2uRL1APoGwKH4SjTT0434wgHkjjtOAtBLz96zqPCQASAX28AgMK5 6raBFpFILLpURLULdVhz7XwSl1JTsp4crMrco4GkhlrO9lMhg4bCNlm052R120tzpW01 T6kuRf6J6ktQ4otG11hbbRkFle99aOTrRNK0roHZsRqZSN32xiODqwnu5ezHfWfP8Zjn VqL/KnJ5cRCs7t2X3Ic6CSAOHwWYREndGAkjm+w9/aKL2smsvH0vKYhQm3zSjL55Tolp bhQI8z1PfqErMZiIqJndefB+GaJvTnSt7WkRqmqm1tIF9aCGU5Ga5rJY0fqv0sPOausL AN2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ujN530MQ; 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=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 29-20020a17090a035d00b002593aab997esi8574583pjf.91.2023.06.12.05.21.54; Mon, 12 Jun 2023 05:22:07 -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=@kernel.org header.s=k20201202 header.b=ujN530MQ; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229823AbjFLL7I (ORCPT <rfc822;rust.linux@gmail.com> + 99 others); Mon, 12 Jun 2023 07:59:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42548 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229454AbjFLL7G (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 12 Jun 2023 07:59:06 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D91B1A1; Mon, 12 Jun 2023 04:59:02 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 74D00615E6; Mon, 12 Jun 2023 11:59:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 02AC4C433EF; Mon, 12 Jun 2023 11:58:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686571141; bh=nyqDX+87HZc8e3DFhKVw9S8HR74VWyXjorE0FFDF0vc=; h=From:To:Cc:Subject:Date:From; b=ujN530MQXGeKb/DiyJ4NQESC5sMVOZ5+fr9SQw21q127rlbpFlDsxzxws0H+1xPhc 1wuAohCVh+URymvlAN0jUKAavNyaGpBj2ziVmnP7sR2K7hSIWo1cKzTX04ZnN78Vum 6R6QwpCkxN6K0PBVScZIWqsV8xfFGWmkMemunuwOY32YUv8p7N3zzL5N1OizlRmtCT WOxXV83CQGLGdAgOLGznpRki6dvwwpan9Y7MGs2u+xZSZv8OfxoVvmiJSbQMNVHTLW l9nj3yzrBXvkTIagLyfRkoTS7Ik8RRiJqxXZSsVueMoEwKCGFn4Y7IsbNsFGk31Ycb cnROUJR0AleBQ== From: "Masami Hiramatsu (Google)" <mhiramat@kernel.org> To: linux-trace-kernel@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Steven Rostedt <rostedt@goodmis.org>, mhiramat@kernel.org, Florent Revest <revest@chromium.org>, Mark Rutland <mark.rutland@arm.com>, Will Deacon <will@kernel.org>, Mathieu Desnoyers <mathieu.desnoyers@efficios.com>, Martin KaFai Lau <martin.lau@linux.dev>, bpf@vger.kernel.org, Bagas Sanjaya <bagasdotme@gmail.com>, kernel test robot <lkp@intel.com> Subject: [PATCH] tracing/probes: Fix tracepoint event with $arg* to fetch correct argument Date: Mon, 12 Jun 2023 20:58:57 +0900 Message-ID: <168657113778.3038017.12245893750241701312.stgit@mhiramat.roam.corp.google.com> X-Mailer: git-send-email 2.41.0.162.gfafddb0af9-goog User-Agent: StGit/0.19 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768499473939374981?= X-GMAIL-MSGID: =?utf-8?q?1768499473939374981?= |
Series |
tracing/probes: Fix tracepoint event with $arg* to fetch correct argument
|
|
Commit Message
Masami Hiramatsu (Google)
June 12, 2023, 11:58 a.m. UTC
From: Masami Hiramatsu (Google) <mhiramat@kernel.org> To hide the first dummy 'data' argument on the tracepoint probe events, the BTF argument array was modified (skip the first argument for tracepoint), but the '$arg*' meta argument parser missed that. Fix to increment the argument index if it is tracepoint probe. And decrement the index when searching the type of the argument. Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org> --- kernel/trace/trace_probe.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
Comments
On 6/12/23 04:58, Masami Hiramatsu (Google) wrote: > From: Masami Hiramatsu (Google) <mhiramat@kernel.org> > > To hide the first dummy 'data' argument on the tracepoint probe events, > the BTF argument array was modified (skip the first argument for tracepoint), > but the '$arg*' meta argument parser missed that. > > Fix to increment the argument index if it is tracepoint probe. And decrement > the index when searching the type of the argument. > > Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org> > --- > kernel/trace/trace_probe.c | 10 ++++++++-- > 1 file changed, 8 insertions(+), 2 deletions(-) > > diff --git a/kernel/trace/trace_probe.c b/kernel/trace/trace_probe.c > index 473e1c43bc57..643aa3a51d5a 100644 > --- a/kernel/trace/trace_probe.c > +++ b/kernel/trace/trace_probe.c > @@ -456,7 +456,10 @@ static int parse_btf_arg(const char *varname, struct fetch_insn *code, > > if (name && !strcmp(name, varname)) { > code->op = FETCH_OP_ARG; > - code->param = i; > + if (ctx->flags & TPARG_FL_TPOINT) > + code->param = i + 1; > + else > + code->param = i; > return 0; > } > } > @@ -470,8 +473,11 @@ static const struct fetch_type *parse_btf_arg_type(int arg_idx, > struct btf *btf = traceprobe_get_btf(); > const char *typestr = NULL; > > - if (btf && ctx->params) > + if (btf && ctx->params) { > + if (ctx->flags & TPARG_FL_TPOINT) > + arg_idx--; > typestr = type_from_btf_id(btf, ctx->params[arg_idx].type); > + } > > return find_fetch_type(typestr, ctx->flags); > } > > I failed to apply this patch. Would you mind to rebase this patch?
On Mon, 12 Jun 2023 20:58:57 +0900 "Masami Hiramatsu (Google)" <mhiramat@kernel.org> wrote: > From: Masami Hiramatsu (Google) <mhiramat@kernel.org> > > To hide the first dummy 'data' argument on the tracepoint probe events, > the BTF argument array was modified (skip the first argument for tracepoint), > but the '$arg*' meta argument parser missed that. > > Fix to increment the argument index if it is tracepoint probe. And decrement > the index when searching the type of the argument. I'm curious. What if we want a variable that points to that data argument? ;-) Probably just add a new type I guess. Anyway, Reviewed-by: Steven Rostedt (Google) <rostedt@goodmis.org> -- Steve > > Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org> > --- > kernel/trace/trace_probe.c | 10 ++++++++-- > 1 file changed, 8 insertions(+), 2 deletions(-) > > diff --git a/kernel/trace/trace_probe.c b/kernel/trace/trace_probe.c > index 473e1c43bc57..643aa3a51d5a 100644 > --- a/kernel/trace/trace_probe.c > +++ b/kernel/trace/trace_probe.c > @@ -456,7 +456,10 @@ static int parse_btf_arg(const char *varname, struct fetch_insn *code, > > if (name && !strcmp(name, varname)) { > code->op = FETCH_OP_ARG; > - code->param = i; > + if (ctx->flags & TPARG_FL_TPOINT) > + code->param = i + 1; > + else > + code->param = i; > return 0; > } > } > @@ -470,8 +473,11 @@ static const struct fetch_type *parse_btf_arg_type(int arg_idx, > struct btf *btf = traceprobe_get_btf(); > const char *typestr = NULL; > > - if (btf && ctx->params) > + if (btf && ctx->params) { > + if (ctx->flags & TPARG_FL_TPOINT) > + arg_idx--; > typestr = type_from_btf_id(btf, ctx->params[arg_idx].type); > + } > > return find_fetch_type(typestr, ctx->flags); > }
On Wed, 14 Jun 2023 12:50:34 -0700 Kui-Feng Lee <sinquersw@gmail.com> wrote: > > > On 6/12/23 04:58, Masami Hiramatsu (Google) wrote: > > From: Masami Hiramatsu (Google) <mhiramat@kernel.org> > > > > To hide the first dummy 'data' argument on the tracepoint probe events, > > the BTF argument array was modified (skip the first argument for tracepoint), > > but the '$arg*' meta argument parser missed that. > > > > Fix to increment the argument index if it is tracepoint probe. And decrement > > the index when searching the type of the argument. > > > > Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org> > > --- > > kernel/trace/trace_probe.c | 10 ++++++++-- > > 1 file changed, 8 insertions(+), 2 deletions(-) > > > > diff --git a/kernel/trace/trace_probe.c b/kernel/trace/trace_probe.c > > index 473e1c43bc57..643aa3a51d5a 100644 > > --- a/kernel/trace/trace_probe.c > > +++ b/kernel/trace/trace_probe.c > > @@ -456,7 +456,10 @@ static int parse_btf_arg(const char *varname, struct fetch_insn *code, > > > > if (name && !strcmp(name, varname)) { > > code->op = FETCH_OP_ARG; > > - code->param = i; > > + if (ctx->flags & TPARG_FL_TPOINT) > > + code->param = i + 1; > > + else > > + code->param = i; > > return 0; > > } > > } > > @@ -470,8 +473,11 @@ static const struct fetch_type *parse_btf_arg_type(int arg_idx, > > struct btf *btf = traceprobe_get_btf(); > > const char *typestr = NULL; > > > > - if (btf && ctx->params) > > + if (btf && ctx->params) { > > + if (ctx->flags & TPARG_FL_TPOINT) > > + arg_idx--; > > typestr = type_from_btf_id(btf, ctx->params[arg_idx].type); > > + } > > > > return find_fetch_type(typestr, ctx->flags); > > } > > > > > > I failed to apply this patch. > Would you mind to rebase this patch? Ah, this is against for the probes/for-next branch on git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace.git Thanks, >
On Wed, 21 Jun 2023 19:03:37 -0400 Steven Rostedt <rostedt@goodmis.org> wrote: > On Mon, 12 Jun 2023 20:58:57 +0900 > "Masami Hiramatsu (Google)" <mhiramat@kernel.org> wrote: > > > From: Masami Hiramatsu (Google) <mhiramat@kernel.org> > > > > To hide the first dummy 'data' argument on the tracepoint probe events, > > the BTF argument array was modified (skip the first argument for tracepoint), > > but the '$arg*' meta argument parser missed that. > > > > Fix to increment the argument index if it is tracepoint probe. And decrement > > the index when searching the type of the argument. > > I'm curious. What if we want a variable that points to that data argument? ;-) That is a dummy parameter which is passed when registering the callback, so it is passed from trace_fprobe.c. Currently trace_fprobe.c passed NULL to the data argument. > > Probably just add a new type I guess. Yeah, if we get any idea to use it, it will be accessed by a new $-variable. > > Anyway, > > Reviewed-by: Steven Rostedt (Google) <rostedt@goodmis.org> Thank you! > > -- Steve > > > > > Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org> > > --- > > kernel/trace/trace_probe.c | 10 ++++++++-- > > 1 file changed, 8 insertions(+), 2 deletions(-) > > > > diff --git a/kernel/trace/trace_probe.c b/kernel/trace/trace_probe.c > > index 473e1c43bc57..643aa3a51d5a 100644 > > --- a/kernel/trace/trace_probe.c > > +++ b/kernel/trace/trace_probe.c > > @@ -456,7 +456,10 @@ static int parse_btf_arg(const char *varname, struct fetch_insn *code, > > > > if (name && !strcmp(name, varname)) { > > code->op = FETCH_OP_ARG; > > - code->param = i; > > + if (ctx->flags & TPARG_FL_TPOINT) > > + code->param = i + 1; > > + else > > + code->param = i; > > return 0; > > } > > } > > @@ -470,8 +473,11 @@ static const struct fetch_type *parse_btf_arg_type(int arg_idx, > > struct btf *btf = traceprobe_get_btf(); > > const char *typestr = NULL; > > > > - if (btf && ctx->params) > > + if (btf && ctx->params) { > > + if (ctx->flags & TPARG_FL_TPOINT) > > + arg_idx--; > > typestr = type_from_btf_id(btf, ctx->params[arg_idx].type); > > + } > > > > return find_fetch_type(typestr, ctx->flags); > > } >
diff --git a/kernel/trace/trace_probe.c b/kernel/trace/trace_probe.c index 473e1c43bc57..643aa3a51d5a 100644 --- a/kernel/trace/trace_probe.c +++ b/kernel/trace/trace_probe.c @@ -456,7 +456,10 @@ static int parse_btf_arg(const char *varname, struct fetch_insn *code, if (name && !strcmp(name, varname)) { code->op = FETCH_OP_ARG; - code->param = i; + if (ctx->flags & TPARG_FL_TPOINT) + code->param = i + 1; + else + code->param = i; return 0; } } @@ -470,8 +473,11 @@ static const struct fetch_type *parse_btf_arg_type(int arg_idx, struct btf *btf = traceprobe_get_btf(); const char *typestr = NULL; - if (btf && ctx->params) + if (btf && ctx->params) { + if (ctx->flags & TPARG_FL_TPOINT) + arg_idx--; typestr = type_from_btf_id(btf, ctx->params[arg_idx].type); + } return find_fetch_type(typestr, ctx->flags); }