Skip to content

Commit 29881b6

Browse files
jpemartinsbonzini
authored andcommitted
KVM: VMX: Introduce pi_is_pir_empty() helper
Streamline the PID.PIR check and change its call sites to use the newly added helper. Suggested-by: Liran Alon <[email protected]> Signed-off-by: Joao Martins <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent 132194f commit 29881b6

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

arch/x86/kvm/vmx/vmx.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1305,7 +1305,7 @@ static void vmx_vcpu_pi_load(struct kvm_vcpu *vcpu, int cpu)
13051305
*/
13061306
smp_mb__after_atomic();
13071307

1308-
if (!bitmap_empty((unsigned long *)pi_desc->pir, NR_VECTORS))
1308+
if (!pi_is_pir_empty(pi_desc))
13091309
pi_set_on(pi_desc);
13101310
}
13111311

@@ -6184,8 +6184,7 @@ static bool vmx_dy_apicv_has_pending_interrupt(struct kvm_vcpu *vcpu)
61846184
struct pi_desc *pi_desc = vcpu_to_pi_desc(vcpu);
61856185

61866186
return pi_test_on(pi_desc) ||
6187-
(pi_test_sn(pi_desc) &&
6188-
!bitmap_empty((unsigned long *)pi_desc->pir, NR_VECTORS));
6187+
(pi_test_sn(pi_desc) && !pi_is_pir_empty(pi_desc));
61896188
}
61906189

61916190
static void vmx_load_eoi_exitmap(struct kvm_vcpu *vcpu, u64 *eoi_exit_bitmap)

arch/x86/kvm/vmx/vmx.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,11 @@ static inline int pi_test_and_set_pir(int vector, struct pi_desc *pi_desc)
355355
return test_and_set_bit(vector, (unsigned long *)pi_desc->pir);
356356
}
357357

358+
static inline bool pi_is_pir_empty(struct pi_desc *pi_desc)
359+
{
360+
return bitmap_empty((unsigned long *)pi_desc->pir, NR_VECTORS);
361+
}
362+
358363
static inline void pi_set_sn(struct pi_desc *pi_desc)
359364
{
360365
set_bit(POSTED_INTR_SN,

0 commit comments

Comments
 (0)