From: Zoltan Menyhart <Zoltan.Menyhart@bull.net>
To: linux-ia64@vger.kernel.org
Subject: Re: test_and_set_bit implementation
Date: Thu, 14 Dec 2006 09:37:56 +0000 [thread overview]
Message-ID: <45811B74.2020405@bull.net> (raw)
In-Reply-To: <457EC42C.90002@bull.net>
Christoph Lameter wrote:
>>How much is the probability that the bit is not set?
> Depends on the load on the system. Typically very much near 100%
If you are right, why do we need "bit_spin_lock()" that much complicated?
while (test_and_set_bit(bitnum, addr)) {
while (test_bit(bitnum, addr)) {
preempt_enable();
cpu_relax();
preempt_disable();
}
}
If "test_and_set_bit()" did not modify the lock while it's busy, a
simpler solution would do:
while (test_and_set_bit(bitnum, addr)) {
preempt_enable();
cpu_relax();
preempt_disable();
}
>>Adding a test can cost only a few cycles, say max 4.
>
> But it reduces the performance of the commonly taken code path.
...
>>
>>By executing the atomic operation unconditionally, you kill
>>the cache line all the other waiting processors looping at.
>
> But note also that we optimize the common case, the case that the test and
> set bit are successful. Only if it was not successful will we do non
> atomic loads. This is done to avoid cachelines bouncing while the lock is
> contended.
I can accept these arguments for small, not too much busy systems.
As the snooping and the cache line bouncing costs increases quadratically
with the system size...
Have you got some lock benchmarks to measure it?
Thanks,
Zoltán Menyhárt
prev parent reply other threads:[~2006-12-14 9:37 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-12-12 15:01 test_and_set_bit implementation Zoltan Menyhart
2006-12-12 15:47 ` Matthew Wilcox
2006-12-12 17:20 ` Christoph Lameter
2006-12-12 17:22 ` Christoph Lameter
2006-12-12 18:07 ` Matthew Wilcox
2006-12-13 10:02 ` Zoltan Menyhart
2006-12-13 10:20 ` Zoltan Menyhart
2006-12-13 12:29 ` Matthew Wilcox
2006-12-13 18:28 ` Christoph Lameter
2006-12-14 9:24 ` Zoltan Menyhart
2006-12-14 9:37 ` Zoltan Menyhart [this message]
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=45811B74.2020405@bull.net \
--to=zoltan.menyhart@bull.net \
--cc=linux-ia64@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox