* [PATCH] locking/rwsem: Move is_rwsem_reader_owned() and rwsem_owner() under CONFIG_DEBUG_RWSEMS
@ 2024-09-09 18:29 Waiman Long
2024-09-10 8:15 ` Andy Shevchenko
0 siblings, 1 reply; 6+ messages in thread
From: Waiman Long @ 2024-09-09 18:29 UTC (permalink / raw)
To: Peter Zijlstra, Ingo Molnar, Will Deacon, Boqun Feng
Cc: linux-kernel, llvm, Nathan Chancellor, Nick Desaulniers,
Bill Wendling, Justin Stitt, Andy Shevchenko, Waiman Long
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>
---
kernel/locking/rwsem.c | 22 ++++++++++------------
1 file changed, 10 insertions(+), 12 deletions(-)
diff --git a/kernel/locking/rwsem.c b/kernel/locking/rwsem.c
index 33cac79e3994..4b041e9c408f 100644
--- a/kernel/locking/rwsem.c
+++ b/kernel/locking/rwsem.c
@@ -181,12 +181,21 @@ static inline void rwsem_set_reader_owned(struct rw_semaphore *sem)
__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.
*/
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.
*/
@@ -194,11 +203,9 @@ static inline bool is_rwsem_reader_owned(struct rw_semaphore *sem)
if (count & RWSEM_WRITER_MASK)
return false;
-#endif
return rwsem_test_oflags(sem, RWSEM_READER_OWNED);
}
-#ifdef CONFIG_DEBUG_RWSEMS
/*
* 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
@@ -265,15 +272,6 @@ static inline bool rwsem_write_trylock(struct rw_semaphore *sem)
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
* flags in the owner. pflags must be non-NULL.
--
2.43.5
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [PATCH] locking/rwsem: Move is_rwsem_reader_owned() and rwsem_owner() under CONFIG_DEBUG_RWSEMS
2024-09-09 18:29 [PATCH] locking/rwsem: Move is_rwsem_reader_owned() and rwsem_owner() under CONFIG_DEBUG_RWSEMS Waiman Long
@ 2024-09-10 8:15 ` Andy Shevchenko
2024-09-10 8:16 ` Andy Shevchenko
0 siblings, 1 reply; 6+ messages in thread
From: Andy Shevchenko @ 2024-09-10 8:15 UTC (permalink / raw)
To: Waiman Long
Cc: Peter Zijlstra, Ingo Molnar, Will Deacon, Boqun Feng,
linux-kernel, llvm, Nathan Chancellor, Nick Desaulniers,
Bill Wendling, Justin Stitt
On Mon, Sep 09, 2024 at 02:29:05PM -0400, Waiman Long wrote:
> 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.
At least this solves my issue,
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Thanks!
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] locking/rwsem: Move is_rwsem_reader_owned() and rwsem_owner() under CONFIG_DEBUG_RWSEMS
2024-09-10 8:15 ` Andy Shevchenko
@ 2024-09-10 8:16 ` Andy Shevchenko
2024-09-10 15:47 ` Waiman Long
0 siblings, 1 reply; 6+ messages in thread
From: Andy Shevchenko @ 2024-09-10 8:16 UTC (permalink / raw)
To: Waiman Long
Cc: Peter Zijlstra, Ingo Molnar, Will Deacon, Boqun Feng,
linux-kernel, llvm, Nathan Chancellor, Nick Desaulniers,
Bill Wendling, Justin Stitt
On Tue, Sep 10, 2024 at 11:15:54AM +0300, Andy Shevchenko wrote:
> On Mon, Sep 09, 2024 at 02:29:05PM -0400, Waiman Long wrote:
> > 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.
>
> At least this solves my issue,
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
...and
Tested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] locking/rwsem: Move is_rwsem_reader_owned() and rwsem_owner() under CONFIG_DEBUG_RWSEMS
2024-09-10 8:16 ` Andy Shevchenko
@ 2024-09-10 15:47 ` Waiman Long
2024-09-10 16:01 ` Andy Shevchenko
0 siblings, 1 reply; 6+ messages in thread
From: Waiman Long @ 2024-09-10 15:47 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Peter Zijlstra, Ingo Molnar, Will Deacon, Boqun Feng,
linux-kernel, llvm, Nathan Chancellor, Nick Desaulniers,
Bill Wendling, Justin Stitt
On 9/10/24 04:16, Andy Shevchenko wrote:
> On Tue, Sep 10, 2024 at 11:15:54AM +0300, Andy Shevchenko wrote:
>> On Mon, Sep 09, 2024 at 02:29:05PM -0400, Waiman Long wrote:
>>> 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.
>> At least this solves my issue,
>> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ...and
>
> Tested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Thanks for the testing.
No functional change is intended for this patch. Ingo & Peter, can this
patch lands in v6.12 or has to wait until v6.13?
Thanks,
Longman
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] locking/rwsem: Move is_rwsem_reader_owned() and rwsem_owner() under CONFIG_DEBUG_RWSEMS
2024-09-10 15:47 ` Waiman Long
@ 2024-09-10 16:01 ` Andy Shevchenko
2024-09-10 18:04 ` Waiman Long
0 siblings, 1 reply; 6+ messages in thread
From: Andy Shevchenko @ 2024-09-10 16:01 UTC (permalink / raw)
To: Waiman Long
Cc: Peter Zijlstra, Ingo Molnar, Will Deacon, Boqun Feng,
linux-kernel, llvm, Nathan Chancellor, Nick Desaulniers,
Bill Wendling, Justin Stitt
On Tue, Sep 10, 2024 at 11:47:17AM -0400, Waiman Long wrote:
> On 9/10/24 04:16, Andy Shevchenko wrote:
> > On Tue, Sep 10, 2024 at 11:15:54AM +0300, Andy Shevchenko wrote:
> > > On Mon, Sep 09, 2024 at 02:29:05PM -0400, Waiman Long wrote:
> > > > 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.
> > > At least this solves my issue,
> > > Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> > ...and
> >
> > Tested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
>
> Thanks for the testing.
>
> No functional change is intended for this patch. Ingo & Peter, can this
> patch lands in v6.12 or has to wait until v6.13?
I see it already in PeterZ's tree.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] locking/rwsem: Move is_rwsem_reader_owned() and rwsem_owner() under CONFIG_DEBUG_RWSEMS
2024-09-10 16:01 ` Andy Shevchenko
@ 2024-09-10 18:04 ` Waiman Long
0 siblings, 0 replies; 6+ messages in thread
From: Waiman Long @ 2024-09-10 18:04 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Peter Zijlstra, Ingo Molnar, Will Deacon, Boqun Feng,
linux-kernel, llvm, Nathan Chancellor, Nick Desaulniers,
Bill Wendling, Justin Stitt
On 9/10/24 12:01, Andy Shevchenko wrote:
> On Tue, Sep 10, 2024 at 11:47:17AM -0400, Waiman Long wrote:
>> On 9/10/24 04:16, Andy Shevchenko wrote:
>>> On Tue, Sep 10, 2024 at 11:15:54AM +0300, Andy Shevchenko wrote:
>>>> On Mon, Sep 09, 2024 at 02:29:05PM -0400, Waiman Long wrote:
>>>>> 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.
>>>> At least this solves my issue,
>>>> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
>>> ...and
>>>
>>> Tested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
>> Thanks for the testing.
>>
>> No functional change is intended for this patch. Ingo & Peter, can this
>> patch lands in v6.12 or has to wait until v6.13?
> I see it already in PeterZ's tree.
>
Right. It is in PeterZ's tree. I didn't check his tree that often.
Thanks for letting me know.
Cheers,
Longman
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2024-09-10 18:04 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-09 18:29 [PATCH] locking/rwsem: Move is_rwsem_reader_owned() and rwsem_owner() under CONFIG_DEBUG_RWSEMS Waiman Long
2024-09-10 8:15 ` Andy Shevchenko
2024-09-10 8:16 ` Andy Shevchenko
2024-09-10 15:47 ` Waiman Long
2024-09-10 16:01 ` Andy Shevchenko
2024-09-10 18:04 ` Waiman Long
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox