Re: [BUG] percpu misaligned allocation

From: Frederic Weisbecker
Date: Thu Mar 18 2010 - 21:31:25 EST


On Thu, Mar 18, 2010 at 05:54:13PM -0700, David Miller wrote:
> From: Tejun Heo <tj@xxxxxxxxxx>
> Date: Thu, 18 Mar 2010 18:30:34 +0900
>
> >
> > if (!total_profile_count) {
> > - buf = (char *)alloc_percpu(perf_trace_t);
> > + buf = (char *)__alloc_percpu(sizeof(perf_trace_t),
> > + __alignof__(unsigned long));
> > if (!buf)
> > goto fail_buf;
>
> Why not make perf_trace_t have the proper alignment?


So, making perf_trace_t as align(8) would do the trick?
I lack the knowledge about alignment layout for archs that
need aligned accesses.
At a first glance, what I would except is that every buffer
has a base address aligned, no?


>
> That's better than patching around it like this.
>
> Defining it as an array of char[]'s is just asking
> for lots of trouble.


Yeah but we need a generic type. This is because
our buffer can be of any random type to match all
the trace event layouts we have, all of them being
generated by macros.

--
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/