Skip to contentSkip to conversation

KVM: apic: reuse smp_wmb() in kvm_make_request()

PATCH linmiaohe 1 participant 1 message Feb 7, 2020 KVM

lore
Share & tools
lore

linmiaohe

author
#0 lore raw
Quoted 16 lines · Sean Christopherson
Quoted 15 lines · Vitaly Kuznetsov

Review

Quoted 10 lines · linmiaohe

From: Miaohe Lin <[email protected]>

There is already an smp_mb() barrier in kvm_make_request(). We reuse it here.

(quoted diff) +6 -0
+			/*
+			 * Make sure pending_events is visible before sending
+			 * the request.
+			 * There is already an smp_wmb() in kvm_make_request(),
+			 * we reuse that barrier here.
+			 */

Let me suggest an alternative wording,

Quoted 6 lines
Quoted 6 lines

"kvm_make_request() provides smp_wmb() so pending_events changes are guaranteed to be visible"

But there is nothing wrong with yours, it's just longer than it could be
:-)

Thanks for your alternative wording. It looks much better.

Quoted 5 lines

I usually lean in favor of more comments, but in thise case I'd vote to drop the comment altogether. There are lots of places that rely on the
smp_wmb() in kvm_make_request() without a comment, e.g. the cases for APIC_DM_STARTUP and APIC_DM_REMRD in this same switch, kvm_inject_nmi(), etc... One might wonder what makes INIT special.

And on the flip side, APIC_DM_STARTUP is a good example of when a
smp_wmb()/smp_rmb() is needed and commented correctly (though calling out the exactly location of the other half would be helpful).

Yeh, I think the comment should be dropped too. :)

Thanks to both for review! I would send v2.