From: Srivatsa Vaddagiri <vatsa@in.ibm.com>
To: Ingo Molnar <mingo@elte.hu>
Cc: Gautham R Shenoy <ego@in.ibm.com>,
rusty@rustcorp.com.au, torvalds@osdl.org, akpm@osdl.org,
linux-kernel@vger.kernel.org, arjan@linux.intel.com,
davej@redhat.com, dipankar@in.ibm.com, ashok.raj@intel.com
Subject: Re: [RFC][PATCH 3/4] (Refcount + Waitqueue) implementation for cpu_hotplug "locking"
Date: Thu, 24 Aug 2006 18:28:14 +0530 [thread overview]
Message-ID: <20060824125813.GE25452@in.ibm.com> (raw)
In-Reply-To: <20060824122527.GA28275@elte.hu>
On Thu, Aug 24, 2006 at 02:25:27PM +0200, Ingo Molnar wrote:
> no. The writer first sets the global write_active flag, and _then_ goes
> on to wait for all readers (if any) to get out of their critical
> sections. (That's the purpose of the per-cpu waitqueue that readers use
> to wake up a writer waiting for the refcount to go to 0.)
>
> can you still see problems with this scheme?
This can cause a deadlock sometimes, when a thread tries to take the
read_lock() recursively, with a writer having come in between the two
recursive reads:
Reader1 on CPU0 Writer1 on CPU1
read_lock() - success
write_lock() - blocks on Reader1
(writer_active = 1)
read_lock() - blocks on Writer1
The only way to avoid this deadlock is to either keep track of
cpu_hp_lock_count per-task (like the preemption count kept per-task)
or allow read_lock() to succeed if reader_count > 1 (even if
writer_active = 1). The later makes the lock unduely biased towards
readers.
--
Regards,
vatsa
next prev parent reply other threads:[~2006-08-24 12:58 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-08-24 10:32 Gautham R Shenoy
2006-08-24 11:14 ` Ingo Molnar
2006-08-24 12:28 ` Gautham R Shenoy
2006-08-24 12:25 ` Ingo Molnar
2006-08-24 12:58 ` Srivatsa Vaddagiri [this message]
2006-08-25 6:04 ` Gautham R Shenoy
2006-08-25 6:19 ` Nick Piggin
2006-08-25 6:29 ` Srivatsa Vaddagiri
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=20060824125813.GE25452@in.ibm.com \
--to=vatsa@in.ibm.com \
--cc=akpm@osdl.org \
--cc=arjan@linux.intel.com \
--cc=ashok.raj@intel.com \
--cc=davej@redhat.com \
--cc=dipankar@in.ibm.com \
--cc=ego@in.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=rusty@rustcorp.com.au \
--cc=torvalds@osdl.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