Commit d00b83d4 authored by Waiman Long's avatar Waiman Long Committed by Peter Zijlstra

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: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: default avatarWaiman Long <longman@redhat.com>
Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Tested-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20240909182905.161156-1-longman@redhat.com
parent 39dea484
...@@ -181,12 +181,21 @@ static inline void rwsem_set_reader_owned(struct rw_semaphore *sem) ...@@ -181,12 +181,21 @@ static inline void rwsem_set_reader_owned(struct rw_semaphore *sem)
__rwsem_set_reader_owned(sem, current); __rwsem_set_reader_owned(sem, current);
} }
#ifdef CONFIG_DEBUG_RWSEMS
/*
* Return just the real task structure pointer of the owner
*/
static inline struct task_struct *rwsem_owner(struct rw_semaphore *sem)
{
return (struct task_struct *)
(atomic_long_read(&sem->owner) & ~RWSEM_OWNER_FLAGS_MASK);
}
/* /*
* Return true if the rwsem is owned by a reader. * Return true if the rwsem is owned by a reader.
*/ */
static inline bool is_rwsem_reader_owned(struct rw_semaphore *sem) static inline bool is_rwsem_reader_owned(struct rw_semaphore *sem)
{ {
#ifdef CONFIG_DEBUG_RWSEMS
/* /*
* Check the count to see if it is write-locked. * Check the count to see if it is write-locked.
*/ */
...@@ -194,11 +203,9 @@ static inline bool is_rwsem_reader_owned(struct rw_semaphore *sem) ...@@ -194,11 +203,9 @@ static inline bool is_rwsem_reader_owned(struct rw_semaphore *sem)
if (count & RWSEM_WRITER_MASK) if (count & RWSEM_WRITER_MASK)
return false; return false;
#endif
return rwsem_test_oflags(sem, RWSEM_READER_OWNED); return rwsem_test_oflags(sem, RWSEM_READER_OWNED);
} }
#ifdef CONFIG_DEBUG_RWSEMS
/* /*
* With CONFIG_DEBUG_RWSEMS configured, it will make sure that if there * With CONFIG_DEBUG_RWSEMS configured, it will make sure that if there
* is a task pointer in owner of a reader-owned rwsem, it will be the * 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) ...@@ -265,15 +272,6 @@ static inline bool rwsem_write_trylock(struct rw_semaphore *sem)
return false; return false;
} }
/*
* Return just the real task structure pointer of the owner
*/
static inline struct task_struct *rwsem_owner(struct rw_semaphore *sem)
{
return (struct task_struct *)
(atomic_long_read(&sem->owner) & ~RWSEM_OWNER_FLAGS_MASK);
}
/* /*
* Return the real task structure pointer of the owner and the embedded * Return the real task structure pointer of the owner and the embedded
* flags in the owner. pflags must be non-NULL. * flags in the owner. pflags must be non-NULL.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment