mirror of
				https://github.com/torvalds/linux.git
				synced 2025-10-31 08:38:45 +02:00 
			
		
		
		
	locking/rwsem: No need to check for handoff bit if wait queue empty
Since commit d257cc8cb8 ("locking/rwsem: Make handoff bit handling
more consistent"), the handoff bit is always cleared if the wait queue
becomes empty. There is no need to check for RWSEM_FLAG_HANDOFF when
the wait list is known to be empty.
Signed-off-by: Waiman Long <longman@redhat.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/20220322152059.2182333-2-longman@redhat.com
			
			
This commit is contained in:
		
							parent
							
								
									8b023accc8
								
							
						
					
					
						commit
						f9e21aa9e6
					
				
					 1 changed files with 4 additions and 5 deletions
				
			
		|  | @ -977,12 +977,11 @@ rwsem_down_read_slowpath(struct rw_semaphore *sem, long count, unsigned int stat | ||||||
| 	if (list_empty(&sem->wait_list)) { | 	if (list_empty(&sem->wait_list)) { | ||||||
| 		/*
 | 		/*
 | ||||||
| 		 * In case the wait queue is empty and the lock isn't owned | 		 * In case the wait queue is empty and the lock isn't owned | ||||||
| 		 * by a writer or has the handoff bit set, this reader can | 		 * by a writer, this reader can exit the slowpath and return | ||||||
| 		 * exit the slowpath and return immediately as its | 		 * immediately as its RWSEM_READER_BIAS has already been set | ||||||
| 		 * RWSEM_READER_BIAS has already been set in the count. | 		 * in the count. | ||||||
| 		 */ | 		 */ | ||||||
| 		if (!(atomic_long_read(&sem->count) & | 		if (!(atomic_long_read(&sem->count) & RWSEM_WRITER_MASK)) { | ||||||
| 		     (RWSEM_WRITER_MASK | RWSEM_FLAG_HANDOFF))) { |  | ||||||
| 			/* Provide lock ACQUIRE */ | 			/* Provide lock ACQUIRE */ | ||||||
| 			smp_acquire__after_ctrl_dep(); | 			smp_acquire__after_ctrl_dep(); | ||||||
| 			raw_spin_unlock_irq(&sem->wait_lock); | 			raw_spin_unlock_irq(&sem->wait_lock); | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue
	
	 Waiman Long
						Waiman Long