From: Hillf Danton <dhillf@gmail.com>
To: Michel Lespinasse <walken@google.com>
Cc: linux-kernel@vger.kernel.org, anton@samba.org, hpa@zytor.com,
mingo@kernel.org, arjan@linux.intel.com, a.p.zijlstra@chello.nl,
torvalds@linux-foundation.org, alex.shi@intel.com,
yuanhan.liu@linux.intel.com, dhowells@redhat.com,
akpm@linux-foundation.org
Subject: Re: [PATCH 3/4] rwsem: implement write lock stealing
Date: Sat, 9 Feb 2013 21:11:25 +0800 [thread overview]
Message-ID: <CAJd=RBB2Hcn7mAdAXF-K7sM=5pxpd8sre6rEJExC79LUO3iEbA@mail.gmail.com> (raw)
In-Reply-To: <CANN689F-Gbh56bDFDMSogxsYtUTTqObxyFTzvrz_somvWh-CUw@mail.gmail.com>
On Sat, Feb 9, 2013 at 3:42 PM, Michel Lespinasse <walken@google.com> wrote:
> On Fri, Feb 8, 2013 at 11:30 PM, Hillf Danton <dhillf@gmail.com> wrote:
>> On Sat, Feb 9, 2013 at 10:45 AM, Michel Lespinasse <walken@google.com> wrote:
>>> + if (waiter->type != RWSEM_WAITING_FOR_WRITE) {
>>> + list_del(&waiter->list);
>>> +
>>> + /* Set RWSEM_WAITING_BIAS before waking the last reader
>>> + * so we know there will be a remaining active locker.
>>> + */
>>> + if (!(--readers) && !list_empty(&sem->wait_list))
>>> + rwsem_atomic_add(RWSEM_WAITING_BIAS, sem);
>>> +
>>> + tsk = waiter->task;
>>> + smp_mb();
>>
>> For what with mb?
>
> This is the same mb that used to be before the readers_only label
> before this change.
> The intention is that the write to waiter->task must be the last
> access to waiter - after that, the reader is granted the lock so it
> could do anything, including deallocating the waiter structure as it
> gets out of rwsem_down_read_failed() and possibly deallocating the
> task structure if it exits
>
Perhaps the waiting process needs to see if no more wait needed,
/* wait to be given the lock */
for (;;) {
if (!waiter.task)
break;
schedule();
set_task_state(tsk, TASK_UNINTERRUPTIBLE);
}
and another mb do exist at the beginning of try_to_wake_up().
And I want to change
+ /* Block until there are no active lockers. */
+ do {
+ schedule();
+ set_task_state(tsk, TASK_UNINTERRUPTIBLE);
+ } while (sem->count & RWSEM_ACTIVE_MASK);
to
/* Block until there are no active lockers. */
while (sem->count & RWSEM_ACTIVE_MASK) {
schedule();
set_task_state(tsk, TASK_UNINTERRUPTIBLE);
}
for sure that we have to wait.
next prev parent reply other threads:[~2013-02-09 13:11 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-09 2:45 [PATCH 0/4] rwsem: Implement writer lock-stealing Michel Lespinasse
2013-02-09 2:45 ` [PATCH 1/4] rwsem: make the waiter type an enumeration rather than a bitmask Michel Lespinasse
2013-02-09 2:45 ` [PATCH 2/4] rwsem: shorter spinlocked section in rwsem_down_failed_common() Michel Lespinasse
2013-02-09 2:45 ` [PATCH 3/4] rwsem: implement write lock stealing Michel Lespinasse
2013-02-09 7:30 ` Hillf Danton
2013-02-09 7:42 ` Michel Lespinasse
2013-02-09 13:11 ` Hillf Danton [this message]
2013-02-09 2:45 ` [PATCH 4/4] x86 rwsem: avoid taking slow path when stealing write lock Michel Lespinasse
2013-02-13 13:55 ` [PATCH 0/4] rwsem: Implement writer lock-stealing Alex Shi
2013-02-13 14:49 ` Ingo Molnar
2013-02-14 1:31 ` Michel Lespinasse
2013-02-14 12:08 ` Alex Shi
2013-02-20 8:50 ` Alex Shi
2013-02-20 10:40 ` Ingo Molnar
2013-02-20 16:50 ` Michel Lespinasse
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='CAJd=RBB2Hcn7mAdAXF-K7sM=5pxpd8sre6rEJExC79LUO3iEbA@mail.gmail.com' \
--to=dhillf@gmail.com \
--cc=a.p.zijlstra@chello.nl \
--cc=akpm@linux-foundation.org \
--cc=alex.shi@intel.com \
--cc=anton@samba.org \
--cc=arjan@linux.intel.com \
--cc=dhowells@redhat.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=torvalds@linux-foundation.org \
--cc=walken@google.com \
--cc=yuanhan.liu@linux.intel.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;
as well as URLs for NNTP newsgroup(s).