locking: Add __lockfunc to slow path functions
Subsystems (2)
PATCH 1/1 locking: Add __lockfunc to slow path functions
So that we can skip the functions in the perf lock contention and other places like /proc/PID/wchan.
--- kernel/locking/qrwlock.c | 4 ++-- kernel/locking/qspinlock.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
kernel/locking/qrwlock.c +2 -2
@@ -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;
kernel/locking/qspinlock.c +1 -1
@@ -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;
Signature · 1 line
2.37.1.559.g78731f0fdb-goog
Waiman Long
reviewerQuoted 36 lines · Namhyung Kim
So that we can skip the functions in the perf lock contention and other places like
/proc/PID/wchan.Signed-off-by Namhyung Kim <[email protected]>--- kernel/locking/qrwlock.c | 4 ++-- kernel/locking/qspinlock.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)kernel/locking/qrwlock.c +2
-2@@ -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;kernel/locking/qspinlock.c +0
-0
kernel/locking/qspinlock.c static __always_inline u32 __pv_wait_head_or_lock(struct qspinlock *lock, · line 319
Quoted 8 lines
kernel/locking/qspinlock.c +1
-1@@ -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
Hello,
Quoted 44 lines · Waiman Long
Quoted 42 lines · Namhyung Kim
So that we can skip the functions in the perf lock contention and other places like
/proc/PID/wchan.Signed-off-by Namhyung Kim <[email protected]>--- kernel/locking/qrwlock.c | 4 ++-- kernel/locking/qspinlock.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)kernel/locking/qrwlock.c +2
-2@@ -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;kernel/locking/qspinlock.c +1
-1@@ -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) {
Quoted 8 lines
kernel/locking/qspinlock.c static __always_inline u32 __pv_wait_head_or_lock(struct qspinlock *lock, · line 319
Quoted 2 lines
kernel/locking/qspinlock.c +0
-0struct 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 inkernel/locking/qspinlock_paravirt.h. Perhaps even the assembly code inarch/x86/include/asm/qspinlock_paravirt.h.
Thanks for your comment. I'm not sure about the asm part, will this be enough?
arch/x86/include/asm/qspinlock_paravirt.h +1 -1
@@ -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;"
Waiman Long
reviewerQuoted 59 lines · Namhyung Kim
Hello,
Quoted 42 lines · Waiman Long
Quoted 41 lines · Namhyung Kim
So that we can skip the functions in the perf lock contention and other places like
/proc/PID/wchan.Signed-off-by Namhyung Kim <[email protected]>--- kernel/locking/qrwlock.c | 4 ++-- kernel/locking/qspinlock.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)kernel/locking/qrwlock.c +2
-2@@ -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;kernel/locking/qspinlock.c +1
-1@@ -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)Quoted 8 lines
kernel/locking/qspinlock.c static __always_inline u32 __pv_wait_head_or_lock(struct qspinlock *lock, · line 319
Quoted 3 lines
kernel/locking/qspinlock.c +0
-0{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 inkernel/locking/qspinlock_paravirt.h. Perhaps even the assembly code inarch/x86/include/asm/qspinlock_paravirt.h.Thanks for your comment. I'm not sure about the asm part, will this be enough?
arch/x86/include/asm/qspinlock_paravirt.h PV_CALLEE_SAVE_REGS_THUNK(__pv_queued_spin_unlock_slowpath); · line 42
Quoted 8 lines
arch/x86/include/asm/qspinlock_paravirt.h +1
-1@@ -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
Quoted 18 lines · Waiman Long
arch/x86/include/asm/qspinlock_paravirt.h PV_CALLEE_SAVE_REGS_THUNK(__pv_queued_spin_unlock_slowpath); · line 42
Quoted 12 lines · Namhyung Kim
arch/x86/include/asm/qspinlock_paravirt.h +1
-1@@ -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
__lockfuncon an equivalent C function to make it clear. Also add the__lockfuncto the pseudo code in the comment section.
Thanks, will add!
Namhyung
Quoted 4 lines · Namhyung Kim
Quoted 2 lines · Waiman Long
On 8/9/22 17:13, Namhyung Kim wrote:
Quoted 16 lines
Quoted 8 lines
Quoted 8 lines
arch/x86/include/asm/qspinlock_paravirt.h +1
-1@@ -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;"Quoted 8 lines
arch/x86/include/asm/qspinlock_paravirt.h PV_CALLEE_SAVE_REGS_THUNK(__pv_queued_spin_unlock_slowpath); · line 42
Quoted 4 lines
arch/x86/include/asm/qspinlock_paravirt.h +0
-0".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
__lockfuncon an equivalent C function to make it clear. Also add the__lockfuncto 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