lkml.org 
[lkml]   [2001]   [Nov]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    From
    SubjectRe: Using %cr2 to reference "current"
    Date
    Followup to:  <20011106134234.A27718@redhat.com>
    By author: Benjamin LaHaise <bcrl@redhat.com>
    In newsgroup: linux.dev.kernel
    >
    > On Tue, Nov 06, 2001 at 09:49:15AM -0800, Linus Torvalds wrote:
    > > That said, how expensive is loading %cr2 anyway? We can do all the same
    > > tricks with a 16kB stack and just playing games with using the higher bits
    > > as the "offset", ie things like
    >
    > Here are some numbers:
    >
    > read cr2 best: 11 av: 11.12
    > write cr2 cr2 best: 61 av: 64.42
    > read cr2 best: 11 av: 11.12
    > write cr2 cr2 best: 61 av: 65.01
    > read stk best: 10 av: 11.03
    > write cr2 stk best: 61 av: 64.95
    > read stk best: 10 av: 11.03
    > write cr2 stk best: 61 av: 65.23
    >
    > Which come from insmod of the below two modules. I didn't test writing to
    > the stack register, but I expect it's similarly expensive as it affects the
    > call return stack and other behind the scenes dependancies. Suffice it to
    > say that reading %cr2 is essentially free on my box (athlon mp). Maybe
    > we should use it as a pointer into a per-cpu area to avoid writing it?
    >

    You still have to write it every time you take a page fault. You're
    adding 60-odd cycles to the page fault path at least.

    Not to mention any system which does microcoded reads of %cr2, which
    apparently the Athlon XP doesn't.

    -hpa
    --
    <hpa@transmeta.com> at work, <hpa@zytor.com> in private!
    "Unix gives you enough rope to shoot yourself in the foot."
    http://www.zytor.com/~hpa/puzzle.txt <amsp@zytor.com>
    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

    \
     
     \ /
      Last update: 2005-03-22 13:12    [W:3.531 / U:0.324 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site