Skip to content

Commit 501f7f6

Browse files
namhyungPeter Zijlstra
authored andcommitted
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. Signed-off-by: Namhyung Kim <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Acked-by: Waiman Long <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 9aeaf5b commit 501f7f6

File tree

4 files changed

+12
-11
lines changed

4 files changed

+12
-11
lines changed

arch/x86/include/asm/qspinlock_paravirt.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,18 @@
1212
*/
1313
#ifdef CONFIG_64BIT
1414

15-
PV_CALLEE_SAVE_REGS_THUNK(__pv_queued_spin_unlock_slowpath);
15+
__PV_CALLEE_SAVE_REGS_THUNK(__pv_queued_spin_unlock_slowpath, ".spinlock.text");
1616
#define __pv_queued_spin_unlock __pv_queued_spin_unlock
1717
#define PV_UNLOCK "__raw_callee_save___pv_queued_spin_unlock"
1818
#define PV_UNLOCK_SLOWPATH "__raw_callee_save___pv_queued_spin_unlock_slowpath"
1919

2020
/*
2121
* Optimized assembly version of __raw_callee_save___pv_queued_spin_unlock
2222
* which combines the registers saving trunk and the body of the following
23-
* C code:
23+
* C code. Note that it puts the code in the .spinlock.text section which
24+
* is equivalent to adding __lockfunc in the C code:
2425
*
25-
* void __pv_queued_spin_unlock(struct qspinlock *lock)
26+
* void __lockfunc __pv_queued_spin_unlock(struct qspinlock *lock)
2627
* {
2728
* u8 lockval = cmpxchg(&lock->locked, _Q_LOCKED_VAL, 0);
2829
*
@@ -36,7 +37,7 @@ PV_CALLEE_SAVE_REGS_THUNK(__pv_queued_spin_unlock_slowpath);
3637
* rsi = lockval (second argument)
3738
* rdx = internal variable (set to 0)
3839
*/
39-
asm (".pushsection .text;"
40+
asm (".pushsection .spinlock.text;"
4041
".globl " PV_UNLOCK ";"
4142
".type " PV_UNLOCK ", @function;"
4243
".align 4,0x90;"
@@ -65,8 +66,8 @@ asm (".pushsection .text;"
6566

6667
#else /* CONFIG_64BIT */
6768

68-
extern void __pv_queued_spin_unlock(struct qspinlock *lock);
69-
PV_CALLEE_SAVE_REGS_THUNK(__pv_queued_spin_unlock);
69+
extern void __lockfunc __pv_queued_spin_unlock(struct qspinlock *lock);
70+
__PV_CALLEE_SAVE_REGS_THUNK(__pv_queued_spin_unlock, ".spinlock.text");
7071

7172
#endif /* CONFIG_64BIT */
7273
#endif

kernel/locking/qrwlock.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
* queued_read_lock_slowpath - acquire read lock of a queued rwlock
1919
* @lock: Pointer to queued rwlock structure
2020
*/
21-
void queued_read_lock_slowpath(struct qrwlock *lock)
21+
void __lockfunc queued_read_lock_slowpath(struct qrwlock *lock)
2222
{
2323
/*
2424
* Readers come here when they cannot get the lock without waiting
@@ -63,7 +63,7 @@ EXPORT_SYMBOL(queued_read_lock_slowpath);
6363
* queued_write_lock_slowpath - acquire write lock of a queued rwlock
6464
* @lock : Pointer to queued rwlock structure
6565
*/
66-
void queued_write_lock_slowpath(struct qrwlock *lock)
66+
void __lockfunc queued_write_lock_slowpath(struct qrwlock *lock)
6767
{
6868
int cnts;
6969

kernel/locking/qspinlock.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ static __always_inline u32 __pv_wait_head_or_lock(struct qspinlock *lock,
313313
* contended : (*,x,y) +--> (*,0,0) ---> (*,0,1) -' :
314314
* queue : ^--' :
315315
*/
316-
void queued_spin_lock_slowpath(struct qspinlock *lock, u32 val)
316+
void __lockfunc queued_spin_lock_slowpath(struct qspinlock *lock, u32 val)
317317
{
318318
struct mcs_spinlock *prev, *next, *node;
319319
u32 old, tail;

kernel/locking/qspinlock_paravirt.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,7 @@ pv_wait_head_or_lock(struct qspinlock *lock, struct mcs_spinlock *node)
489489
* PV versions of the unlock fastpath and slowpath functions to be used
490490
* instead of queued_spin_unlock().
491491
*/
492-
__visible void
492+
__visible __lockfunc void
493493
__pv_queued_spin_unlock_slowpath(struct qspinlock *lock, u8 locked)
494494
{
495495
struct pv_node *node;
@@ -544,7 +544,7 @@ __pv_queued_spin_unlock_slowpath(struct qspinlock *lock, u8 locked)
544544
#include <asm/qspinlock_paravirt.h>
545545

546546
#ifndef __pv_queued_spin_unlock
547-
__visible void __pv_queued_spin_unlock(struct qspinlock *lock)
547+
__visible __lockfunc void __pv_queued_spin_unlock(struct qspinlock *lock)
548548
{
549549
u8 locked;
550550

0 commit comments

Comments
 (0)