From: Ingo Molnar <mingo@elte.hu>
To: Zwane Mwaikambo <zwane@fsmlabs.com>
Cc: Linus Torvalds <torvalds@osdl.org>,
Paul Mackerras <paulus@samba.org>,
Linux Kernel <linux-kernel@vger.kernel.org>,
Andrew Morton <akpm@osdl.org>, Anton Blanchard <anton@samba.org>,
"Nakajima, Jun" <jun.nakajima@intel.com>, Andi Kleen <ak@suse.de>
Subject: Re: [PATCH] Yielding processor resources during lock contention
Date: Sun, 12 Sep 2004 09:49:04 +0200 [thread overview]
Message-ID: <20040912074904.GA7777@elte.hu> (raw)
In-Reply-To: <Pine.LNX.4.53.0409120009510.2297@montezuma.fsmlabs.com>
* Zwane Mwaikambo <zwane@fsmlabs.com> wrote:
> > Agreed, Paul we may as well remove the cpu_relax() in __preempt_spin_lock
> > and use something like "cpu_yield" (architectures not supporting it would
> > just call cpu_relax) i'll have something for you later.
>
> The following patch introduces cpu_lock_yield which allows
> architectures to possibly yield processor resources during lock
> contention. [...]
it is not clear from the Intel documentation how well MONITOR+MWAIT
works on SMP. It seems to be targeted towards hyperthreaded CPUs - where
i suspect it's much easier to monitor the stream of stores done to an
address.
on SMP MESI caches the question is, does MONITOR+MWAIT detect a
cacheline invalidate or even a natural cacheline flush? I doubt it does.
But without having the monitored cacheline in Modified state in the
sleeping CPU for sure it's fundamentally racy and it's not possible to
guarantee latencies: another CPU could have grabbed the cacheline and
could keep it dirty indefinitely. (it could itself go idle forever after
this point!)
the only safe way would be if MONITOR moved the cacheline into Exclusive
state and if it would watch that cacheline possibly going away (i.e.
another CPU unlocking the spinlock) after this point - in addition to
watching the stores of any HT sibling. But there is no description of
the SMP behavior in the Intel docs - and i truly suspect it would be
documented all over the place if it worked correctly on SMP... So i
think this is an HT-only instruction. (and in that limited context we
could indeed use it!)
one good thing to do would be to test the behavior and count cycles - it
is possible to set up the 'wrong' caching case that can potentially lead
to indefinite delays in mwait. If it turns out to work the expected way
then it would be nice to use. (The deep-sleep worries are not a too big
issue for latency-sensitive users as deep sleep can already occur via
the idle loop so it has to be turned off / tuned anyway.)
but unless the SMP case is guaranteed to work in a time-deterministic
way i dont think this patch can be added :-( It's not just the question
of high latencies, it's the question of fundamental correctness: with
large enough caches there is no guarantee that a CPU will _ever_ flush a
dirty cacheline to RAM.
Ingo
next prev parent reply other threads:[~2004-09-12 7:48 UTC|newest]
Thread overview: 50+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-09-03 0:02 [PATCH][5/8] Arch agnostic completely out of line locks / ppc64 Zwane Mwaikambo
2004-09-09 5:42 ` Paul Mackerras
2004-09-09 12:41 ` Zwane Mwaikambo
2004-09-09 14:54 ` Linus Torvalds
2004-09-09 14:55 ` Linus Torvalds
2004-09-09 15:32 ` Zwane Mwaikambo
2004-09-12 4:59 ` [PATCH] Yielding processor resources during lock contention Zwane Mwaikambo
2004-09-12 5:00 ` Andrew Morton
2004-09-12 5:10 ` Anton Blanchard
2004-09-12 5:13 ` Zwane Mwaikambo
2004-09-12 4:32 ` Nick Piggin
2004-09-12 5:33 ` Zwane Mwaikambo
2004-09-12 4:46 ` Nick Piggin
2004-09-12 5:51 ` Zwane Mwaikambo
2004-09-12 5:02 ` Nick Piggin
2004-09-12 6:09 ` Anton Blanchard
2004-09-12 6:58 ` William Lee Irwin III
2004-09-12 5:18 ` Andrew Morton
2004-09-12 5:10 ` Linus Torvalds
2004-09-12 5:27 ` Zwane Mwaikambo
2004-09-13 12:21 ` [PATCH] Yielding processor resources during lock contention #2 Zwane Mwaikambo
2004-09-12 7:49 ` Ingo Molnar [this message]
2004-09-12 16:10 ` [PATCH] Yielding processor resources during lock contention Zwane Mwaikambo
2004-09-12 19:34 ` Ingo Molnar
2004-09-12 10:10 ` Arnd Bergmann
2004-09-12 10:43 ` Anton Blanchard
2004-09-12 11:12 ` Arnd Bergmann
2004-09-09 15:43 ` [PATCH][5/8] Arch agnostic completely out of line locks / ppc64 Anton Blanchard
2004-09-09 17:19 ` William Lee Irwin III
2004-09-09 21:38 ` Paul Mackerras
2004-09-09 22:00 ` William Lee Irwin III
2004-09-09 23:36 ` Paul Mackerras
2004-09-10 0:09 ` William Lee Irwin III
2004-09-10 0:21 ` Linus Torvalds
2004-09-10 0:35 ` Anton Blanchard
2004-09-10 0:54 ` Linus Torvalds
2004-09-10 1:42 ` Anton Blanchard
2004-09-10 1:50 ` Anton Blanchard
2004-09-10 2:22 ` William Lee Irwin III
2004-09-10 2:32 ` William Lee Irwin III
2004-09-10 2:37 ` William Lee Irwin III
2004-09-10 3:24 ` Anton Blanchard
2004-09-10 7:40 ` Ingo Molnar
2004-09-10 12:16 ` William Lee Irwin III
2004-09-10 12:22 ` Ingo Molnar
2004-09-10 3:23 ` Anton Blanchard
2004-09-10 7:56 ` Anton Blanchard
-- strict thread matches above, loose matches on Subject: below --
2004-09-13 0:45 [PATCH] Yielding processor resources during lock contention Nakajima, Jun
2004-09-13 1:35 Nakajima, Jun
2004-09-13 6:35 ` Ingo Molnar
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=20040912074904.GA7777@elte.hu \
--to=mingo@elte.hu \
--cc=ak@suse.de \
--cc=akpm@osdl.org \
--cc=anton@samba.org \
--cc=jun.nakajima@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=paulus@samba.org \
--cc=torvalds@osdl.org \
--cc=zwane@fsmlabs.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox