Netdev List
 help / color / mirror / Atom feed
* [RFC] change dst_entry padding from using an array to using __attribute__
@ 2010-04-07 16:46 Laurent Chavey
  2010-04-07 16:55 ` Eric Dumazet
  0 siblings, 1 reply; 3+ messages in thread
From: Laurent Chavey @ 2010-04-07 16:46 UTC (permalink / raw)
  To: netdev; +Cc: laurent chavey

what are the benefit(s)  of using an array to force a struct
element to be aligned on 64 bytes / 32 bytes boundaries
versus using gcc __attribute__.


------------------------------------

struct dst_entry {

       /*
        * Align __refcnt to a 64 bytes alignment
        * (L1_CACHE_SIZE would be too much)
        */
- #ifdef CONFIG_64BIT
-       long                    __pad_to_align_refcnt[1];
- #else
-       long                    __pad_to_align_refcnt[0];
- #endif
+       atomic_t                __refcnt __attribute__
((aligned(64))); /* client references    */
#undef __padding__
       /*
        * __refcnt wants to be on a different cache line from
        * input/output/ops or performance tanks badly
        */
       atomic_t                __refcnt;       /* client references    */
};

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

* Re: [RFC] change dst_entry padding from using an array to using __attribute__
  2010-04-07 16:46 [RFC] change dst_entry padding from using an array to using __attribute__ Laurent Chavey
@ 2010-04-07 16:55 ` Eric Dumazet
  2010-04-07 16:56   ` Eric Dumazet
  0 siblings, 1 reply; 3+ messages in thread
From: Eric Dumazet @ 2010-04-07 16:55 UTC (permalink / raw)
  To: Laurent Chavey; +Cc: netdev

Le mercredi 07 avril 2010 à 09:46 -0700, Laurent Chavey a écrit :
> what are the benefit(s)  of using an array to force a struct
> element to be aligned on 64 bytes / 32 bytes boundaries
> versus using gcc __attribute__.
> 
> 
> ------------------------------------
> 
> struct dst_entry {
> 
>        /*
>         * Align __refcnt to a 64 bytes alignment
>         * (L1_CACHE_SIZE would be too much)
>         */
> - #ifdef CONFIG_64BIT
> -       long                    __pad_to_align_refcnt[1];
> - #else
> -       long                    __pad_to_align_refcnt[0];
> - #endif
> +       atomic_t                __refcnt __attribute__
> ((aligned(64))); /* client references    */
> #undef __padding__
>        /*
>         * __refcnt wants to be on a different cache line from
>         * input/output/ops or performance tanks badly
>         */
>        atomic_t                __refcnt;       /* client references    */
> };

We dont want a huge hole (say.. 120 bytes) being not noticed.

Some machines around have 4 millions dst entries.

This deserve us being not lazy :)

Thanks



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

* Re: [RFC] change dst_entry padding from using an array to using __attribute__
  2010-04-07 16:55 ` Eric Dumazet
@ 2010-04-07 16:56   ` Eric Dumazet
  0 siblings, 0 replies; 3+ messages in thread
From: Eric Dumazet @ 2010-04-07 16:56 UTC (permalink / raw)
  To: Laurent Chavey; +Cc: netdev

Le mercredi 07 avril 2010 à 18:55 +0200, Eric Dumazet a écrit :

> We dont want a huge hole (say.. 120 bytes) being not noticed.

sorry, 60 bytes of course.



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

end of thread, other threads:[~2010-04-07 16:56 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-04-07 16:46 [RFC] change dst_entry padding from using an array to using __attribute__ Laurent Chavey
2010-04-07 16:55 ` Eric Dumazet
2010-04-07 16:56   ` Eric Dumazet

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox