All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stevie Alvarez <stevie.6strings@gmail.com>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: linux-trace-devel@vger.kernel.org, Ross Zwisler <zwisler@google.com>
Subject: Re: [PATCH v2 1/5] histograms: Initial histograms interface
Date: Fri, 4 Aug 2023 14:25:41 -0400	[thread overview]
Message-ID: <20230804182541.GB4353@3xKetch> (raw)
In-Reply-To: <20230804135718.70dba76c@gandalf.local.home>

On Fri, Aug 04, 2023 at 01:57:18PM -0400, Steven Rostedt wrote:
> On Fri, 4 Aug 2023 13:41:59 -0400
> Stevie Alvarez <stevie.6strings@gmail.com> wrote:
> 
> > > > +struct traceeval_type {
> > > > +	char				*name;
> > > > +	traceeval_dyn_release_fn	dyn_release;
> > > > +	traceeval_dyn_cmp_fn		dyn_cmp;
> > > > +	enum traceeval_data_type	type;
> > > > +	size_t				flags;
> > > > +	size_t				id;  
> > > 
> > > Let's reorder this a little. Normally function pointers come at the end of
> > > a structure. That's more of a guideline than a rule, but let's have it here.
> > > 
> > > struct traceeval_type {
> > > 	char				*name;
> > > 	enum traceeval_data_type	type;
> > > 	size_t				flags;
> > > 	size_t				id;
> > > 	traceeval_dyn_release_fn	dyn_release;
> > > 	traceeval_dyn_cmp_fn		dyn_cmp;
> > > };
> > > 
> > > Especially since dynamic types are going to be rare, we don't want it in
> > > the hot cache.  
> > 
> > Does the order of the fields in a struct definition not matter? I
> > thought word-boundaries applied to struct definitions? Or does the
> > compiler take care of this?
> 
> They do matter. Word bounders are important, but the compiler will just
> make "holes" if needed. For example, let's say on 64 bit, everything above
> is 64 bits but the type. I would have created a "hole". But because the
> type is more important than the id, I kept it at the top.
> 
> struct traceeval_type {
> 	char				*name;			// offset 0
>  	enum traceeval_data_type	type;			// offset 8
> 
> [ compiler adds 4 byte "hole" or "padding" ]
> 
>  	size_t				flags;			// offset 16
>  	size_t				id;			// offset 24
>  	traceeval_dyn_release_fn	dyn_release;		// offset 32
>  	traceeval_dyn_cmp_fn		dyn_cmp;		// offset 40
> };
> 
> If a cache line is 32 bytes (most is usually 128, but let's say on an older
> architecture) I don't care if the the dyn_release and dyn_cmp are in the
> same cache line as name.
> 
> -- Steve

This makes sense, I appreciate the explination! I was treating size_t as
an int in my head by accident.... oops!

-- Stevie

  reply	other threads:[~2023-08-04 18:28 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-03 22:53 [PATCH v2 0/5] histograms: bug fixes and convention compliance Stevie Alvarez
2023-08-03 22:53 ` [PATCH v2 1/5] histograms: Initial histograms interface Stevie Alvarez
2023-08-04 13:50   ` Steven Rostedt
2023-08-04 17:41     ` Stevie Alvarez
2023-08-04 17:57       ` Steven Rostedt
2023-08-04 18:25         ` Stevie Alvarez [this message]
2023-08-03 22:54 ` [PATCH v2 2/5] histograms: Add traceeval initialize Stevie Alvarez
2023-08-04 14:40   ` Steven Rostedt
2023-08-04 18:23     ` Stevie Alvarez
2023-08-04 19:20       ` Steven Rostedt
2023-08-03 22:54 ` [PATCH v2 3/5] histograms: Add traceeval release Stevie Alvarez
2023-08-04 14:55   ` Steven Rostedt
2023-08-03 22:54 ` [PATCH v2 4/5] histograms: Add traceeval compare Stevie Alvarez
2023-08-04 15:24   ` Steven Rostedt
2023-08-07 23:40   ` Ross Zwisler
2023-08-03 22:54 ` [PATCH v2 5/5] histograms: Initial unit tests Stevie Alvarez
2023-08-04 12:37 ` [PATCH v2 0/5] histograms: bug fixes and convention compliance Steven Rostedt

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=20230804182541.GB4353@3xKetch \
    --to=stevie.6strings@gmail.com \
    --cc=linux-trace-devel@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=zwisler@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 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.