linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [BUG] alignment problem in net/core/flow.c:flow_key_compare
@ 2004-03-18 10:53 Måns Rullgård
  2004-03-18 11:25 ` Måns Rullgård
  0 siblings, 1 reply; 4+ messages in thread
From: Måns Rullgård @ 2004-03-18 10:53 UTC (permalink / raw)
  To: linux-kernel

There is a problem with alignment in the flow_key_compare function in
net/core/flow.c.  It takes arguments of type struct flowi * and casts
them to flow_compare_t *, which is 64 bits on 64-bit machines.  It
then proceeds to read and compare 64-bit values from these pointers.
The problem is that struct flowi only requires 32-bit alignment, so
these reads cause numerous unaligned exceptions.  On average, I get
nearly 1000 unaligned exceptions per second.

The solutions I see are either to force the alignment of struct flowi
to 64 bits, or to use 32-bit access in flow_key_compare.

-- 
Måns Rullgård
mru@kth.se

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [BUG] alignment problem in net/core/flow.c:flow_key_compare
  2004-03-18 10:53 [BUG] alignment problem in net/core/flow.c:flow_key_compare Måns Rullgård
@ 2004-03-18 11:25 ` Måns Rullgård
  2004-03-18 18:30   ` David S. Miller
  0 siblings, 1 reply; 4+ messages in thread
From: Måns Rullgård @ 2004-03-18 11:25 UTC (permalink / raw)
  To: linux-kernel

mru@kth.se (Måns Rullgård) writes:

> There is a problem with alignment in the flow_key_compare function in
> net/core/flow.c.  It takes arguments of type struct flowi * and casts
> them to flow_compare_t *, which is 64 bits on 64-bit machines.  It
> then proceeds to read and compare 64-bit values from these pointers.
> The problem is that struct flowi only requires 32-bit alignment, so
> these reads cause numerous unaligned exceptions.  On average, I get
> nearly 1000 unaligned exceptions per second.
>
> The solutions I see are either to force the alignment of struct flowi
> to 64 bits, or to use 32-bit access in flow_key_compare.

I forgot to mention that this is kernel 2.6.4.

-- 
Måns Rullgård
mru@kth.se


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [BUG] alignment problem in net/core/flow.c:flow_key_compare
  2004-03-18 11:25 ` Måns Rullgård
@ 2004-03-18 18:30   ` David S. Miller
  2004-03-18 19:41     ` Måns Rullgård
  0 siblings, 1 reply; 4+ messages in thread
From: David S. Miller @ 2004-03-18 18:30 UTC (permalink / raw)
  To: Måns Rullgård; +Cc: linux-kernel

On Thu, 18 Mar 2004 12:25:57 +0100
mru@kth.se (Måns Rullgård) wrote:

> mru@kth.se (Måns Rullgård) writes:
> 
> > The solutions I see are either to force the alignment of struct flowi
> > to 64 bits, or to use 32-bit access in flow_key_compare.
> 
> I forgot to mention that this is kernel 2.6.4.

Yes, just add an alignment attribute of some kind to the struct
is probably the best idea.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [BUG] alignment problem in net/core/flow.c:flow_key_compare
  2004-03-18 18:30   ` David S. Miller
@ 2004-03-18 19:41     ` Måns Rullgård
  0 siblings, 0 replies; 4+ messages in thread
From: Måns Rullgård @ 2004-03-18 19:41 UTC (permalink / raw)
  To: David S. Miller; +Cc: linux-kernel

"David S. Miller" <davem@redhat.com> writes:

> On Thu, 18 Mar 2004 12:25:57 +0100
> mru@kth.se (Måns Rullgård) wrote:
>
>> mru@kth.se (Måns Rullgård) writes:
>> 
>> > The solutions I see are either to force the alignment of struct flowi
>> > to 64 bits, or to use 32-bit access in flow_key_compare.
>> 
>> I forgot to mention that this is kernel 2.6.4.
>
> Yes, just add an alignment attribute of some kind to the struct
> is probably the best idea.

What's the proper way of doing that in kernel code?  Should I use gcc
__attribute__ directly or is there some macro that's preferred?

-- 
Måns Rullgård
mru@kth.se

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2004-03-18 19:42 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-03-18 10:53 [BUG] alignment problem in net/core/flow.c:flow_key_compare Måns Rullgård
2004-03-18 11:25 ` Måns Rullgård
2004-03-18 18:30   ` David S. Miller
2004-03-18 19:41     ` Måns Rullgård

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).