From nobody Tue Dec 16 07:28:40 2025 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 0D8A020F999; Tue, 14 Jan 2025 21:22:58 +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=1736889779; cv=none; b=ewqwC/i5c4DvnQdFjygnuICEcG0DbvG6FfdL8yy6jlgqEAUvUWXT1LkhQ2Mgko772vlXVPqBSiyQIRl88jwkLoWZKOe1AUQ4OSoRBvkrul3kWnsZMVO7j2BfFH1jiFC9vEW5fpKVJP14HzINY7JdeHZJyAufKfC5lo21fX/z9p4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736889779; c=relaxed/simple; bh=NxSCJ2syR3YYbNJ3uryk3tsjg2K+IpnX1WSFOL5GHws=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=evIgiUy4x4IJG9v3pVT9kQDMoY/QLlTnzJyXojslA0uJtpMcybVZAo4Uj3pwul5i06ikT/7UwYthEYDfQeIhwtjjJDa5OPbDNAfQS6mklrPZDcCKQU65MHSga8MHcZRWYVDOkh7DfI2rCk+LzGMghUFZQSuHIuWIQXkfPGm2lD8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=CG3y5Zcx; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="CG3y5Zcx" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3C30CC4CEE5; Tue, 14 Jan 2025 21:22:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1736889778; bh=NxSCJ2syR3YYbNJ3uryk3tsjg2K+IpnX1WSFOL5GHws=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CG3y5ZcxG9BSLqun5CgVmuEpdF7+XsGqtk90xQWfaoCTbB+dCo0ih7GWXroHd/mJE JdayuVNXjuIoxoVi6+J2YVlyflAuOlxqozqn31N8xmZOmvcqe06rwLCX2UNXy8cZ7w oZaKlObMWZ8xRSDQfXEkMB0Q4hasAbhuGAY89oyHsIlvDNOkKh14FUga036kh+SaSD FTJh13wWIYWgMiMnK/WO2KvGBzr+5cOoDsSXMuIxrbuVH4b3tiSe2sFxnyLcheyXZL 7zC042A3asN9xrnfw/OCeOxx8bhHdQKyge5RvNvFGzmSpjjADMzoGLQ+klbMY0jnUH 5CldJpnTNDt8w== From: Namhyung Kim To: Arnaldo Carvalho de Melo , Ian Rogers , Kan Liang Cc: Jiri Olsa , Adrian Hunter , Peter Zijlstra , Ingo Molnar , LKML , linux-perf-users@vger.kernel.org, Howard Chu Subject: [PATCH 1/4] perf trace: Allocate syscall stats only if summary is on Date: Tue, 14 Jan 2025 13:22:53 -0800 Message-ID: <20250114212256.160730-2-namhyung@kernel.org> X-Mailer: git-send-email 2.48.0.rc2.279.g1de40edade-goog In-Reply-To: <20250114212256.160730-1-namhyung@kernel.org> References: <20250114212256.160730-1-namhyung@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The syscall stats are used only when summary is requested. Let's avoid unnecessary operations. Pass 'trace' pointer to check summary and give output file together. Signed-off-by: Namhyung Kim --- tools/perf/builtin-trace.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index 40dd2dd1320d37a9..0691e817c15b4136 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c @@ -1523,13 +1523,14 @@ struct thread_trace { struct intlist *syscall_stats; }; =20 -static struct thread_trace *thread_trace__new(void) +static struct thread_trace *thread_trace__new(struct trace *trace) { struct thread_trace *ttrace =3D zalloc(sizeof(struct thread_trace)); =20 if (ttrace) { ttrace->files.max =3D -1; - ttrace->syscall_stats =3D intlist__new(NULL); + if (trace->summary) + ttrace->syscall_stats =3D intlist__new(NULL); } =20 return ttrace; @@ -1551,7 +1552,7 @@ static void thread_trace__delete(void *pttrace) free(ttrace); } =20 -static struct thread_trace *thread__trace(struct thread *thread, FILE *fp) +static struct thread_trace *thread__trace(struct thread *thread, struct tr= ace *trace) { struct thread_trace *ttrace; =20 @@ -1559,7 +1560,7 @@ static struct thread_trace *thread__trace(struct thre= ad *thread, FILE *fp) goto fail; =20 if (thread__priv(thread) =3D=3D NULL) - thread__set_priv(thread, thread_trace__new()); + thread__set_priv(thread, thread_trace__new(trace)); =20 if (thread__priv(thread) =3D=3D NULL) goto fail; @@ -1569,7 +1570,7 @@ static struct thread_trace *thread__trace(struct thre= ad *thread, FILE *fp) =20 return ttrace; fail: - color_fprintf(fp, PERF_COLOR_RED, + color_fprintf(trace->output, PERF_COLOR_RED, "WARNING: not enough memory, dropping samples!\n"); return NULL; } @@ -2623,7 +2624,7 @@ static int trace__sys_enter(struct trace *trace, stru= ct evsel *evsel, return -1; =20 thread =3D machine__findnew_thread(trace->host, sample->pid, sample->tid); - ttrace =3D thread__trace(thread, trace->output); + ttrace =3D thread__trace(thread, trace); if (ttrace =3D=3D NULL) goto out_put; =20 @@ -2700,7 +2701,7 @@ static int trace__fprintf_sys_enter(struct trace *tra= ce, struct evsel *evsel, return -1; =20 thread =3D machine__findnew_thread(trace->host, sample->pid, sample->tid); - ttrace =3D thread__trace(thread, trace->output); + ttrace =3D thread__trace(thread, trace); /* * We need to get ttrace just to make sure it is there when syscall__scnp= rintf_args() * and the rest of the beautifiers accessing it via struct syscall_arg to= uches it. @@ -2772,7 +2773,7 @@ static int trace__sys_exit(struct trace *trace, struc= t evsel *evsel, return -1; =20 thread =3D machine__findnew_thread(trace->host, sample->pid, sample->tid); - ttrace =3D thread__trace(thread, trace->output); + ttrace =3D thread__trace(thread, trace); if (ttrace =3D=3D NULL) goto out_put; =20 @@ -2961,7 +2962,7 @@ static int trace__sched_stat_runtime(struct trace *tr= ace, struct evsel *evsel, struct thread *thread =3D machine__findnew_thread(trace->host, sample->pid, sample->tid); - struct thread_trace *ttrace =3D thread__trace(thread, trace->output); + struct thread_trace *ttrace =3D thread__trace(thread, trace); =20 if (ttrace =3D=3D NULL) goto out_dump; @@ -3215,7 +3216,7 @@ static int trace__pgfault(struct trace *trace, } } =20 - ttrace =3D thread__trace(thread, trace->output); + ttrace =3D thread__trace(thread, trace); if (ttrace =3D=3D NULL) goto out_put; =20 --=20 2.48.0.rc2.279.g1de40edade-goog