[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1400144080.3782.23.camel@tkhai>
Date: Thu, 15 May 2014 12:54:40 +0400
From: Kirill Tkhai <ktkhai@...allels.com>
To: David Miller <davem@...emloft.net>
CC: <netdev@...r.kernel.org>, <edumazet@...gle.com>
Subject: Re: net: unix: Align send data_len up to PAGE_SIZE
В Ср, 14/05/2014 в 15:15 -0400, David Miller пишет:
> From: Kirill Tkhai <ktkhai@...allels.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
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists