public inbox for linux-trace-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Tim Chen <tim.c.chen@linux.intel.com>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
	Linux Trace Kernel <linux-trace-kernel@vger.kernel.org>,
	Masami Hiramatsu <mhiramat@kernel.org>,
	 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
	Mark Rutland <mark.rutland@arm.com>,
	Vincent Donnefort <vdonnefort@google.com>,
	Sven Schnelle <svens@linux.ibm.com>,
	Mete Durlu <meted@linux.ibm.com>
Subject: Re: [PATCH] tracing: Have saved_cmdlines arrays all in one allocation
Date: Tue, 13 Feb 2024 08:35:22 -0800	[thread overview]
Message-ID: <967027adabdc8aa654cd788b21147427477a0f08.camel@linux.intel.com> (raw)
In-Reply-To: <20240212191336.5c502f78@gandalf.local.home>

On Mon, 2024-02-12 at 19:13 -0500, Steven Rostedt wrote:
> On Mon, 12 Feb 2024 15:39:03 -0800
> Tim Chen <tim.c.chen@linux.intel.com> wrote:
> 
> > > diff --git a/kernel/trace/trace_sched_switch.c b/kernel/trace/trace_sched_switch.c
> > > index e4fbcc3bede5..210c74dcd016 100644
> > > --- a/kernel/trace/trace_sched_switch.c
> > > +++ b/kernel/trace/trace_sched_switch.c
> > > @@ -201,7 +201,7 @@ static struct saved_cmdlines_buffer *allocate_cmdlines_buffer(unsigned int val)
> > >  	int order;
> > >  
> > >  	/* Figure out how much is needed to hold the given number of cmdlines */
> > > -	orig_size = sizeof(*s) + val * TASK_COMM_LEN;
> > > +	orig_size = sizeof(*s) + val * (TASK_COMM_LEN + sizeof(int));  
> > 
> > Strictly speaking, *map_cmdline_to_pid is unsigned int so it is more consistent
> > to use sizeof(unsigned) in line above.  But I'm nitpicking and I'm fine to
> > leave it as is.
> 
> I was thinking about making that into a macro as it is used in two places.
> 
> /* Holds the size of a cmdline and pid element */
> #define SAVED_CMDLINE_MAP_ELEMENT_SIZE(s)		\
> 	(TASK_COMM_LEN + sizeof((s)->map_cmdline_to_pid[0]))
> 
> 	orig_size = sizeof(*s) + val * SAVED_CMDLINE_MAP_ELEMENT_SIZE(s);
> 
> 

Looks good. This makes the code more readable.

Tim

      reply	other threads:[~2024-02-13 16:35 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-12 23:09 [PATCH] tracing: Have saved_cmdlines arrays all in one allocation Steven Rostedt
2024-02-12 23:36 ` Masami Hiramatsu
2024-02-12 23:39 ` Tim Chen
2024-02-13  0:13   ` Steven Rostedt
2024-02-13 16:35     ` Tim Chen [this message]

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=967027adabdc8aa654cd788b21147427477a0f08.camel@linux.intel.com \
    --to=tim.c.chen@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=meted@linux.ibm.com \
    --cc=mhiramat@kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=svens@linux.ibm.com \
    --cc=vdonnefort@google.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox