From: Clemens Ladisch <clemens@ladisch.de>
To: "Chen, Dennis (SRDC SW)" <Dennis1.Chen@amd.com>
Cc: Ingo Molnar <mingo@kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: semaphore and mutex in current Linux kernel (3.2.2)
Date: Fri, 06 Apr 2012 12:10:25 +0200 [thread overview]
Message-ID: <4F7EC111.4010608@ladisch.de> (raw)
In-Reply-To: <491D6B4EAD0A714894D8AD22F4BDE0439F9E45@SCYBEXDAG02.amd.com>
Chen, Dennis (SRDC SW) wrote:
> On Thu, Apr 5, 2012 at 10:15 PM, Clemens Ladisch <clemens@ladisch.de> wrote:
>> It would not make sense to spin too long, especially if some other
>> process wants to run on the same CPU.
>>
>>> int mutex_spin_on_owner(struct mutex *lock, struct task_struct *owner)
>>> {
>>> ...
>>> while (owner_running(lock, owner)) {
>>> if (need_resched())
>>> break;
>>>
>>> arch_mutex_cpu_relax();
>>> }
>>> ...
>>> }
>>>
>>> D+ means the App in CPU1 is sleeping in a UNINTERRUPTIBLE state. This is very interesting,
>>> How does this happen?
>>
>> Your experiment shows that there must be some condition that makes the
>> code break out of the spin loop ...
>
> I guess this is related with RCU component, but I don't found the right place where the code
> Located yet.
"On the internet, nobody can hear you being subtle."
If some other process wants to run on the same CPU, needs_resched() is set.
(This might happen to make the cursor blink, for keyboard input, or when
somebody starts a rogue process like ps.)
Regards,
Clemens
next prev parent reply other threads:[~2012-04-06 10:10 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-01 9:56 Chen, Dennis (SRDC SW)
2012-04-01 12:19 ` Ingo Molnar
2012-04-02 15:28 ` Chen, Dennis (SRDC SW)
2012-04-03 7:52 ` Ingo Molnar
2012-04-05 8:37 ` Chen, Dennis (SRDC SW)
2012-04-05 14:15 ` Clemens Ladisch
2012-04-06 9:45 ` Chen, Dennis (SRDC SW)
2012-04-06 10:10 ` Clemens Ladisch [this message]
2012-04-06 17:47 ` Chen, Dennis (SRDC SW)
2012-04-09 18:45 ` Paul E. McKenney
2012-04-11 5:04 ` Chen, Dennis (SRDC SW)
2012-04-11 17:30 ` Paul E. McKenney
2012-04-12 9:42 ` Chen, Dennis (SRDC SW)
2012-04-12 15:18 ` Paul E. McKenney
2012-04-13 14:15 ` Chen, Dennis (SRDC SW)
2012-04-13 18:43 ` Paul E. McKenney
2012-04-16 8:33 ` [PATCH 0/2] tools perf: Add a new benchmark tool for semaphore/mutex Chen, Dennis (SRDC SW)
2012-04-16 9:24 ` Ingo Molnar
2012-04-16 14:10 ` Chen, Dennis (SRDC SW)
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=4F7EC111.4010608@ladisch.de \
--to=clemens@ladisch.de \
--cc=Dennis1.Chen@amd.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@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
Powered by JetHome