From patchwork Mon Jun 12 11:58:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Masami Hiramatsu (Google)" X-Patchwork-Id: 13276410 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2BAB5C7EE23 for ; Mon, 12 Jun 2023 11:59:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229695AbjFLL7H (ORCPT ); Mon, 12 Jun 2023 07:59:07 -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 ); 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)" To: linux-trace-kernel@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Steven Rostedt , mhiramat@kernel.org, Florent Revest , Mark Rutland , Will Deacon , Mathieu Desnoyers , Martin KaFai Lau , bpf@vger.kernel.org, Bagas Sanjaya , kernel test robot 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 Precedence: bulk List-ID: X-Mailing-List: linux-trace-kernel@vger.kernel.org From: Masami Hiramatsu (Google) 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) Reviewed-by: Steven Rostedt (Google) --- 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); }