Re: [PATCH 2/3] DEBUGFS: Add per cpu counters
From: Steven Rostedt
Date: Tue Dec 13 2011 - 18:08:20 EST
On Tue, 2011-12-13 at 14:56 -0800, Andi Kleen wrote:
>
> > > +struct debugfs_counter {
> > > + unsigned __percpu *ptr;
> > > + const char *fn;
> > > + const char *name;
> > > +} __attribute__((aligned(sizeof(char *))));
> > > +
> >
> > See commit 654986462 for details.
>
> Doesn't give a lot of details actually. Which target?
>
> Note that my structure only has pointers, so there is not a lot
> of potential for "evil" alignment.
We hit this with trace events as well, and your structure does have an
evil alignment, it's 3 pointers, which is not a base 2 number. Thus,
there were some compilers that liked to add padding to make the
alignment a power of 2. That is, between two sections of files we ended
up with something like:
.section file1
.ptra1
.ptra2
.ptra3
.ptrb1
.ptrb2
.ptrb3
.ptrc1
.ptrc2
.ptrc3
.ptrd1
.ptrd2
.ptrd3
.ptre1
.ptre2
.ptre3
<space>
.section file2
.ptrf1
.ptrf2
.ptrf3
[...]
It didn't happen often, heck, trace events and tracepoints were like
this for sometime before this blew up in our faces.
>From what I've seen is that 1 or 2 longs will pack nicely, but anything
else (except for maybe 4, 8, 16, etc) will run a risk of crashing.
-- Steve
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/