Re: [PATCH 4/6] locking/rwsem: Split out rwsem_reader_wake()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, 23 Feb 2023 13:26:46 +0100 Peter Zijlstra (Intel) <peterz@xxxxxxxxxxxxx>
> +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);
 }
 
 /*




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux