From patchwork Mon Feb 26 03:58:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Masami Hiramatsu (Google)" X-Patchwork-Id: 206237 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp1861027dyb; Sun, 25 Feb 2024 20:16:04 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXxtmQFhoIqw0pjLiiFNLSw8pE48HQhhSJQg28vT2uxvXw8FF1UPIQGTyMx8Fg30M9m6dz9cagLm+d8UNBGo/vQF1SomA== X-Google-Smtp-Source: AGHT+IE2sShzkPvkOENIlCF/OzzzWC9OCRsqA48PKFccR8/cGvCYArkiPHKbUMLUwVlF1+5+ykou X-Received: by 2002:a05:6358:b3c8:b0:17b:583c:c4b7 with SMTP id pb8-20020a056358b3c800b0017b583cc4b7mr8753971rwc.3.1708920964641; Sun, 25 Feb 2024 20:16:04 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708920964; cv=pass; d=google.com; s=arc-20160816; b=yO9oeYpUV93VJQdQ0yxvBag3eXZgpHJGQXhh6q5EqoXWbaJVBRCE2k0r6gOII1R+ZQ ct2EOvJutPpr5f7XKRCsEEb4Aoq/kjKTlL5wTJUVLgKfBDcAG+noZS705H4lbGieMzlx 3gtDAgNjKoOgR1y0m13LFkzKQbaoIU/QJwxyNc3jVbG1wdfkSGJgdMhkhkvoluVRRzbD weJhSEpD0DP4DRSnmuoG4wKu/PVm5oGtc70H50em/nameBWi9gIwTyJcFYlgtAI49PyL JYpkrdJ2XJ6tdOJLXCRHvlIS1zfN93QuQ6CO+GZRS6MHoGhTn8jrZSNbgnabIIlVH11x NQlA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:user-agent:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=QCYWdK2Ldog6bkdmPmbIO9tO0XT3I9dIMwsAQLYx+YM=; fh=+uEoxECwu+GZPXA+yzsV/ZJCsf7WyFzcH+9RxOmv8OU=; b=pcGdTnFdvWR6fDaX/Xj1AMsP66K014TQjU8Dr0B/AJyRvzXIPeCEAHZV2x1VlwO4X+ jG4jrZzoHfVerFo7TBM6YEBDyv//j6B2rBx2A6HOM5diVaTuBQZuWI77rbRUI3nZkp/7 tnNs9HLz0tt4pYTECk4kEIAWEQ0bPeCeylXwDGLuGX4KMxQ1NoIgLSDs8+oYT+f8pjpQ FlfRCSCXI0SiqN21fbL4XB2PkXMM2uq1LMQXufSOCF00QVu/LWg/uSCIEOEiRka/6ghF kdaG6pPC8eLbWJ+9nT4vrAfA9Fbj4BLXBOGCWFjos3CfVJHHAPVaEu2yzuRb9m3YgUR2 98jA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="kUmeRj/h"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-80506-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-80506-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id a8-20020a056a000c8800b006e45b910aa0si3066610pfv.234.2024.02.25.20.16.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Feb 2024 20:16:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-80506-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="kUmeRj/h"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-80506-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-80506-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 93575B232FD for ; Mon, 26 Feb 2024 04:02:58 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2845C1C283; Mon, 26 Feb 2024 03:58:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="kUmeRj/h" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6D51317BB9; Mon, 26 Feb 2024 03:58:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708919908; cv=none; b=IoYkQY0Xo8/mowOZEx/hfYQl6G1xde/56DUiIrRBpiAX3zyrpLDOcmmQV1EFWZd/R4tfwTx95uck1UH+eK2aO2OoksS8vCMJn53SXWf7o2jZP4QSn53uFaVs3naZpP4yib7qaia7/qK1ETrF4ZwPbnz4NAz4LlJYF3z2SliEpW8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708919908; c=relaxed/simple; bh=63h5hWEAUrjyKuKg98EUt1dzdDxGAgC9zxmqReDr5CI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=PHH90OxDFKTfmsRCf6wESONIDM8nyuwDF9fo1JHMNeCzsDysZ0BSLB2ie5+OCWaFVTV3QCTgj2TgqtHU13Id4YtLawRcFe47q9dg1YVLF+6fkU/BDkOVDGu8vq72bZCL/rxAgQO5P9EDUOSqedGo1TjI33CtaIXn+4luYMwKmwM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=kUmeRj/h; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 349ACC433C7; Mon, 26 Feb 2024 03:58:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708919908; bh=63h5hWEAUrjyKuKg98EUt1dzdDxGAgC9zxmqReDr5CI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kUmeRj/hqT4T0rF6Y5RcGUyKDDCPS16On2WXkCBYFQahY/43lqhh4GdUjBUr/xWcm J27zl9kdvNf0yLQLGdKbPF0/UeXU/5SQqznnQe8RtooBWd8lAYEpsuV2D4wfvrAlaA wqs4o3VGIsCVyngquuhGs7ExqRQiyABs8TLHkA0Zu2HmV8quIPrDDMs7bekBhyBXBF Evobr/V9WU1PENUojeeiX69rNHihidbdHKgh09riXFt64+vQPIOAOzCQJtPCRWgNyn szhgx6d31Mjlb5bTA+1Zc/uIzGNgq8afWKjBZScRnmi9PxRqOk8jgMG8Daz2+bzTtD 4cHCDpyWvXmUw== From: "Masami Hiramatsu (Google)" To: Steven Rostedt , Jiri Olsa Cc: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, mhiramat@kernel.org, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: [PATCH v2 3/7] tracing/probes: cleanup: Set trace_probe::nr_args at trace_probe_init Date: Mon, 26 Feb 2024 12:58:23 +0900 Message-Id: <170891990355.609861.2805086066595778818.stgit@devnote2> X-Mailer: git-send-email 2.34.1 In-Reply-To: <170891987362.609861.6767830614537418260.stgit@devnote2> References: <170891987362.609861.6767830614537418260.stgit@devnote2> User-Agent: StGit/0.19 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791933509158067686 X-GMAIL-MSGID: 1791933509158067686 From: Masami Hiramatsu (Google) Instead of incrementing the trace_probe::nr_args, init it at trace_probe_init(). This is a cleanup, so the behavior is not changed. Signed-off-by: Masami Hiramatsu (Google) Reviewed-by: Steven Rostedt (Google) --- kernel/trace/trace_eprobe.c | 2 +- kernel/trace/trace_probe.c | 10 ++++++---- kernel/trace/trace_probe.h | 2 +- kernel/trace/trace_uprobe.c | 2 +- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/kernel/trace/trace_eprobe.c b/kernel/trace/trace_eprobe.c index 03c851f57969..eb72def7410f 100644 --- a/kernel/trace/trace_eprobe.c +++ b/kernel/trace/trace_eprobe.c @@ -220,7 +220,7 @@ static struct trace_eprobe *alloc_event_probe(const char *group, if (!ep->event_system) goto error; - ret = trace_probe_init(&ep->tp, this_event, group, false); + ret = trace_probe_init(&ep->tp, this_event, group, false, nargs); if (ret < 0) goto error; diff --git a/kernel/trace/trace_probe.c b/kernel/trace/trace_probe.c index 67a0b9cbb648..93f36f8a108e 100644 --- a/kernel/trace/trace_probe.c +++ b/kernel/trace/trace_probe.c @@ -1423,9 +1423,6 @@ int traceprobe_parse_probe_arg(struct trace_probe *tp, int i, const char *arg, struct probe_arg *parg = &tp->args[i]; const char *body; - /* Increment count for freeing args in error case */ - tp->nr_args++; - body = strchr(arg, '='); if (body) { if (body - arg > MAX_ARG_NAME_LEN) { @@ -1810,7 +1807,7 @@ void trace_probe_cleanup(struct trace_probe *tp) } int trace_probe_init(struct trace_probe *tp, const char *event, - const char *group, bool alloc_filter) + const char *group, bool alloc_filter, int nargs) { struct trace_event_call *call; size_t size = sizeof(struct trace_probe_event); @@ -1846,6 +1843,11 @@ int trace_probe_init(struct trace_probe *tp, const char *event, goto error; } + tp->nr_args = nargs; + /* Make sure pointers in args[] are NULL */ + if (nargs) + memset(tp->args, 0, sizeof(tp->args[0]) * nargs); + return 0; error: diff --git a/kernel/trace/trace_probe.h b/kernel/trace/trace_probe.h index c1877d018269..ed8d1052f8a7 100644 --- a/kernel/trace/trace_probe.h +++ b/kernel/trace/trace_probe.h @@ -338,7 +338,7 @@ static inline bool trace_probe_has_single_file(struct trace_probe *tp) } int trace_probe_init(struct trace_probe *tp, const char *event, - const char *group, bool alloc_filter); + const char *group, bool alloc_filter, int nargs); void trace_probe_cleanup(struct trace_probe *tp); int trace_probe_append(struct trace_probe *tp, struct trace_probe *to); void trace_probe_unlink(struct trace_probe *tp); diff --git a/kernel/trace/trace_uprobe.c b/kernel/trace/trace_uprobe.c index a84b85d8aac1..796ebcae9b38 100644 --- a/kernel/trace/trace_uprobe.c +++ b/kernel/trace/trace_uprobe.c @@ -337,7 +337,7 @@ alloc_trace_uprobe(const char *group, const char *event, int nargs, bool is_ret) if (!tu) return ERR_PTR(-ENOMEM); - ret = trace_probe_init(&tu->tp, event, group, true); + ret = trace_probe_init(&tu->tp, event, group, true, nargs); if (ret < 0) goto error;