From: Ingo Molnar <mingo@elte.hu>
To: Gautham R Shenoy <ego@in.ibm.com>
Cc: rusty@rustcorp.com.au, torvalds@osdl.org, akpm@osdl.org,
linux-kernel@vger.kernel.org, arjan@linux.intel.com,
davej@redhat.com, vatsa@in.ibm.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 14:25:27 +0200 [thread overview]
Message-ID: <20060824122527.GA28275@elte.hu> (raw)
In-Reply-To: <20060824122808.GH2395@in.ibm.com>
* Gautham R Shenoy <ego@in.ibm.com> wrote:
> This was the approach I tried to make it cache friendly.
> These are the problems I faced.
>
> - Reader checks the write_active flag. If set, he waits in the global read
> queue. else, he gets the lock and increments percpu refcount.
>
> - the writer would have to check each cpu's read refcount, and ensure that
> read refcount =0 on all of them before he sets write_active and
> begins a write operation.
> This will create a big race window - a writer is checking
> for a refcount on cpu(j), a reader comes on cpu(i) where i<j;
> Let's assume the writer checks refcounts in increasing order of cpus.
> Should the reader on cpu(i) wait or go ahead? If we use a global
> lock to serialize this operation, we the whole purpose of maintaining
> per cpu data is lost.
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?
(the 'write_active' flag is probably best implemented as a mutex, where
readers check mutex_is_locked(), and writers try to take it.)
Ingo
next prev parent reply other threads:[~2006-08-24 12:32 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-08-24 10:32 [RFC][PATCH 3/4] (Refcount + Waitqueue) implementation for cpu_hotplug "locking" 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 [this message]
2006-08-24 12:58 ` Srivatsa Vaddagiri
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=20060824122527.GA28275@elte.hu \
--to=mingo@elte.hu \
--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=rusty@rustcorp.com.au \
--cc=torvalds@osdl.org \
--cc=vatsa@in.ibm.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.