From patchwork Wed Feb 14 13:22:50 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: 200957 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:bc8a:b0:106:860b:bbdd with SMTP id dn10csp1207964dyb; Wed, 14 Feb 2024 05:23:52 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUgbYDZ2uaUfI7Fqvl/wztHr3l0eALHZnSq742HamjtPAuKE+4iXy4h013UXWAPnCDCYBHRBsgKEsPOnW1q+jS7gmGwrw== X-Google-Smtp-Source: AGHT+IHf25Lf/1pnQgiXkJOXqrc6GThEGceHd0fr1BX9Hp+1ho2mrTdR46TafwguxtWWbpxRUVvh X-Received: by 2002:a05:6808:2124:b0:3c1:33fb:74c2 with SMTP id r36-20020a056808212400b003c133fb74c2mr300749oiw.1.1707917032647; Wed, 14 Feb 2024 05:23:52 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707917032; cv=pass; d=google.com; s=arc-20160816; b=YhE0V3FqTge+BRruXWW4jFNVs3JvGk4IQo6A6ylgLY58ddRNCrfVePmNQ3WRi/XWn6 vR3q36ydZ0KuO/F8c2Ix0XHilc/9mlVO3JvoCFqvappRYfvhju07hjJXEog0JvtyN14z VPr9fPalH67+PQAr24VzzlTkUsA6zijopiA3ufYM2ayC9CGBjLz4HPmrsiRbwg+UaSVH a1oc3SWtitNwocixFXUvQuiNCSu2T1WRPU0UhHEtWHzVDeWbH9GvC43+vxZf01e1xK8a bYdQY0wUvR+xyI9sSxf6i7d497w7V6n/YO4RWoFY7rX4E6ll/DYQRP4m1rzXxQ7anC5R Lz/g== 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=Cs6YlQCCA0/38ByWp/cs4od9UH+v6bg2xXqWAn/SCc8=; fh=7k2vqjmxRK2v9e/vBa/x7PuuCDiNhK4sbdlxZtwkxEQ=; b=PlPHHJh8KzI8xQMiTYYoHLclMAVb86xAyRBjzRvJwxgb6sfqn1Y8ssiHP3pmOGM7yO z+07Z3EINYKTI+YJg1C/uDphEXMh0aPiK+oDLwvu0PN21hSkF42aQpey+TjPtOImWoYM ae1d2nc2fuDwvZDnIgGP+wxbB7kmMxX5Ayy4KExtVOd7JNmpVHlr5xlOZYgtdKR3c+UA RSMWpdVu5TBNA6HEEAwFqZLZ9MwlycU+AR/JAz1uztbYnyaXJdjgG6esmrS5U2ICXTEv A3efFCZzuF6SefZ8PhWyjWL2ylmbuByj0ks+8rTC0XOM27CbUHGembpzF7oYb8fHDKf/ a17g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ij33RRTp; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-65271-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-65271-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=2; AJvYcCVlbpSg9K8ASt1PK5eab79uiQ4XqctHcr8VZtn8vZcoeUEJCq9To8b+cKlunOA+5AZbXuQ6g24TgA22xM+yEEGh1AvIag== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id gw15-20020a0562140f0f00b0068ef74690d5si1137874qvb.9.2024.02.14.05.23.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 05:23:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-65271-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ij33RRTp; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-65271-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-65271-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 4AA711C2252F for ; Wed, 14 Feb 2024 13:23:52 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AD78054BF5; Wed, 14 Feb 2024 13:22:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ij33RRTp" 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 2E3F455C04; Wed, 14 Feb 2024 13:22:53 +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=1707916974; cv=none; b=NCCq7/W7ghNa/BUnidmE7qdfh5uZqOwg88t9vdLg+YY60+k0UJFZOMUZJUUSw/CnDQKUpEy81Nq1wiEmjFf+UMBMzEyld/uQQ657RW1ViDt81Qa/YuhIr83IvHTINuj5rymAex3LyYCNqrVK6VGdw34zzu8qmxd0lrTbd5fiUFM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707916974; c=relaxed/simple; bh=KMkNYqwUm/DKFq2MqbwKymJ8CYTI6sIrbCfL1CVMecY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=ic8nfIe32pcvcgCHD8KSytuz0Ry9zl9Ffa2quSHNnlW8Azn/4vao9ArIeSzhbd+SdvKEwL63ekby7goXBpJPTj/Gu1e8yiOmR84EkyBzg/JnLkbY7N07BRajoTaPZrD+27KUJKvaH6RE8OQsq4dIaujyYGeb5A1b+HYJT4rD4tk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ij33RRTp; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 81625C433C7; Wed, 14 Feb 2024 13:22:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707916973; bh=KMkNYqwUm/DKFq2MqbwKymJ8CYTI6sIrbCfL1CVMecY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ij33RRTpQRk1InLaUJOruddEz2SgNCMcLWYimJeeBYOhIBydytZ66tmuLrgTEs6nV 7mxJ+iuuy7WSr6Fp9/0QWbL7nNhoMmUpuADkllhaB9D52OQ5fbUxOZcRWwvfpUDQef xtiHMFJ0v8Zc1Nu1G+CVFoR/CLOvS25JRsdYa2BEU+HjqJr9rDE+j39fc5IfyXlok9 PZNZycfNbqNbvWJEjBsdNEAupcPSTDCgUlWgAsyHOUYrThn+hF/a1mqJvHXWNJ0H5N 2vlvTknOjURgzNEpB9+P13bnVQvfD1YdHaVFJ70fxZI6qk/Lug6jy2IZFIArjnVlGy 6YT6942OE855A== From: "Masami Hiramatsu (Google)" To: linux-trace-kernel@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Steven Rostedt , mhiramat@kernel.org Subject: [PATCH RFC 4/5] tracing/probes: cleanup: Set trace_probe::nr_args at trace_probe_init Date: Wed, 14 Feb 2024 22:22:50 +0900 Message-Id: <170791697034.389532.9872760768297831357.stgit@devnote2> X-Mailer: git-send-email 2.34.1 In-Reply-To: <170791693437.389532.6816883363982512874.stgit@devnote2> References: <170791693437.389532.6816883363982512874.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: 1790880810515748301 X-GMAIL-MSGID: 1790880810515748301 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) --- 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 99c051de412a..49d9af6d446e 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;