From: ebiederm@xmission.com (Eric W. Biederman)
To: Eric Dumazet <eric.dumazet@gmail.com>
Cc: David Miller <davem@davemloft.net>,
alexander.duyck@gmail.com, netdev@vger.kernel.org
Subject: Re: [PATCH 00/16] Remove the ipv4 routing cache
Date: Fri, 27 Jul 2012 09:23:18 -0700 [thread overview]
Message-ID: <87mx2l41hl.fsf@xmission.com> (raw)
In-Reply-To: <1343401949.2626.13011.camel@edumazet-glaptop> (Eric Dumazet's message of "Fri, 27 Jul 2012 17:12:29 +0200")
Eric Dumazet <eric.dumazet@gmail.com> writes:
> On Fri, 2012-07-27 at 07:53 -0700, Eric W. Biederman wrote:
>> Eric Dumazet <eric.dumazet@gmail.com> writes:
>>
>> > Now IP route cache is removed, we should make sure fib structures
>> > cant share cache lines with possibly often dirtied objects.
>> >
>> > On x86, kmalloc-96 cache can be source of such problems.
>> >
>> > Signed-off-by: Eric Dumazet <edumazet@google.com>
>>
>>
>> > +static inline void *fib_zalloc(size_t size)
>> > +{
>> > + /* We want to avoid possible false sharing */
>> > + return kzalloc(max_t(size_t, 128, size), GFP_KERNEL);
>>
>> Why the hard coded 128 here?
>>
>> It seems more portable and obvious to do
>> return kzalloc(round_up(size, L1_CACHE_BYTES), GFP_KERNEL);
>>
>
> Its not that obvious, because some machines have an apparent
> L1_CACHE_BYTES of 64, but hardware prefetching to 128 bytes
I am familiar. But does hardware prefetching make a difference
if your object is less than 64 bytes?
I don't believe only allocating 64 bytes will be a problem,
as no one else well be dirtying your cache line.
I suppose you could run into pathologies where your object
is 3*64 bytes in size, but your expression doesn't handle
that case either.
> But using 2*L1_CACHE_BYTES as minimum allocation size might be overkill
> on some arches with 256 bytes cache lines.
The other alternative to guarantee very good cache behavior is
to ensure you are allocating a power of two size up to some limit,
perhaps page size.
My point is the magic 128 likely requires an explicatory comment and I
think the net result is you have encoded something fragile that is good
for testing but that will in the fullness of time do strange things that
will be easy to overlook.
Eric
next prev parent reply other threads:[~2012-07-27 16:23 UTC|newest]
Thread overview: 51+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-20 21:25 [PATCH 00/16] Remove the ipv4 routing cache David Miller
2012-07-20 22:05 ` Eric Dumazet
2012-07-20 22:42 ` Eric Dumazet
2012-07-20 22:50 ` David Miller
2012-07-20 22:54 ` David Miller
2012-07-20 23:13 ` David Miller
2012-07-21 5:40 ` Eric Dumazet
2012-07-22 7:47 ` Vijay Subramanian
2012-07-22 19:42 ` David Miller
2012-07-23 0:39 ` David Miller
2012-07-23 7:15 ` Eric Dumazet
2012-07-23 17:54 ` Paweł Staszewski
2012-07-23 20:10 ` David Miller
2012-07-26 17:02 ` Eric Dumazet
2012-07-25 23:02 ` Alexander Duyck
2012-07-25 23:17 ` David Miller
2012-07-25 23:39 ` David Miller
2012-07-26 0:54 ` David Miller
2012-07-26 2:30 ` Alexander Duyck
2012-07-26 5:32 ` David Miller
2012-07-26 8:13 ` Eric Dumazet
2012-07-26 8:18 ` David Miller
2012-07-26 8:27 ` Eric Dumazet
2012-07-26 8:47 ` David Miller
2012-07-26 9:12 ` Eric Dumazet
2012-07-26 17:18 ` Alexander Duyck
2012-07-26 17:30 ` Eric Dumazet
2012-07-26 17:36 ` Eric Dumazet
2012-07-26 17:43 ` Eric Dumazet
2012-07-26 17:48 ` Eric Dumazet
2012-07-26 18:26 ` Alexander Duyck
2012-07-26 21:06 ` David Miller
2012-07-26 22:03 ` Alexander Duyck
2012-07-26 22:13 ` Stephen Hemminger
2012-07-26 22:19 ` Eric Dumazet
2012-07-26 22:48 ` David Miller
2012-07-26 22:53 ` David Miller
2012-07-27 2:14 ` Alexander Duyck
2012-07-27 3:08 ` David Miller
2012-07-27 6:02 ` David Miller
2012-07-27 10:01 ` Eric Dumazet
2012-07-27 14:53 ` Eric W. Biederman
2012-07-27 15:12 ` Eric Dumazet
2012-07-27 16:23 ` Eric W. Biederman [this message]
2012-07-27 16:28 ` Eric Dumazet
2012-07-27 19:06 ` Alexander Duyck
2012-07-28 4:15 ` David Miller
2012-07-28 5:45 ` Alexander Duyck
2012-07-26 18:06 ` Alexander Duyck
2012-07-26 21:00 ` David Miller
2012-07-26 20:59 ` David Miller
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=87mx2l41hl.fsf@xmission.com \
--to=ebiederm@xmission.com \
--cc=alexander.duyck@gmail.com \
--cc=davem@davemloft.net \
--cc=eric.dumazet@gmail.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 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.