From: David Daney <ddaney.cavm@gmail.com>
To: "H. Peter Anvin" <hpa@zytor.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
Borislav Petkov <bp@amd64.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Ingo Molnar <mingo@kernel.org>,
Thomas Gleixner <tglx@linutronix.de>,
David Daney <ddaney@caviumnetworks.com>
Subject: Re: [PATCH 3/3] x86, extable: Handle early exceptions
Date: Thu, 19 Apr 2012 13:17:14 -0700 [thread overview]
Message-ID: <4F9072CA.6030903@gmail.com> (raw)
In-Reply-To: <9ff2e09c-57e4-455e-8614-1b3b17b652f4@email.android.com>
On 04/19/2012 11:55 AM, H. Peter Anvin wrote:
> Either way I suggest picking up David's presorting patchset since it is already done and use its infrastructure for any further improvements.
>
It does have the advantage of already being implemented. There was a
little feedback on the kbuild portions of the patch.
If you would like, I will send an updated version of the patch.
> As far as a linear probe you get an average of n lookups with a packing density of 1-1/n so you are right; a linear probe with a density of say 1/2 is probably best.
>
I usually see exception table sizes on the order of 2^10 entries, so I
have to wonder how much you really gain from an O(1) implementation.
David Daney
> Linus Torvalds<torvalds@linux-foundation.org> wrote:
>
>> On Thu, Apr 19, 2012 at 10:59 AM, H. Peter Anvin<hpa@zytor.com> wrote:
>>>
>>> I would argue that the O(1) hash makes things simpler as there is no
>>> need to deal with collisions at all.
>>
>> Most of the O(1) hashes I have seen more than made up for the trivial
>> complexity of a few linear lookups by making the hash function way
>> more complicated.
>>
>> A linear probe with a step of one really is pretty simple. Sure, you
>> might want to make the initial hash "good enough" to not often hit the
>> probing code, but doing a few linear probes is cheap.
>>
>> In contrast, the perfect linear hashes do crazy things like having
>> table lookups *JUST TO COMPUTE THE HASH*.
>>
>> Which is f*cking stupid, really. They'll miss in the cache just at
>> hash compute time, never mind at hash lookup. The table-driven
>> versions look beautiful in microbenchmarks that have the tables in the
>> L1 cache, but for something like the exception handling, I can
>> guarantee that *nothing* is in L1, and probably not even L2.
>>
>> So what you want is:
>> - no table lookups for hashing
>> - simple code (ie a normal "a multiply and a shift/mask or two") to
>> keep the I$ footprint down too
>> - you *will* take a cache miss on the actual hash table lookup, that
>> cannot be avoided, but linear probing at least hopefully keeps it to
>> that single cache miss even if you have to do a probe or two.
>>
>> Remember: this is very much a "cold-cache behavior matters" case. We
>> would never ever call this in a loop, at most we have loads that get a
>> fair amount of exceptions (but will go through the exception code, so
>> the L1 is probably blown even then).
>>
>> Linus
>
next prev parent reply other threads:[~2012-04-19 20:17 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-19 0:16 [PATCH 0/5] RFC: x86: Early exception table support H. Peter Anvin
2012-04-19 0:16 ` [PATCH 1/5] x86, nop: Make the ASM_NOP* macros work from assembly H. Peter Anvin
2012-04-19 9:29 ` Borislav Petkov
2012-04-20 0:24 ` [tip:x86/extable] " tip-bot for H. Peter Anvin
2012-04-19 0:16 ` [PATCH 2/5] x86: Add symbolic constant for exceptions with error code H. Peter Anvin
2012-04-19 9:30 ` Borislav Petkov
2012-04-20 0:25 ` [tip:x86/extable] " tip-bot for H. Peter Anvin
2012-04-19 0:16 ` [PATCH 3/5] x86, paravirt: Replace GET_CR2_INTO_RCX with GET_CR2_INTO_RAX H. Peter Anvin
2012-04-20 0:26 ` [tip:x86/extable] " tip-bot for H. Peter Anvin
2012-04-19 0:16 ` [PATCH 4/5] x86-64: Handle exception table entries during early boot H. Peter Anvin
2012-04-19 13:02 ` Borislav Petkov
2012-04-19 16:59 ` H. Peter Anvin
2012-04-19 17:16 ` Borislav Petkov
2012-04-20 0:29 ` [tip:x86/extable] x86, doc: Revert "x86: Document rdmsr_safe restrictions" tip-bot for H. Peter Anvin
2012-04-20 0:28 ` [tip:x86/extable] x86-64: Handle exception table entries during early boot tip-bot for H. Peter Anvin
2012-04-19 0:16 ` [PATCH 5/5] x86-32: " H. Peter Anvin
2012-04-20 0:28 ` [tip:x86/extable] " tip-bot for H. Peter Anvin
2012-04-19 9:22 ` [PATCH 0/5] RFC: x86: Early exception table support Borislav Petkov
2012-04-19 9:24 ` [PATCH 1/3] x86, extable: Cleanup fixup_exception Borislav Petkov
2012-04-19 9:25 ` [PATCH 2/3] x86, extable: Carve out the main extable searching routine Borislav Petkov
2012-04-19 9:26 ` [PATCH 3/3] x86, extable: Handle early exceptions Borislav Petkov
2012-04-19 17:02 ` H. Peter Anvin
2012-04-19 17:27 ` Linus Torvalds
2012-04-19 17:38 ` Borislav Petkov
2012-04-19 17:59 ` H. Peter Anvin
2012-04-19 18:25 ` Linus Torvalds
2012-04-19 18:55 ` H. Peter Anvin
2012-04-19 20:17 ` David Daney [this message]
2012-04-19 20:20 ` H. Peter Anvin
2012-04-19 20:26 ` H. Peter Anvin
2012-04-19 20:40 ` David Daney
2012-04-19 21:47 ` Linus Torvalds
2012-04-19 22:16 ` H. Peter Anvin
2012-04-19 22:47 ` Tony Luck
2012-04-19 22:58 ` Linus Torvalds
2012-04-19 23:10 ` H. Peter Anvin
2012-04-19 23:26 ` Tony Luck
2012-04-19 23:35 ` H. Peter Anvin
2012-04-20 8:26 ` Andreas Schwab
2012-04-19 18:11 ` Linus Torvalds
2012-04-20 8:46 ` Borislav Petkov
2012-04-19 17:54 ` H. Peter Anvin
2012-04-20 0:27 ` [tip:x86/extable] x86, extable: Add early_fixup_exception() tip-bot for H. Peter Anvin
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=4F9072CA.6030903@gmail.com \
--to=ddaney.cavm@gmail.com \
--cc=bp@amd64.org \
--cc=ddaney@caviumnetworks.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.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.