locking/pvqspinlock: Correct the type of "old" variable in pv_kick_node()
PATCH 1/1 locking/pvqspinlock: Correct the type of "old" variable in pv_kick_node()
"enum vcpu_state" is not compatible with "u8" type for all targets, resulting in:
error: initialization of 'u8 *' {aka 'unsigned char *'} from incompatible pointer type 'enum vcpu_state *'
for LoongArch. Correct the type of "old" variable to "u8".
--- kernel/locking/qspinlock_paravirt.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/locking/qspinlock_paravirt.h +1 -1
@@ -357,7 +357,7 @@ static void pv_wait_node(struct mcs_spinlock *node, struct mcs_spinlock *prev)static void pv_kick_node (struct qspinlock *lock,struct mcs_spinlock *node) {struct pv_node *pn = (struct pv_node *)node; -enum vcpu_state old = vcpu_halted; +u8 old = vcpu_halted;/* * If the vCPU is indeed halted, advance its state to match that of * pv_wait_node(). If OTOH this fails, the vCPU was running and will
Signature · 1 line
2.42.0
Quoted 25 lines · Uros Bizjak
"enum
vcpu_state" is not compatible with "u8" type for all targets, resulting in:error: initialization of 'u8 *' {aka 'unsigned char *'} from incompatible pointer type 'enum
vcpu_state*'for LoongArch. Correct the type of "old" variable to "u8".
Cc Peter Zijlstra <[email protected]>Cc Ingo Molnar <[email protected]>Cc Will Deacon <[email protected]>Cc Waiman Long <[email protected]>Cc Boqun Feng <[email protected]>Fixes fea0e1820b51 ("locking/pvqspinlock: Use try_cmpxchg() in qspinlock_paravirt.h")Reported-by Bibo Mao <[email protected]>Signed-off-by Uros Bizjak <[email protected]>--- kernel/locking/qspinlock_paravirt.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)kernel/locking/qspinlock_paravirt.h +0
-0
kernel/locking/qspinlock_paravirt.h static void pv_wait_node(struct mcs_spinlock *node, struct mcs_spinlock *prev) · line 363
Quoted 8 lines
kernel/locking/qspinlock_paravirt.h +1
-1@@ -357,7 +357,7 @@ static void pv_wait_node(struct mcs_spinlock *node, struct mcs_spinlock *prev)static void pv_kick_node (struct qspinlock *lock,struct mcs_spinlock *node) {struct pv_node *pn = (struct pv_node *)node; -enum vcpu_state old = vcpu_halted; +u8 old = vcpu_halted;/* * If the vCPU is indeed halted, advance its state to match that of * pv_wait_node(). If OTOH this fails, the vCPU was running and will
Uros,
Sorry for late reply because of weekend time. This modification works well for me.
In later I want to define pv_node::state as int type on LoongArch because there is only int32/int64 cmpxchg is better supported on the system, however that is another issue.
Quoted 34 lines · Uros Bizjak
"enum
vcpu_state" is not compatible with "u8" type for all targets, resulting in:error: initialization of 'u8 *' {aka 'unsigned char *'} from incompatible pointer type 'enum
vcpu_state*'for LoongArch. Correct the type of "old" variable to "u8".
Cc Peter Zijlstra <[email protected]>Cc Ingo Molnar <[email protected]>Cc Will Deacon <[email protected]>Cc Waiman Long <[email protected]>Cc Boqun Feng <[email protected]>Fixes fea0e1820b51 ("locking/pvqspinlock: Use try_cmpxchg() in qspinlock_paravirt.h")Reported-by Bibo Mao <[email protected]>Signed-off-by Uros Bizjak <[email protected]>--- kernel/locking/qspinlock_paravirt.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)kernel/locking/qspinlock_paravirt.h +1
-1@@ -357,7 +357,7 @@ static void pv_wait_node(struct mcs_spinlock *node, struct mcs_spinlock *prev)static void pv_kick_node (struct qspinlock *lock,struct mcs_spinlock *node) {struct pv_node *pn = (struct pv_node *)node; -enum vcpu_state old = vcpu_halted; +u8 old = vcpu_halted;/* * If the vCPU is indeed halted, advance its state to match that of * pv_wait_node(). If OTOH this fails, the vCPU was running and will
Waiman Long
reviewerQuoted 5 lines · maobibo
Uros,
Sorry for late reply because of weekend time. This modification works well for me.
In later I want to define
pv_node::stateas int type on LoongArch because there is only int32/int64 cmpxchg is better supported on the system, however that is another issue.
I thought about changing pv_node::state to int, but that requires changing the pv_wait() call to use int too. That doesn't work because pv_wait() is also used to monitor the state of the lock byte of the qspinlock. In essence, we can't use pvqspinlock if 8-bit cmpxchg isn't supported.
Cheers,
Longman
Quoted 40 lines
Tested-by Bibo Mao <[email protected]>Quoted 35 lines · Uros Bizjak
"enum
vcpu_state" is not compatible with "u8" type for all targets, resulting in:error: initialization of 'u8 *' {aka 'unsigned char *'} from incompatible pointer type 'enum
vcpu_state*'for LoongArch. Correct the type of "old" variable to "u8".
Cc Peter Zijlstra <[email protected]>Cc Ingo Molnar <[email protected]>Cc Will Deacon <[email protected]>Cc Waiman Long <[email protected]>Cc Boqun Feng <[email protected]>Fixes fea0e1820b51 ("locking/pvqspinlock: Use try_cmpxchg() in qspinlock_paravirt.h")Reported-by Bibo Mao <[email protected]>Signed-off-by Uros Bizjak <[email protected]>---
kernel/locking/qspinlock_paravirt.h| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)kernel/locking/qspinlock_paravirt.h +1
-1@@ -357,7 +357,7 @@ static void pv_wait_node(struct mcs_spinlock *node, struct mcs_spinlock *prev) static void pv_kick_node(struct qspinlock *lock, struct mcs_spinlock *node) { struct pv_node *pn = (struct pv_node *)node; - enum vcpu_state old = vcpu_halted; + u8 old = vcpu_halted; /** If the vCPU is indeed halted, advance its state to match that of *
pv_wait_node(). If OTOH this fails, the vCPU was running and will
Quoted 9 lines · Waiman Long
Quoted 5 lines · maobibo
Uros,
Sorry for late reply because of weekend time. This modification works well for me.
In later I want to define
pv_node::stateas int type on LoongArch because there is only int32/int64 cmpxchg is better supported on the system, however that is another issue.I thought about changing
pv_node::stateto int, but that requires changing thepv_wait()call to use int too. That doesn't work becausepv_wait()is also used to monitor the state of the lock byte of the qspinlock. In essence, we can't use pvqspinlock if 8-bit cmpxchg isn't supported.
Hi Longman,
yes, your are right. pv_wait also monitors the state of the qspinlock lock byte, so the parameter type about pv_wait must be u8.
LoongArch supports byte cmpxchg, only that word cmpxchg has higher efficiency. By the draft kernel compiling test, pvqspinlock can improve performance greatly when pCPU is shared by multiple vCPUs.
And thanks for your remaindering.
Regards
Bibo Mao
Quoted 46 lines
Cheers,
LongmanQuoted 41 lines
Tested-by Bibo Mao <[email protected]>Quoted 36 lines · Uros Bizjak
"enum
vcpu_state" is not compatible with "u8" type for all targets, resulting in:error: initialization of 'u8 *' {aka 'unsigned char *'} from incompatible pointer type 'enum
vcpu_state*'for LoongArch. Correct the type of "old" variable to "u8".
Cc Peter Zijlstra <[email protected]>Cc Ingo Molnar <[email protected]>Cc Will Deacon <[email protected]>Cc Waiman Long <[email protected]>Cc Boqun Feng <[email protected]>Fixes fea0e1820b51 ("locking/pvqspinlock: Use try_cmpxchg() in qspinlock_paravirt.h")Reported-by Bibo Mao <[email protected]>Signed-off-by Uros Bizjak <[email protected]>---
kernel/locking/qspinlock_paravirt.h| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)kernel/locking/qspinlock_paravirt.h +1
-1@@ -357,7 +357,7 @@ static void pv_wait_node(struct mcs_spinlock *node, struct mcs_spinlock *prev) static void pv_kick_node(struct qspinlock *lock, struct mcs_spinlock *node) { struct pv_node *pn = (struct pv_node *)node; - enum vcpu_state old = vcpu_halted; + u8 old = vcpu_halted; /** If the vCPU is indeed halted, advance its state to match that of *
pv_wait_node(). If OTOH this fails, the vCPU was running and will
The following commit has been merged into the locking/urgent branch of tip:
The following commit has been merged into the locking/urgent branch of tip:
Commit-ID: 6623b0217d0c9bed80bfa43b778ce1c0eb03b497 Gitweb: https://git.kernel.org/tip/6623b0217d0c9bed80bfa43b778ce1c0eb03b497 Author: Uros Bizjak <[email protected]> AuthorDate: Sun, 21 Jul 2024 18:45:41 +02:00 Committer: Peter Zijlstra <[email protected]> CommitterDate: Mon, 29 Jul 2024 12:16:21 +02:00
locking/pvqspinlock: Correct the type of "old" variable in pv_kick_node()
"enum vcpu_state" is not compatible with "u8" type for all targets, resulting in:
error: initialization of 'u8 *' {aka 'unsigned char *'} from incompatible pointer type 'enum vcpu_state *'
for LoongArch. Correct the type of "old" variable to "u8".
--- kernel/locking/qspinlock_paravirt.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/locking/qspinlock_paravirt.h +1 -1
@@ -357,7 +357,7 @@ static void pv_wait_node(struct mcs_spinlock *node, struct mcs_spinlock *prev)static void pv_kick_node (struct qspinlock *lock,struct mcs_spinlock *node) {struct pv_node *pn = (struct pv_node *)node; -enum vcpu_state old = vcpu_halted; +u8 old = vcpu_halted;/* * If the vCPU is indeed halted, advance its state to match that of * pv_wait_node(). If OTOH this fails, the vCPU was running and will