From: David Miller on
From: Frederic Weisbecker <fweisbec(a)gmail.com>
Date: Fri, 19 Mar 2010 02:31:22 +0100

> On Thu, Mar 18, 2010 at 05:54:13PM -0700, David Miller wrote:
>> From: Tejun Heo <tj(a)kernel.org>
>> 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?

Make it of the largest type that could appeat
in a trace entry.

I would use u64 so something like:

u64 [FTRACE_MAX_PROFILE_SIZE / sizeof(u64)]
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
From: Tejun Heo on
On 03/19/2010 10:57 AM, David Miller wrote:
> I would use u64 so something like:
>
> u64 [FTRACE_MAX_PROFILE_SIZE / sizeof(u64)]

<paranoid>DIV_ROUND_UP() would be safer than division</paranoid>

Thanks.

--
tejun
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
From: Frederic Weisbecker on
On Fri, Mar 19, 2010 at 11:18:51AM +0900, Tejun Heo wrote:
> On 03/19/2010 10:57 AM, David Miller wrote:
> > I would use u64 so something like:
> >
> > u64 [FTRACE_MAX_PROFILE_SIZE / sizeof(u64)]
>
> <paranoid>DIV_ROUND_UP() would be safer than division</paranoid>
>
> Thanks.


Ok, thanks guys, I'll try this out.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
From: David Miller on
From: Tejun Heo <tj(a)kernel.org>
Date: Fri, 19 Mar 2010 11:18:51 +0900

> On 03/19/2010 10:57 AM, David Miller wrote:
>> I would use u64 so something like:
>>
>> u64 [FTRACE_MAX_PROFILE_SIZE / sizeof(u64)]
>
> <paranoid>DIV_ROUND_UP() would be safer than division</paranoid>

There's potential real trouble if it isn't a multiple of sizeof(u64)
so better:

BUILD_BUG_ON(FTRACE_MAX_PROFILE_SIZE % sizeof(u64));

:-)

What a mess, just because this thing can't be typed properly :-/
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
From: Richard Kennedy on
On 19/03/10 03:02, David Miller wrote:
> From: Tejun Heo <tj(a)kernel.org>
> Date: Fri, 19 Mar 2010 11:18:51 +0900
>
>> On 03/19/2010 10:57 AM, David Miller wrote:
>>> I would use u64 so something like:
>>>
>>> u64 [FTRACE_MAX_PROFILE_SIZE / sizeof(u64)]
>>
>> <paranoid>DIV_ROUND_UP() would be safer than division</paranoid>
>
> There's potential real trouble if it isn't a multiple of sizeof(u64)
> so better:
>
> BUILD_BUG_ON(FTRACE_MAX_PROFILE_SIZE % sizeof(u64));
>
> :-)
>
> What a mess, just because this thing can't be typed properly :-/
> --
> To unsubscribe from this list: send the line "unsubscribe sparclinux" in
> the body of a message to majordomo(a)vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>

Couldn't you use a union?

For example if you have
union test {
long t;
char buffer[50];
};
gcc will then do the right thing.

on x86_64 sizeof(union test) = 56
but on x86_32 it's only 52.

regards
Richard

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/