From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754187AbbJIN4T (ORCPT ); Fri, 9 Oct 2015 09:56:19 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45855 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751457AbbJIN4R (ORCPT ); Fri, 9 Oct 2015 09:56:17 -0400 Subject: Re: [PATCH v2] kvm: fix waitqueue_active without memory barrier in virt/kvm/async_pf.c To: Peter Zijlstra , Kosuke Tatsukawa References: <17EC94B0A072C34B8DCF0D30AD16044A02874DB5@BPXM09GP.gisp.nec.co.jp> <20151009125507.GA7520@twins.programming.kicks-ass.net> Cc: Gleb Natapov , "kvm@vger.kernel.org" , "linux-kernel@vger.kernel.org" From: Paolo Bonzini X-Enigmail-Draft-Status: N1110 Message-ID: <5617C77D.9060202@redhat.com> Date: Fri, 9 Oct 2015 15:56:13 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 In-Reply-To: <20151009125507.GA7520@twins.programming.kicks-ass.net> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 09/10/2015 14:55, Peter Zijlstra wrote: > On Fri, Oct 09, 2015 at 12:21:55PM +0000, Kosuke Tatsukawa wrote: > >> + * Memory barrier is required here to make sure change to >> + * vcpu->async_pf.done is visible from other CPUs. This memory >> + * barrier pairs with prepare_to_wait's set_current_state() > > That is not how memory barriers work; they don't 'make visible'. They > simply ensure order between operations. > > X = Y = 0 > > CPU0 CPU1 > > [S] X=1 [S] Y=1 > MB MB > [L] y=Y [L] x=X > > assert(x || y) > > The issue of the memory barrier does not mean the store is visible, it > merely means that the load _must_ happen after the store (in the above > scenario). > > This gives a guarantee that not both x and y can be 0. Because either > being 0, means the other has not yet executed and must therefore observe > your store. > > Nothing more, nothing less. > > So your comment is misleading at best. Yeah, I will just reword the comment when applying. Thanks Kosuke-san for your contribution! Paolo