[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <48A46EC2.1010301@goop.org>
Date: Thu, 14 Aug 2008 10:43:30 -0700
From: Jeremy Fitzhardinge <jeremy@...p.org>
To: Mathieu Desnoyers <mathieu.desnoyers@...ymtl.ca>
CC: "H. Peter Anvin" <hpa@...or.com>, Andi Kleen <andi@...stfloor.org>,
Linus Torvalds <torvalds@...ux-foundation.org>,
Ingo Molnar <mingo@...e.hu>,
Steven Rostedt <rostedt@...dmis.org>,
Steven Rostedt <srostedt@...hat.com>,
LKML <linux-kernel@...r.kernel.org>,
Thomas Gleixner <tglx@...utronix.de>,
Peter Zijlstra <peterz@...radead.org>,
Andrew Morton <akpm@...ux-foundation.org>,
David Miller <davem@...emloft.net>,
Roland McGrath <roland@...hat.com>,
Ulrich Drepper <drepper@...hat.com>,
Rusty Russell <rusty@...tcorp.com.au>,
Gregory Haskins <ghaskins@...ell.com>,
Arnaldo Carvalho de Melo <acme@...hat.com>,
"Luis Claudio R. Goncalves" <lclaudio@...g.org>,
Clark Williams <williams@...hat.com>,
Christoph Lameter <cl@...ux-foundation.org>
Subject: Re: [RFC PATCH] x86 alternatives : fix LOCK_PREFIX race with preemptible
kernel and CPU hotplug
Mathieu Desnoyers wrote:
> * Jeremy Fitzhardinge (jeremy@...p.org) wrote:
>
>> Mathieu Desnoyers wrote:
>>
>>> * H. Peter Anvin (hpa@...or.com) wrote:
>>>
>>>
>>>> Mathieu Desnoyers wrote:
>>>>
>>>>
>>>>> I can't argue about the benefit of using VM CPU pinning to manage
>>>>> resources because I don't use it myself, but I ran some tests out of
>>>>> curiosity to find if uncontended locks were that cheap, and it turns out
>>>>> they aren't. Here are the results :
>>>>> Xeon 2.0GHz
>>>>> Summary
>>>>> make -j1 kernel/ 33.94 +/- 0.07 34.91 +/- 0.27 2.8 %
>>>>> hackbench 50 2.99 +/- 0.01 3.74 +/- 0.01 25.1 %
>>>>> 1 CPU, replace smp lock prefixes with DS segment selector prefixes
>>>>> 1 CPU, noreplace-smp
>>>>>
>>>>>
>>>> For reference, could you also compare replace smp lock with NOPs?
>>>>
>>>> -hpa
>>>>
>>>>
>>> Sure, here are the updated tables. Basically, they show no significant
>>> difference between the NOP and the DS segment selector prefix
>>> approaches.
>>>
>>>
>> BTW, are you changing the initial prefix to DS too? Ie, are you doing a
>> nop->lock->ds transition, or ds->lock->ds?
>>
>> J
>>
>
> Yeah, I thought about this case yesterday, good thing you ask.
>
> include/asm-x86/alternative.h defines LOCK_PREFIX as :
>
> #define LOCK_PREFIX \
> ".section .smp_locks,\"a\"\n" \
> _ASM_ALIGN "\n" \
> _ASM_PTR "661f\n" /* address */ \
> ".previous\n" \
> "661:\n\tlock; "
>
> So we have the locked instructions built into the kernel, not the nop'd
> one. Therefore, the only transition I am doing for my benchmarks is :
>
> lock->ds
>
> but I tried to switch back to SMP and it worked fine.
>
Ah, OK. I'd thought we started unlocked, but given that I've just been
disassembling the kernel and looking at the lock prefixes, that's a bit
of a braino on my part.
BTW, using the ds prefix allows us to undo the hack of dealing with
locked instructions with exception handlers. There was a bug where if
we do lock->nop, then the address of a faulting instruction changes, so
we need exception records for both the locked and unlocked forms. Using
ds means the instruction size doesn't change, so we only need one
exception record. I don't remember off hand where that happens.
J
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists