mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] locking: Add __lockfunc to slow path functions
@ 2022-08-08 17:59 Namhyung Kim
  2022-08-09 15:05 ` Waiman Long
  0 siblings, 1 reply; 6+ messages in thread
From: Namhyung Kim @ 2022-08-08 17:59 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, Will Deacon; +Cc: Waiman Long, Boqun Feng, LKML

So that we can skip the functions in the perf lock contention and other
places like /proc/PID/wchan.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
 kernel/locking/qrwlock.c   | 4 ++--
 kernel/locking/qspinlock.c | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/kernel/locking/qrwlock.c b/kernel/locking/qrwlock.c
index 2e1600906c9f..d2ef312a8611 100644
--- a/kernel/locking/qrwlock.c
+++ b/kernel/locking/qrwlock.c
@@ -18,7 +18,7 @@
  * queued_read_lock_slowpath - acquire read lock of a queued rwlock
  * @lock: Pointer to queued rwlock structure
  */
-void queued_read_lock_slowpath(struct qrwlock *lock)
+void __lockfunc queued_read_lock_slowpath(struct qrwlock *lock)
 {
 	/*
 	 * Readers come here when they cannot get the lock without waiting
@@ -63,7 +63,7 @@ EXPORT_SYMBOL(queued_read_lock_slowpath);
  * queued_write_lock_slowpath - acquire write lock of a queued rwlock
  * @lock : Pointer to queued rwlock structure
  */
-void queued_write_lock_slowpath(struct qrwlock *lock)
+void __lockfunc queued_write_lock_slowpath(struct qrwlock *lock)
 {
 	int cnts;
 
diff --git a/kernel/locking/qspinlock.c b/kernel/locking/qspinlock.c
index 65a9a10caa6f..2b23378775fe 100644
--- a/kernel/locking/qspinlock.c
+++ b/kernel/locking/qspinlock.c
@@ -313,7 +313,7 @@ static __always_inline u32  __pv_wait_head_or_lock(struct qspinlock *lock,
  * contended             :    (*,x,y) +--> (*,0,0) ---> (*,0,1) -'  :
  *   queue               :         ^--'                             :
  */
-void queued_spin_lock_slowpath(struct qspinlock *lock, u32 val)
+void __lockfunc queued_spin_lock_slowpath(struct qspinlock *lock, u32 val)
 {
 	struct mcs_spinlock *prev, *next, *node;
 	u32 old, tail;
-- 
2.37.1.559.g78731f0fdb-goog


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] locking: Add __lockfunc to slow path functions
  2022-08-08 17:59 [PATCH] locking: Add __lockfunc to slow path functions Namhyung Kim
@ 2022-08-09 15:05 ` Waiman Long
  2022-08-09 21:13   ` Namhyung Kim
  0 siblings, 1 reply; 6+ messages in thread
From: Waiman Long @ 2022-08-09 15:05 UTC (permalink / raw)
  To: Namhyung Kim, Peter Zijlstra, Ingo Molnar, Will Deacon; +Cc: Boqun Feng, LKML

On 8/8/22 13:59, Namhyung Kim wrote:
> So that we can skip the functions in the perf lock contention and other
> places like /proc/PID/wchan.
>
> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
> ---
>   kernel/locking/qrwlock.c   | 4 ++--
>   kernel/locking/qspinlock.c | 2 +-
>   2 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/kernel/locking/qrwlock.c b/kernel/locking/qrwlock.c
> index 2e1600906c9f..d2ef312a8611 100644
> --- a/kernel/locking/qrwlock.c
> +++ b/kernel/locking/qrwlock.c
> @@ -18,7 +18,7 @@
>    * queued_read_lock_slowpath - acquire read lock of a queued rwlock
>    * @lock: Pointer to queued rwlock structure
>    */
> -void queued_read_lock_slowpath(struct qrwlock *lock)
> +void __lockfunc queued_read_lock_slowpath(struct qrwlock *lock)
>   {
>   	/*
>   	 * Readers come here when they cannot get the lock without waiting
> @@ -63,7 +63,7 @@ EXPORT_SYMBOL(queued_read_lock_slowpath);
>    * queued_write_lock_slowpath - acquire write lock of a queued rwlock
>    * @lock : Pointer to queued rwlock structure
>    */
> -void queued_write_lock_slowpath(struct qrwlock *lock)
> +void __lockfunc queued_write_lock_slowpath(struct qrwlock *lock)
>   {
>   	int cnts;
>   
> diff --git a/kernel/locking/qspinlock.c b/kernel/locking/qspinlock.c
> index 65a9a10caa6f..2b23378775fe 100644
> --- a/kernel/locking/qspinlock.c
> +++ b/kernel/locking/qspinlock.c
> @@ -313,7 +313,7 @@ static __always_inline u32  __pv_wait_head_or_lock(struct qspinlock *lock,
>    * contended             :    (*,x,y) +--> (*,0,0) ---> (*,0,1) -'  :
>    *   queue               :         ^--'                             :
>    */
> -void queued_spin_lock_slowpath(struct qspinlock *lock, u32 val)
> +void __lockfunc queued_spin_lock_slowpath(struct qspinlock *lock, u32 val)
>   {
>   	struct mcs_spinlock *prev, *next, *node;
>   	u32 old, tail;


For completeness, I think you should also add it to the 
__pv_queued_spin_unlock() and __pv_queued_spin_unlock_slowpath() 
function in kernel/locking/qspinlock_paravirt.h. Perhaps even the 
assembly code in arch/x86/include/asm/qspinlock_paravirt.h.

Cheers,
Longman


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] locking: Add __lockfunc to slow path functions
  2022-08-09 15:05 ` Waiman Long
@ 2022-08-09 21:13   ` Namhyung Kim
  2022-08-09 23:09     ` Waiman Long
  0 siblings, 1 reply; 6+ messages in thread
From: Namhyung Kim @ 2022-08-09 21:13 UTC (permalink / raw)
  To: Waiman Long; +Cc: Peter Zijlstra, Ingo Molnar, Will Deacon, Boqun Feng, LKML

Hello,

On Tue, Aug 9, 2022 at 8:05 AM Waiman Long <longman@redhat.com> wrote:
>
> On 8/8/22 13:59, Namhyung Kim wrote:
> > So that we can skip the functions in the perf lock contention and other
> > places like /proc/PID/wchan.
> >
> > Signed-off-by: Namhyung Kim <namhyung@kernel.org>
> > ---
> >   kernel/locking/qrwlock.c   | 4 ++--
> >   kernel/locking/qspinlock.c | 2 +-
> >   2 files changed, 3 insertions(+), 3 deletions(-)
> >
> > diff --git a/kernel/locking/qrwlock.c b/kernel/locking/qrwlock.c
> > index 2e1600906c9f..d2ef312a8611 100644
> > --- a/kernel/locking/qrwlock.c
> > +++ b/kernel/locking/qrwlock.c
> > @@ -18,7 +18,7 @@
> >    * queued_read_lock_slowpath - acquire read lock of a queued rwlock
> >    * @lock: Pointer to queued rwlock structure
> >    */
> > -void queued_read_lock_slowpath(struct qrwlock *lock)
> > +void __lockfunc queued_read_lock_slowpath(struct qrwlock *lock)
> >   {
> >       /*
> >        * Readers come here when they cannot get the lock without waiting
> > @@ -63,7 +63,7 @@ EXPORT_SYMBOL(queued_read_lock_slowpath);
> >    * queued_write_lock_slowpath - acquire write lock of a queued rwlock
> >    * @lock : Pointer to queued rwlock structure
> >    */
> > -void queued_write_lock_slowpath(struct qrwlock *lock)
> > +void __lockfunc queued_write_lock_slowpath(struct qrwlock *lock)
> >   {
> >       int cnts;
> >
> > diff --git a/kernel/locking/qspinlock.c b/kernel/locking/qspinlock.c
> > index 65a9a10caa6f..2b23378775fe 100644
> > --- a/kernel/locking/qspinlock.c
> > +++ b/kernel/locking/qspinlock.c
> > @@ -313,7 +313,7 @@ static __always_inline u32  __pv_wait_head_or_lock(struct qspinlock *lock,
> >    * contended             :    (*,x,y) +--> (*,0,0) ---> (*,0,1) -'  :
> >    *   queue               :         ^--'                             :
> >    */
> > -void queued_spin_lock_slowpath(struct qspinlock *lock, u32 val)
> > +void __lockfunc queued_spin_lock_slowpath(struct qspinlock *lock, u32 val)
> >   {
> >       struct mcs_spinlock *prev, *next, *node;
> >       u32 old, tail;
>
>
> For completeness, I think you should also add it to the
> __pv_queued_spin_unlock() and __pv_queued_spin_unlock_slowpath()
> function in kernel/locking/qspinlock_paravirt.h. Perhaps even the
> assembly code in arch/x86/include/asm/qspinlock_paravirt.h.

Thanks for your comment.  I'm not sure about the asm part, will this be enough?

--- a/arch/x86/include/asm/qspinlock_paravirt.h
+++ b/arch/x86/include/asm/qspinlock_paravirt.h
@@ -36,7 +36,7 @@ PV_CALLEE_SAVE_REGS_THUNK(__pv_queued_spin_unlock_slowpath);
  *   rsi = lockval           (second argument)
  *   rdx = internal variable (set to 0)
  */
-asm    (".pushsection .text;"
+asm    (".pushsection .spinlock.text;"
        ".globl " PV_UNLOCK ";"
        ".type " PV_UNLOCK ", @function;"
        ".align 4,0x90;"

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] locking: Add __lockfunc to slow path functions
  2022-08-09 21:13   ` Namhyung Kim
@ 2022-08-09 23:09     ` Waiman Long
  2022-08-09 23:37       ` Namhyung Kim
  0 siblings, 1 reply; 6+ messages in thread
From: Waiman Long @ 2022-08-09 23:09 UTC (permalink / raw)
  To: Namhyung Kim; +Cc: Peter Zijlstra, Ingo Molnar, Will Deacon, Boqun Feng, LKML

On 8/9/22 17:13, Namhyung Kim wrote:
> Hello,
>
> On Tue, Aug 9, 2022 at 8:05 AM Waiman Long <longman@redhat.com> wrote:
>> On 8/8/22 13:59, Namhyung Kim wrote:
>>> So that we can skip the functions in the perf lock contention and other
>>> places like /proc/PID/wchan.
>>>
>>> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
>>> ---
>>>    kernel/locking/qrwlock.c   | 4 ++--
>>>    kernel/locking/qspinlock.c | 2 +-
>>>    2 files changed, 3 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/kernel/locking/qrwlock.c b/kernel/locking/qrwlock.c
>>> index 2e1600906c9f..d2ef312a8611 100644
>>> --- a/kernel/locking/qrwlock.c
>>> +++ b/kernel/locking/qrwlock.c
>>> @@ -18,7 +18,7 @@
>>>     * queued_read_lock_slowpath - acquire read lock of a queued rwlock
>>>     * @lock: Pointer to queued rwlock structure
>>>     */
>>> -void queued_read_lock_slowpath(struct qrwlock *lock)
>>> +void __lockfunc queued_read_lock_slowpath(struct qrwlock *lock)
>>>    {
>>>        /*
>>>         * Readers come here when they cannot get the lock without waiting
>>> @@ -63,7 +63,7 @@ EXPORT_SYMBOL(queued_read_lock_slowpath);
>>>     * queued_write_lock_slowpath - acquire write lock of a queued rwlock
>>>     * @lock : Pointer to queued rwlock structure
>>>     */
>>> -void queued_write_lock_slowpath(struct qrwlock *lock)
>>> +void __lockfunc queued_write_lock_slowpath(struct qrwlock *lock)
>>>    {
>>>        int cnts;
>>>
>>> diff --git a/kernel/locking/qspinlock.c b/kernel/locking/qspinlock.c
>>> index 65a9a10caa6f..2b23378775fe 100644
>>> --- a/kernel/locking/qspinlock.c
>>> +++ b/kernel/locking/qspinlock.c
>>> @@ -313,7 +313,7 @@ static __always_inline u32  __pv_wait_head_or_lock(struct qspinlock *lock,
>>>     * contended             :    (*,x,y) +--> (*,0,0) ---> (*,0,1) -'  :
>>>     *   queue               :         ^--'                             :
>>>     */
>>> -void queued_spin_lock_slowpath(struct qspinlock *lock, u32 val)
>>> +void __lockfunc queued_spin_lock_slowpath(struct qspinlock *lock, u32 val)
>>>    {
>>>        struct mcs_spinlock *prev, *next, *node;
>>>        u32 old, tail;
>>
>> For completeness, I think you should also add it to the
>> __pv_queued_spin_unlock() and __pv_queued_spin_unlock_slowpath()
>> function in kernel/locking/qspinlock_paravirt.h. Perhaps even the
>> assembly code in arch/x86/include/asm/qspinlock_paravirt.h.
> Thanks for your comment.  I'm not sure about the asm part, will this be enough?
>
> --- a/arch/x86/include/asm/qspinlock_paravirt.h
> +++ b/arch/x86/include/asm/qspinlock_paravirt.h
> @@ -36,7 +36,7 @@ PV_CALLEE_SAVE_REGS_THUNK(__pv_queued_spin_unlock_slowpath);
>    *   rsi = lockval           (second argument)
>    *   rdx = internal variable (set to 0)
>    */
> -asm    (".pushsection .text;"
> +asm    (".pushsection .spinlock.text;"
>          ".globl " PV_UNLOCK ";"
>          ".type " PV_UNLOCK ", @function;"
>          ".align 4,0x90;"
>
That is what I meant. However, you should also a comment saying that the 
use of .spinlock.text section is equivalent to the use of __lockfunc on 
an equivalent C function to make it clear. Also add the __lockfunc to 
the pseudo code in the comment section.

Cheers,
Longman


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] locking: Add __lockfunc to slow path functions
  2022-08-09 23:09     ` Waiman Long
@ 2022-08-09 23:37       ` Namhyung Kim
  2022-08-10 21:00         ` Namhyung Kim
  0 siblings, 1 reply; 6+ messages in thread
From: Namhyung Kim @ 2022-08-09 23:37 UTC (permalink / raw)
  To: Waiman Long; +Cc: Peter Zijlstra, Ingo Molnar, Will Deacon, Boqun Feng, LKML

On Tue, Aug 9, 2022 at 4:09 PM Waiman Long <longman@redhat.com> wrote:
>
> On 8/9/22 17:13, Namhyung Kim wrote:
> > --- a/arch/x86/include/asm/qspinlock_paravirt.h
> > +++ b/arch/x86/include/asm/qspinlock_paravirt.h
> > @@ -36,7 +36,7 @@ PV_CALLEE_SAVE_REGS_THUNK(__pv_queued_spin_unlock_slowpath);
> >    *   rsi = lockval           (second argument)
> >    *   rdx = internal variable (set to 0)
> >    */
> > -asm    (".pushsection .text;"
> > +asm    (".pushsection .spinlock.text;"
> >          ".globl " PV_UNLOCK ";"
> >          ".type " PV_UNLOCK ", @function;"
> >          ".align 4,0x90;"
> >
> That is what I meant. However, you should also a comment saying that the
> use of .spinlock.text section is equivalent to the use of __lockfunc on
> an equivalent C function to make it clear. Also add the __lockfunc to
> the pseudo code in the comment section.

Thanks, will add!
Namhyung

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] locking: Add __lockfunc to slow path functions
  2022-08-09 23:37       ` Namhyung Kim
@ 2022-08-10 21:00         ` Namhyung Kim
  0 siblings, 0 replies; 6+ messages in thread
From: Namhyung Kim @ 2022-08-10 21:00 UTC (permalink / raw)
  To: Waiman Long; +Cc: Peter Zijlstra, Ingo Molnar, Will Deacon, Boqun Feng, LKML

On Tue, Aug 9, 2022 at 4:37 PM Namhyung Kim <namhyung@kernel.org> wrote:
>
> On Tue, Aug 9, 2022 at 4:09 PM Waiman Long <longman@redhat.com> wrote:
> >
> > On 8/9/22 17:13, Namhyung Kim wrote:
> > > --- a/arch/x86/include/asm/qspinlock_paravirt.h
> > > +++ b/arch/x86/include/asm/qspinlock_paravirt.h
> > > @@ -36,7 +36,7 @@ PV_CALLEE_SAVE_REGS_THUNK(__pv_queued_spin_unlock_slowpath);
> > >    *   rsi = lockval           (second argument)
> > >    *   rdx = internal variable (set to 0)
> > >    */
> > > -asm    (".pushsection .text;"
> > > +asm    (".pushsection .spinlock.text;"
> > >          ".globl " PV_UNLOCK ";"
> > >          ".type " PV_UNLOCK ", @function;"
> > >          ".align 4,0x90;"
> > >
> > That is what I meant. However, you should also a comment saying that the
> > use of .spinlock.text section is equivalent to the use of __lockfunc on
> > an equivalent C function to make it clear. Also add the __lockfunc to
> > the pseudo code in the comment section.

FYI I had to use __PV_CALLEE_SAVE_REGS_THUNK to pass the section name
(".spinlock.text") to prevent a build error.

  CC      kernel/locking/qspinlock.o
/tmp/ccdn2Gyk.s: Assembler messages:
/tmp/ccdn2Gyk.s:725: Error: changed section attributes for .spinlock.text

Thanks,
Namhyung

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-08-10 21:01 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-08 17:59 [PATCH] locking: Add __lockfunc to slow path functions Namhyung Kim
2022-08-09 15:05 ` Waiman Long
2022-08-09 21:13   ` Namhyung Kim
2022-08-09 23:09     ` Waiman Long
2022-08-09 23:37       ` Namhyung Kim
2022-08-10 21:00         ` Namhyung Kim

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®