Skip to content

Commit d00b83d

Browse files
Waiman-LongPeter Zijlstra
authored andcommitted
locking/rwsem: Move is_rwsem_reader_owned() and rwsem_owner() under CONFIG_DEBUG_RWSEMS
Both is_rwsem_reader_owned() and rwsem_owner() are currently only used when CONFIG_DEBUG_RWSEMS is defined. This causes a compilation error with clang when `make W=1` and CONFIG_WERROR=y: kernel/locking/rwsem.c:187:20: error: unused function 'is_rwsem_reader_owned' [-Werror,-Wunused-function] 187 | static inline bool is_rwsem_reader_owned(struct rw_semaphore *sem) | ^~~~~~~~~~~~~~~~~~~~~ kernel/locking/rwsem.c:271:35: error: unused function 'rwsem_owner' [-Werror,-Wunused-function] 271 | static inline struct task_struct *rwsem_owner(struct rw_semaphore *sem) | ^~~~~~~~~~~ Fix this by moving these two functions under the CONFIG_DEBUG_RWSEMS define. Reported-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Waiman Long <longman@redhat.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Tested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://lore.kernel.org/r/20240909182905.161156-1-longman@redhat.com
1 parent 39dea48 commit d00b83d

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

kernel/locking/rwsem.c

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -181,24 +181,31 @@ static inline void rwsem_set_reader_owned(struct rw_semaphore *sem)
181181
__rwsem_set_reader_owned(sem, current);
182182
}
183183

184+
#ifdef CONFIG_DEBUG_RWSEMS
185+
/*
186+
* Return just the real task structure pointer of the owner
187+
*/
188+
static inline struct task_struct *rwsem_owner(struct rw_semaphore *sem)
189+
{
190+
return (struct task_struct *)
191+
(atomic_long_read(&sem->owner) & ~RWSEM_OWNER_FLAGS_MASK);
192+
}
193+
184194
/*
185195
* Return true if the rwsem is owned by a reader.
186196
*/
187197
static inline bool is_rwsem_reader_owned(struct rw_semaphore *sem)
188198
{
189-
#ifdef CONFIG_DEBUG_RWSEMS
190199
/*
191200
* Check the count to see if it is write-locked.
192201
*/
193202
long count = atomic_long_read(&sem->count);
194203

195204
if (count & RWSEM_WRITER_MASK)
196205
return false;
197-
#endif
198206
return rwsem_test_oflags(sem, RWSEM_READER_OWNED);
199207
}
200208

201-
#ifdef CONFIG_DEBUG_RWSEMS
202209
/*
203210
* With CONFIG_DEBUG_RWSEMS configured, it will make sure that if there
204211
* is a task pointer in owner of a reader-owned rwsem, it will be the
@@ -265,15 +272,6 @@ static inline bool rwsem_write_trylock(struct rw_semaphore *sem)
265272
return false;
266273
}
267274

268-
/*
269-
* Return just the real task structure pointer of the owner
270-
*/
271-
static inline struct task_struct *rwsem_owner(struct rw_semaphore *sem)
272-
{
273-
return (struct task_struct *)
274-
(atomic_long_read(&sem->owner) & ~RWSEM_OWNER_FLAGS_MASK);
275-
}
276-
277275
/*
278276
* Return the real task structure pointer of the owner and the embedded
279277
* flags in the owner. pflags must be non-NULL.

0 commit comments

Comments
 (0)