Skip to content

Commit 7061c63

Browse files
committed
KVM: s390: Remove one byte cmpxchg() usage
Within sca_clear_ext_call() cmpxchg() is used to clear one or two bytes (depending on sca format). The cmpxchg() calls are not supposed to fail; if so that would be a bug. Given that cmpxchg() usage on one and two byte areas generates very inefficient code, replace them with block concurrent WRITE_ONCE() calls, and remove the WARN_ON(). Acked-by: Claudio Imbrenda <[email protected]> Acked-by: Janosch Frank <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Heiko Carstens <[email protected]>
1 parent 5618c53 commit 7061c63

File tree

1 file changed

+2
-11
lines changed

1 file changed

+2
-11
lines changed

arch/s390/kvm/interrupt.c

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,6 @@ static int sca_inject_ext_call(struct kvm_vcpu *vcpu, int src_id)
118118

119119
static void sca_clear_ext_call(struct kvm_vcpu *vcpu)
120120
{
121-
int rc, expect;
122-
123121
if (!kvm_s390_use_sca_entries())
124122
return;
125123
kvm_s390_clear_cpuflags(vcpu, CPUSTAT_ECALL_PEND);
@@ -128,23 +126,16 @@ static void sca_clear_ext_call(struct kvm_vcpu *vcpu)
128126
struct esca_block *sca = vcpu->kvm->arch.sca;
129127
union esca_sigp_ctrl *sigp_ctrl =
130128
&(sca->cpu[vcpu->vcpu_id].sigp_ctrl);
131-
union esca_sigp_ctrl old;
132129

133-
old = READ_ONCE(*sigp_ctrl);
134-
expect = old.value;
135-
rc = cmpxchg(&sigp_ctrl->value, old.value, 0);
130+
WRITE_ONCE(sigp_ctrl->value, 0);
136131
} else {
137132
struct bsca_block *sca = vcpu->kvm->arch.sca;
138133
union bsca_sigp_ctrl *sigp_ctrl =
139134
&(sca->cpu[vcpu->vcpu_id].sigp_ctrl);
140-
union bsca_sigp_ctrl old;
141135

142-
old = READ_ONCE(*sigp_ctrl);
143-
expect = old.value;
144-
rc = cmpxchg(&sigp_ctrl->value, old.value, 0);
136+
WRITE_ONCE(sigp_ctrl->value, 0);
145137
}
146138
read_unlock(&vcpu->kvm->arch.sca_lock);
147-
WARN_ON(rc != expect); /* cannot clear? */
148139
}
149140

150141
int psw_extint_disabled(struct kvm_vcpu *vcpu)

0 commit comments

Comments
 (0)