linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Hillf Danton <hdanton@sina.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: longman@redhat.com, mingo@redhat.com, will@kernel.org,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org,
	boqun.feng@gmail.com
Subject: Re: [PATCH 4/6] locking/rwsem: Split out rwsem_reader_wake()
Date: Sat, 25 Feb 2023 18:15:17 +0800	[thread overview]
Message-ID: <20230225101517.3227-1-hdanton@sina.com> (raw)
In-Reply-To: <20230223123319.548254615@infradead.org>

On Thu, 23 Feb 2023 13:26:46 +0100 Peter Zijlstra (Intel) <peterz@infradead.org>
> +static void rwsem_mark_wake(struct rw_semaphore *sem,
> +			    enum rwsem_wake_type wake_type,
> +			    struct wake_q_head *wake_q)
> +{
> +	struct rwsem_waiter *waiter;
> +
> +	lockdep_assert_held(&sem->wait_lock);
> +
> +	/*
> +	 * Take a peek at the queue head waiter such that we can determine
> +	 * the wakeup(s) to perform.
> +	 */
> +	waiter = rwsem_first_waiter(sem);
> +
> +	if (waiter->type == RWSEM_WAITING_FOR_WRITE) {
> +		if (wake_type == RWSEM_WAKE_ANY)
> +			rwsem_writer_wake(sem, waiter, wake_q);
> +	} else {
> +		rwsem_reader_wake(sem, wake_type, waiter, wake_q);
> +	}
> +}

Hm... missing wakeup, and feel free to pick up the diff below if it
makes sense to you.

+++ b/kernel/locking/rwsem.c
@@ -661,12 +661,13 @@ static void rwsem_mark_wake(struct rw_se
 	 */
 	waiter = rwsem_first_waiter(sem);
 
-	if (waiter->type == RWSEM_WAITING_FOR_WRITE) {
-		if (wake_type == RWSEM_WAKE_ANY)
+	if (waiter->type == RWSEM_WAITING_FOR_WRITE)
+		if (wake_type == RWSEM_WAKE_ANY) {
 			rwsem_writer_wake(sem, waiter, wake_q);
-	} else {
-		rwsem_reader_wake(sem, wake_type, waiter, wake_q);
-	}
+			return;
+		}
+
+	rwsem_reader_wake(sem, wake_type, waiter, wake_q);
 }
 
 /*


      parent reply	other threads:[~2023-02-25 10:15 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20230223122642.491637862@infradead.org>
     [not found] ` <20230223123319.487908155@infradead.org>
2023-02-24 10:11   ` [PATCH 3/6] locking/rwsem: Rework writer wakeup Hillf Danton
     [not found] ` <20230223123319.548254615@infradead.org>
2023-02-25 10:15   ` Hillf Danton [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=20230225101517.3227-1-hdanton@sina.com \
    --to=hdanton@sina.com \
    --cc=boqun.feng@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=longman@redhat.com \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=will@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