All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Jacobowitz <dan@debian.org>
To: Andrew Morton <akpm@digeo.com>
Cc: Jeff Garzik <jgarzik@pobox.com>,
	"David S. Miller" <davem@redhat.com>,
	linux-kernel@vger.kernel.org, netdev@oss.sgi.com
Subject: Re: [RFC][PATCH] net drivers and cache alignment
Date: Sat, 7 Dec 2002 20:14:03 -0500	[thread overview]
Message-ID: <20021208011403.GA7729@nevyn.them.org> (raw)
In-Reply-To: <3DF2844C.F9216283@digeo.com>

On Sat, Dec 07, 2002 at 03:29:16PM -0800, Andrew Morton wrote:
> Jeff Garzik wrote:
> > 
> > David S. Miller wrote:
> > > Can't the cacheline_aligned attribute be applied to individual
> > > struct members?  I remember doing this for thread_struct on
> > > sparc ages ago.
> > 
> > Looks like it from the 2.4 processor.h code.
> > 
> > Attached is cut #2.  Thanks for all the near-instant feedback so far :)
> >   Andrew, does the attached still need padding on SMP?
> 
> It needs padding _only_ on SMP.  ____cacheline_aligned_in_smp.
> 
> #define offsetof(t, m)  ((int)(&((t *)0)->m))
> 
> struct foo {
>         int a;
>         int b __attribute__((__aligned__(1024)));
>         int c;
> } foo;
> 
> main()
> {
>         printf("%d\n", sizeof(struct foo));
>         printf("%d\n", offsetof(struct foo, a));
>         printf("%d\n", offsetof(struct foo, b));
>         printf("%d\n", offsetof(struct foo, c));
> }
> 
> ./a.out
> 2048
> 0
> 1024
> 1028
> 
> So your patch will do what you want it to do.  You should just tag the
> first member of a group with ____cacheline_aligned_in_smp, and keep an
> eye on things with offsetof().
> 
> Not sure why sizeof() returned 2048 though.

The structure contains an __aligned__(1024) item.  Think about an array
of 'struct foo' items.  They have to be 2048 bytes or you won't align
correctly.

C allows for empty space in structure padding, but not in arrays,
AFAIK.


-- 
Daniel Jacobowitz
MontaVista Software                         Debian GNU/Linux Developer

      parent reply	other threads:[~2002-12-08  1:07 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-12-07 22:37 [RFC][PATCH] net drivers and cache alignment Jeff Garzik
2002-12-07 22:40 ` David S. Miller
2002-12-07 22:46   ` Jeff Garzik
2002-12-07 23:06   ` Jeff Garzik
2002-12-07 23:29     ` Andrew Morton
2002-12-07 23:30       ` David S. Miller
2002-12-07 23:42         ` Andrew Morton
2002-12-07 23:51           ` Andrew Morton
2002-12-15 18:31             ` Jes Sorensen
2002-12-08 20:00           ` David S. Miller
2002-12-07 23:36       ` Jeff Garzik
2002-12-07 23:37       ` J.A. Magallon
2002-12-07 23:42         ` Jeff Garzik
2002-12-07 23:45         ` Andrew Morton
2002-12-07 23:52           ` J.A. Magallon
2002-12-08  1:14       ` Daniel Jacobowitz [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20021208011403.GA7729@nevyn.them.org \
    --to=dan@debian.org \
    --cc=akpm@digeo.com \
    --cc=davem@redhat.com \
    --cc=jgarzik@pobox.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@oss.sgi.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.