netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Graf <tgraf@suug.ch>
To: Eric Dumazet <eric.dumazet@gmail.com>
Cc: davem@davemloft.net, jeffrey.t.kirsher@intel.com,
	intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org
Subject: Re: [PATCH 3/3 net-next] net_device: Add minimal padding to allow for net_device pointer alignment
Date: Fri, 10 Apr 2015 09:48:16 +0100	[thread overview]
Message-ID: <20150410084816.GB23070@casper.infradead.org> (raw)
In-Reply-To: <1428626095.25985.282.camel@edumazet-glaptop2.roam.corp.google.com>

On 04/09/15 at 05:34pm, Eric Dumazet wrote:
> On Fri, 2015-04-10 at 01:43 +0200, Thomas Graf wrote:
> > diff --git a/net/core/dev.c b/net/core/dev.c
> > index b2775f0..2b43aba 100644
> > --- a/net/core/dev.c
> > +++ b/net/core/dev.c
> > @@ -6794,8 +6794,7 @@ struct net_device *alloc_netdev_mqs(int sizeof_priv, const char *name,
> >  		alloc_size = ALIGN(alloc_size, NETDEV_ALIGN);
> >  		alloc_size += sizeof_priv;
> >  	}
> > -	/* ensure 32-byte alignment of whole construct */
> > -	alloc_size += NETDEV_ALIGN - 1;
> > +	alloc_size += PTR_ALIGN_PAD(struct net_device, NETDEV_ALIGN);
> >  
> >  	p = kzalloc(alloc_size, GFP_KERNEL | __GFP_NOWARN | __GFP_REPEAT);
> >  	if (!p)
> 
> 
> I believe code intent was to get an alignment even if kmalloc() returns
> say 0xxxxx0008.
> 
> AFAIK, SLAB in debug mode was able to do this.

I assumed kmalloc would guarantee alignment of the return pointer as
indicated by __alignof__ but I now realize that this can't possibly be the
case. kmalloc only knows about the size. We'll have to drop patch 3.
Fortunately it's still below 2K.

  reply	other threads:[~2015-04-10  8:48 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-09 23:43 [PATCH 0/3 net-next] Bring sizeof(net_device) down to < 2K bytes Thomas Graf
2015-04-09 23:43 ` [PATCH 1/3 net-next] e1000: Allocate pm_qos_req as needed Thomas Graf
2015-04-10  0:08   ` Jeff Kirsher
2015-04-10  4:35     ` [Intel-wired-lan] " Jeff Kirsher
2015-04-10  8:01       ` Daniel Borkmann
2015-04-10  8:48         ` Thomas Graf
2015-04-10  8:58           ` Jeff Kirsher
2015-04-09 23:43 ` [PATCH 2/3 net-next] net_device: Reorder members to fill holes Thomas Graf
2015-04-09 23:43 ` [PATCH 3/3 net-next] net_device: Add minimal padding to allow for net_device pointer alignment Thomas Graf
2015-04-10  0:34   ` Eric Dumazet
2015-04-10  8:48     ` Thomas Graf [this message]
2015-04-10  9:03       ` Eric Dumazet
2015-04-10  0:01 ` [PATCH 0/3 net-next] Bring sizeof(net_device) down to < 2K bytes Alexei Starovoitov
2015-04-10  8:41   ` Thomas Graf

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=20150410084816.GB23070@casper.infradead.org \
    --to=tgraf@suug.ch \
    --cc=davem@davemloft.net \
    --cc=eric.dumazet@gmail.com \
    --cc=intel-wired-lan@lists.osuosl.org \
    --cc=jeffrey.t.kirsher@intel.com \
    --cc=netdev@vger.kernel.org \
    /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 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).