netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kirill Tkhai <ktkhai@parallels.com>
To: David Miller <davem@davemloft.net>
Cc: <netdev@vger.kernel.org>, <edumazet@google.com>
Subject: Re: net: unix: Align send data_len up to PAGE_SIZE
Date: Thu, 15 May 2014 12:54:40 +0400	[thread overview]
Message-ID: <1400144080.3782.23.camel@tkhai> (raw)
In-Reply-To: <20140514.151504.1740922429122469259.davem@davemloft.net>

В Ср, 14/05/2014 в 15:15 -0400, David Miller пишет:
> From: Kirill Tkhai <ktkhai@parallels.com>
> Date: Mon, 12 May 2014 18:52:12 +0400
> 
> >  		data_len = min_t(size_t,
> >  				 len - SKB_MAX_ALLOC,
> >  				 MAX_SKB_FRAGS * PAGE_SIZE);
> > +		data_len = min_t(size_t,
> > +				 len,
> > +				 PAGE_ALIGN(data_len));
> > +	}
> 
> When I see:
> 
> 		x = min(y - N, z1);
> 		x = min(y, z2);
> 
> I'm a bit suspicious.  Why are you not subtracting the constant
> factor out of the first variable in the second min() call?

Because, in the most cases (len - SKB_MAX_ALLOC) < PAGE_ALIGN(data_len),
and the only payload of the patch is it tries to fix that :)
We use unused space of allocated page. For mem cache it's easier
to allocate

(len - PAGE_ALIGN(x)) than (len - x).


Here really should be 

 		data_len = min_t(size_t,
 				 len - SKB_MAX_ALLOC,
 				 MAX_SKB_FRAGS * PAGE_SIZE);
+		data_len = PAGE_ALIGN(data_len));


I added the second min, because I was afraid somebody plays with
SKB_MAX_ALLOC size in debug purposes. Not sure now.

Ok, yes, simple PAGE_ALIGN is much better :)

+ data_len = PAGE_ALIGN(data_len));

And I assumed it's OK to allocate skbs with zero header size like this:

sock_alloc_send_pskb(sk, 0, data_len)

Please say, if it's wrong.

Thanks!
Kirill

  reply	other threads:[~2014-05-15  8:54 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-12 14:52 net: unix: Align send data_len up to PAGE_SIZE Kirill Tkhai
2014-05-14 19:15 ` David Miller
2014-05-15  8:54   ` Kirill Tkhai [this message]
2014-05-15 13:27     ` Eric Dumazet
2014-05-15 14:27       ` Kirill Tkhai
2014-05-15 15:41         ` Eric Dumazet

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=1400144080.3782.23.camel@tkhai \
    --to=ktkhai@parallels.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.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).