From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.7 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 359EDC35247 for ; Fri, 7 Feb 2020 02:59:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 135E521927 for ; Fri, 7 Feb 2020 02:59:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727028AbgBGC7S convert rfc822-to-8bit (ORCPT ); Thu, 6 Feb 2020 21:59:18 -0500 Received: from szxga08-in.huawei.com ([45.249.212.255]:40578 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726597AbgBGC7R (ORCPT ); Thu, 6 Feb 2020 21:59:17 -0500 Received: from DGGEMM402-HUB.china.huawei.com (unknown [172.30.72.53]) by Forcepoint Email with ESMTP id 04D312EDC18A8F6983C6; Fri, 7 Feb 2020 10:59:15 +0800 (CST) Received: from dggeme713-chm.china.huawei.com (10.1.199.109) by DGGEMM402-HUB.china.huawei.com (10.3.20.210) with Microsoft SMTP Server (TLS) id 14.3.439.0; Fri, 7 Feb 2020 10:59:14 +0800 Received: from dggeme763-chm.china.huawei.com (10.3.19.109) by dggeme713-chm.china.huawei.com (10.1.199.109) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5; Fri, 7 Feb 2020 10:59:14 +0800 Received: from dggeme763-chm.china.huawei.com ([10.6.66.36]) by dggeme763-chm.china.huawei.com ([10.6.66.36]) with mapi id 15.01.1713.004; Fri, 7 Feb 2020 10:59:14 +0800 From: linmiaohe To: Sean Christopherson , Vitaly Kuznetsov CC: "kvm@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "x86@kernel.org" , "pbonzini@redhat.com" , "rkrcmar@redhat.com" , "wanpengli@tencent.com" , "jmattson@google.com" , "joro@8bytes.org" , "tglx@linutronix.de" , "mingo@redhat.com" , "bp@alien8.de" , "hpa@zytor.com" Subject: Re: [PATCH] KVM: apic: reuse smp_wmb() in kvm_make_request() Thread-Topic: [PATCH] KVM: apic: reuse smp_wmb() in kvm_make_request() Thread-Index: AdXdYflqAMGIHsEtNky6XhNmzdckJQ== Date: Fri, 7 Feb 2020 02:59:14 +0000 Message-ID: <0f8ae71f59cd4b80ac93b9e1aa3b2428@huawei.com> Accept-Language: en-US Content-Language: zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.173.221.158] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-CFilter-Loop: Reflected Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Sean Christopherson wrote: > On Thu, Feb 06, 2020 at 11:47:02AM +0100, Vitaly Kuznetsov wrote: >> linmiaohe writes: >> >> > From: Miaohe Lin >> > >> > There is already an smp_mb() barrier in kvm_make_request(). We reuse >> > it here. >> > + /* >> > + * 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, >> >> "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. >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.