All of lore.kernel.org
 help / color / mirror / Atom feed
From: Wander Lairson Costa <wander@redhat.com>
To: Costa Shulyupin <costa.shul@redhat.com>
Cc: Steven Rostedt <rostedt@goodmis.org>,
	 Tomas Glozar <tglozar@redhat.com>,
	Crystal Wood <crwood@redhat.com>,
	 Ivan Pravdin <ipravdin.official@gmail.com>,
	John Kacur <jkacur@redhat.com>,
	 Tiezhu Yang <yangtiezhu@loongson.cn>,
	linux-trace-kernel@vger.kernel.org, linux-kernel@vger.kernel.org,
	 bpf@vger.kernel.org
Subject: Re: [PATCH v2 2/4] tools/rtla: Remove unneeded nr_cpus arguments
Date: Wed, 11 Feb 2026 08:03:48 -0300	[thread overview]
Message-ID: <aYxh8jbeDENgZ9ht@fedora> (raw)
In-Reply-To: <20260209092436.2899888-3-costa.shul@redhat.com>

On Mon, Feb 09, 2026 at 11:24:34AM +0200, Costa Shulyupin wrote:
> nr_cpus does not change at runtime, so passing it through function
> arguments is unnecessary.
> 
> Use the global nr_cpus instead of propagating it via parameters.

The parameter should also be removed from timerlat_bpf_get_hist_value(),
shouldn't it?

> 
> Signed-off-by: Costa Shulyupin <costa.shul@redhat.com>
> ---
>  tools/tracing/rtla/src/osnoise_hist.c  |  4 ++--
>  tools/tracing/rtla/src/osnoise_top.c   |  4 ++--
>  tools/tracing/rtla/src/timerlat_bpf.c  |  5 ++---
>  tools/tracing/rtla/src/timerlat_bpf.h  |  6 ++----
>  tools/tracing/rtla/src/timerlat_hist.c | 19 +++++++------------
>  tools/tracing/rtla/src/timerlat_top.c  | 19 +++++++------------
>  tools/tracing/rtla/src/timerlat_u.c    |  6 +++---
>  7 files changed, 25 insertions(+), 38 deletions(-)
> 
> diff --git a/tools/tracing/rtla/src/osnoise_hist.c b/tools/tracing/rtla/src/osnoise_hist.c
> index 03ebff34fff4..d83ee047a5f5 100644
> --- a/tools/tracing/rtla/src/osnoise_hist.c
> +++ b/tools/tracing/rtla/src/osnoise_hist.c
> @@ -62,7 +62,7 @@ static void osnoise_free_hist_tool(struct osnoise_tool *tool)
>   * osnoise_alloc_histogram - alloc runtime data
>   */
>  static struct osnoise_hist_data
> -*osnoise_alloc_histogram(int nr_cpus, int entries, int bucket_size)
> +*osnoise_alloc_histogram(int entries, int bucket_size)
>  {
>  	struct osnoise_hist_data *data;
>  	int cpu;
> @@ -652,7 +652,7 @@ static struct osnoise_tool
>  	if (!tool)
>  		return NULL;
>  
> -	tool->data = osnoise_alloc_histogram(nr_cpus, params->hist.entries,
> +	tool->data = osnoise_alloc_histogram(params->hist.entries,
>  					     params->hist.bucket_size);
>  	if (!tool->data)
>  		goto out_err;
> diff --git a/tools/tracing/rtla/src/osnoise_top.c b/tools/tracing/rtla/src/osnoise_top.c
> index 7dcd2e318205..73b3ac0dd43b 100644
> --- a/tools/tracing/rtla/src/osnoise_top.c
> +++ b/tools/tracing/rtla/src/osnoise_top.c
> @@ -51,7 +51,7 @@ static void osnoise_free_top_tool(struct osnoise_tool *tool)
>  /*
>   * osnoise_alloc_histogram - alloc runtime data
>   */
> -static struct osnoise_top_data *osnoise_alloc_top(int nr_cpus)
> +static struct osnoise_top_data *osnoise_alloc_top(void)
>  {
>  	struct osnoise_top_data *data;
>  
> @@ -496,7 +496,7 @@ struct osnoise_tool *osnoise_init_top(struct common_params *params)
>  	if (!tool)
>  		return NULL;
>  
> -	tool->data = osnoise_alloc_top(nr_cpus);
> +	tool->data = osnoise_alloc_top();
>  	if (!tool->data) {
>  		osnoise_destroy_tool(tool);
>  		return NULL;
> diff --git a/tools/tracing/rtla/src/timerlat_bpf.c b/tools/tracing/rtla/src/timerlat_bpf.c
> index 05adf18303df..8d5c3a095e41 100644
> --- a/tools/tracing/rtla/src/timerlat_bpf.c
> +++ b/tools/tracing/rtla/src/timerlat_bpf.c
> @@ -191,13 +191,12 @@ int timerlat_bpf_get_hist_value(int key,
>  int timerlat_bpf_get_summary_value(enum summary_field key,
>  				   long long *value_irq,
>  				   long long *value_thread,
> -				   long long *value_user,
> -				   int cpus)
> +				   long long *value_user)
>  {
>  	return get_value(bpf->maps.summary_irq,
>  			 bpf->maps.summary_thread,
>  			 bpf->maps.summary_user,
> -			 key, value_irq, value_thread, value_user, cpus);
> +			 key, value_irq, value_thread, value_user, nr_cpus);
>  }
>  
>  /*
> diff --git a/tools/tracing/rtla/src/timerlat_bpf.h b/tools/tracing/rtla/src/timerlat_bpf.h
> index 169abeaf4363..f4a5476f2abb 100644
> --- a/tools/tracing/rtla/src/timerlat_bpf.h
> +++ b/tools/tracing/rtla/src/timerlat_bpf.h
> @@ -28,8 +28,7 @@ int timerlat_bpf_get_hist_value(int key,
>  int timerlat_bpf_get_summary_value(enum summary_field key,
>  				   long long *value_irq,
>  				   long long *value_thread,
> -				   long long *value_user,
> -				   int cpus);
> +				   long long *value_user);
>  int timerlat_load_bpf_action_program(const char *program_path);
>  static inline int have_libbpf_support(void) { return 1; }
>  #else
> @@ -53,8 +52,7 @@ static inline int timerlat_bpf_get_hist_value(int key,
>  static inline int timerlat_bpf_get_summary_value(enum summary_field key,
>  						 long long *value_irq,
>  						 long long *value_thread,
> -						 long long *value_user,
> -						 int cpus)
> +						 long long *value_user)
>  {
>  	return -1;
>  }
> diff --git a/tools/tracing/rtla/src/timerlat_hist.c b/tools/tracing/rtla/src/timerlat_hist.c
> index 841118ed84f2..dee5fbf622c3 100644
> --- a/tools/tracing/rtla/src/timerlat_hist.c
> +++ b/tools/tracing/rtla/src/timerlat_hist.c
> @@ -83,7 +83,7 @@ static void timerlat_free_histogram_tool(struct osnoise_tool *tool)
>   * timerlat_alloc_histogram - alloc runtime data
>   */
>  static struct timerlat_hist_data
> -*timerlat_alloc_histogram(int nr_cpus, int entries, int bucket_size)
> +*timerlat_alloc_histogram(int entries, int bucket_size)
>  {
>  	struct timerlat_hist_data *data;
>  	int cpu;
> @@ -223,8 +223,7 @@ static int timerlat_hist_bpf_pull_data(struct osnoise_tool *tool)
>  
>  	/* Pull summary */
>  	err = timerlat_bpf_get_summary_value(SUMMARY_COUNT,
> -					     value_irq, value_thread, value_user,
> -					     data->nr_cpus);
> +					     value_irq, value_thread, value_user);
>  	if (err)
>  		return err;
>  	for (i = 0; i < data->nr_cpus; i++) {
> @@ -234,8 +233,7 @@ static int timerlat_hist_bpf_pull_data(struct osnoise_tool *tool)
>  	}
>  
>  	err = timerlat_bpf_get_summary_value(SUMMARY_MIN,
> -					     value_irq, value_thread, value_user,
> -					     data->nr_cpus);
> +					     value_irq, value_thread, value_user);
>  	if (err)
>  		return err;
>  	for (i = 0; i < data->nr_cpus; i++) {
> @@ -245,8 +243,7 @@ static int timerlat_hist_bpf_pull_data(struct osnoise_tool *tool)
>  	}
>  
>  	err = timerlat_bpf_get_summary_value(SUMMARY_MAX,
> -					     value_irq, value_thread, value_user,
> -					     data->nr_cpus);
> +					     value_irq, value_thread, value_user);
>  	if (err)
>  		return err;
>  	for (i = 0; i < data->nr_cpus; i++) {
> @@ -256,8 +253,7 @@ static int timerlat_hist_bpf_pull_data(struct osnoise_tool *tool)
>  	}
>  
>  	err = timerlat_bpf_get_summary_value(SUMMARY_SUM,
> -					     value_irq, value_thread, value_user,
> -					     data->nr_cpus);
> +					     value_irq, value_thread, value_user);
>  	if (err)
>  		return err;
>  	for (i = 0; i < data->nr_cpus; i++) {
> @@ -267,8 +263,7 @@ static int timerlat_hist_bpf_pull_data(struct osnoise_tool *tool)
>  	}
>  
>  	err = timerlat_bpf_get_summary_value(SUMMARY_OVERFLOW,
> -					     value_irq, value_thread, value_user,
> -					     data->nr_cpus);
> +					     value_irq, value_thread, value_user);
>  	if (err)
>  		return err;
>  	for (i = 0; i < data->nr_cpus; i++) {
> @@ -1036,7 +1031,7 @@ static struct osnoise_tool
>  	if (!tool)
>  		return NULL;
>  
> -	tool->data = timerlat_alloc_histogram(nr_cpus, params->hist.entries,
> +	tool->data = timerlat_alloc_histogram(params->hist.entries,
>  					      params->hist.bucket_size);
>  	if (!tool->data)
>  		goto out_err;
> diff --git a/tools/tracing/rtla/src/timerlat_top.c b/tools/tracing/rtla/src/timerlat_top.c
> index 3e395ce4fa9f..25b4d81b4fe0 100644
> --- a/tools/tracing/rtla/src/timerlat_top.c
> +++ b/tools/tracing/rtla/src/timerlat_top.c
> @@ -62,7 +62,7 @@ static void timerlat_free_top_tool(struct osnoise_tool *tool)
>  /*
>   * timerlat_alloc_histogram - alloc runtime data
>   */
> -static struct timerlat_top_data *timerlat_alloc_top(int nr_cpus)
> +static struct timerlat_top_data *timerlat_alloc_top(void)
>  {
>  	struct timerlat_top_data *data;
>  	int cpu;
> @@ -196,8 +196,7 @@ static int timerlat_top_bpf_pull_data(struct osnoise_tool *tool)
>  
>  	/* Pull summary */
>  	err = timerlat_bpf_get_summary_value(SUMMARY_CURRENT,
> -					     value_irq, value_thread, value_user,
> -					     data->nr_cpus);
> +					     value_irq, value_thread, value_user);
>  	if (err)
>  		return err;
>  	for (i = 0; i < data->nr_cpus; i++) {
> @@ -207,8 +206,7 @@ static int timerlat_top_bpf_pull_data(struct osnoise_tool *tool)
>  	}
>  
>  	err = timerlat_bpf_get_summary_value(SUMMARY_COUNT,
> -					     value_irq, value_thread, value_user,
> -					     data->nr_cpus);
> +					     value_irq, value_thread, value_user);
>  	if (err)
>  		return err;
>  	for (i = 0; i < data->nr_cpus; i++) {
> @@ -218,8 +216,7 @@ static int timerlat_top_bpf_pull_data(struct osnoise_tool *tool)
>  	}
>  
>  	err = timerlat_bpf_get_summary_value(SUMMARY_MIN,
> -					     value_irq, value_thread, value_user,
> -					     data->nr_cpus);
> +					     value_irq, value_thread, value_user);
>  	if (err)
>  		return err;
>  	for (i = 0; i < data->nr_cpus; i++) {
> @@ -229,8 +226,7 @@ static int timerlat_top_bpf_pull_data(struct osnoise_tool *tool)
>  	}
>  
>  	err = timerlat_bpf_get_summary_value(SUMMARY_MAX,
> -					     value_irq, value_thread, value_user,
> -					     data->nr_cpus);
> +					     value_irq, value_thread, value_user);
>  	if (err)
>  		return err;
>  	for (i = 0; i < data->nr_cpus; i++) {
> @@ -240,8 +236,7 @@ static int timerlat_top_bpf_pull_data(struct osnoise_tool *tool)
>  	}
>  
>  	err = timerlat_bpf_get_summary_value(SUMMARY_SUM,
> -					     value_irq, value_thread, value_user,
> -					     data->nr_cpus);
> +					     value_irq, value_thread, value_user);
>  	if (err)
>  		return err;
>  	for (i = 0; i < data->nr_cpus; i++) {
> @@ -782,7 +777,7 @@ static struct osnoise_tool
>  	if (!top)
>  		return NULL;
>  
> -	top->data = timerlat_alloc_top(nr_cpus);
> +	top->data = timerlat_alloc_top();
>  	if (!top->data)
>  		goto out_err;
>  
> diff --git a/tools/tracing/rtla/src/timerlat_u.c b/tools/tracing/rtla/src/timerlat_u.c
> index a569fe7f93aa..03b4e68e8b1e 100644
> --- a/tools/tracing/rtla/src/timerlat_u.c
> +++ b/tools/tracing/rtla/src/timerlat_u.c
> @@ -99,7 +99,7 @@ static int timerlat_u_main(int cpu, struct timerlat_u_params *params)
>   *
>   * Return the number of processes that received the kill.
>   */
> -static int timerlat_u_send_kill(pid_t *procs, int nr_cpus)
> +static int timerlat_u_send_kill(pid_t *procs)
>  {
>  	int killed = 0;
>  	int i, retval;
> @@ -169,7 +169,7 @@ void *timerlat_u_dispatcher(void *data)
>  
>  		/* parent */
>  		if (pid == -1) {
> -			timerlat_u_send_kill(procs, nr_cpus);
> +			timerlat_u_send_kill(procs);
>  			debug_msg("Failed to create child processes");
>  			pthread_exit(&retval);
>  		}
> @@ -196,7 +196,7 @@ void *timerlat_u_dispatcher(void *data)
>  		sleep(1);
>  	}
>  
> -	timerlat_u_send_kill(procs, nr_cpus);
> +	timerlat_u_send_kill(procs);
>  
>  	while (procs_count) {
>  		pid = waitpid(-1, &wstatus, 0);
> -- 
> 2.52.0
> 


  reply	other threads:[~2026-02-11 11:03 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-09  9:24 [PATCH v2 0/4] tools/rtla: Consolidate nr_cpus usage Costa Shulyupin
2026-02-09  9:24 ` [PATCH v2 1/4] tools/rtla: Consolidate nr_cpus usage across all tools Costa Shulyupin
2026-02-11 11:03   ` Wander Lairson Costa
2026-02-11 11:15     ` Tomas Glozar
2026-02-09  9:24 ` [PATCH v2 2/4] tools/rtla: Remove unneeded nr_cpus arguments Costa Shulyupin
2026-02-11 11:03   ` Wander Lairson Costa [this message]
2026-02-09  9:24 ` [PATCH v2 3/4] tools/rtla: Remove unneeded nr_cpus members Costa Shulyupin
2026-02-09  9:24 ` [PATCH v2 4/4] tools/rtla: Remove unneeded nr_cpus from for_each_monitored_cpu Costa Shulyupin
2026-02-10 21:07 ` [PATCH v2 0/4] tools/rtla: Consolidate nr_cpus usage Crystal Wood

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aYxh8jbeDENgZ9ht@fedora \
    --to=wander@redhat.com \
    --cc=bpf@vger.kernel.org \
    --cc=costa.shul@redhat.com \
    --cc=crwood@redhat.com \
    --cc=ipravdin.official@gmail.com \
    --cc=jkacur@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=tglozar@redhat.com \
    --cc=yangtiezhu@loongson.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.