From: Jesper Nilsson <[email protected]>
Date: Mon, 17 Jan 2011 10:05:57 +0100
> On Mon, Jan 17, 2011 at 07:07:55AM +0100, David Miller wrote:
>> Ugh, and I just noticed that include/linux/klist.h does this fixed
>> alignment of "4" too, where is this stuff coming from? It's
>> wrong on 64-bit, at best. But I can't see the impetus behind doing
>> this at all in the first place.
>>
>> Oh, this is some CRIS thing, because it only byte aligns. See:
>>
>> commit c0e69a5bbc6fc74184aa043aadb9a53bc58f953b
>> Author: Jesper Nilsson <[email protected]>
>> Date: Wed Jan 14 11:19:08 2009 +0100
>>
>> klist.c: bit 0 in pointer can't be used as flag
>>
>> That's where the klist one comes from.
>
> Yup, this one could instead be solved by introducing a "flags" field
> in the struct, but that was considered a too large impact fix.
Jesper, could you please review this?
--------------------
klist: Fix object alignment on 64-bit.
Commit c0e69a5bbc6fc74184aa043aadb9a53bc58f953b ("klist.c: bit 0 in
pointer can't be used as flag") intended to make sure that all klist
objects were at least pointer size aligned, but used the constant "4"
which only works on 32-bit.
Use "sizeof(void *)" which is correct in all cases.
Signed-off-by: David S. Miller <[email protected]>
diff --git a/include/linux/klist.h b/include/linux/klist.h
index e91a4e5..a370ce5 100644
--- a/include/linux/klist.h
+++ b/include/linux/klist.h
@@ -22,7 +22,7 @@ struct klist {
struct list_head k_list;
void (*get)(struct klist_node *);
void (*put)(struct klist_node *);
-} __attribute__ ((aligned (4)));
+} __attribute__ ((aligned (sizeof(void *))));
#define KLIST_INIT(_name, _get, _put) \
{ .k_lock = __SPIN_LOCK_UNLOCKED(_name.k_lock), \
On Tue, Feb 01, 2011 at 06:11:16AM +0100, David Miller wrote:
> Jesper, could you please review this?
Looks good!
Acked-by: Jesper Nilsson <[email protected]>
> --------------------
> klist: Fix object alignment on 64-bit.
>
> Commit c0e69a5bbc6fc74184aa043aadb9a53bc58f953b ("klist.c: bit 0 in
> pointer can't be used as flag") intended to make sure that all klist
> objects were at least pointer size aligned, but used the constant "4"
> which only works on 32-bit.
>
> Use "sizeof(void *)" which is correct in all cases.
>
> Signed-off-by: David S. Miller <[email protected]>
>
> diff --git a/include/linux/klist.h b/include/linux/klist.h
> index e91a4e5..a370ce5 100644
> --- a/include/linux/klist.h
> +++ b/include/linux/klist.h
> @@ -22,7 +22,7 @@ struct klist {
> struct list_head k_list;
> void (*get)(struct klist_node *);
> void (*put)(struct klist_node *);
> -} __attribute__ ((aligned (4)));
> +} __attribute__ ((aligned (sizeof(void *))));
>
> #define KLIST_INIT(_name, _get, _put) \
> { .k_lock = __SPIN_LOCK_UNLOCKED(_name.k_lock), \
/^JN - Jesper Nilsson
--
Jesper Nilsson -- [email protected]