Received: by 2002:ac0:aa62:0:0:0:0:0 with SMTP id w31-v6csp1258523ima; Sun, 21 Oct 2018 07:53:57 -0700 (PDT) X-Google-Smtp-Source: ACcGV63TRzKn5Ihhg+dtuqw2GRq3aukHNVI48RziZ3OZ8WVM4FNJplj9cMxwCg8QQBUsioGEiM0N X-Received: by 2002:a62:cc4:: with SMTP id 65-v6mr41956333pfm.127.1540133637491; Sun, 21 Oct 2018 07:53:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540133637; cv=none; d=google.com; s=arc-20160816; b=gmPU0UQ5EtT/ySp3lylzKwDYdVtoUOYH2ihhXXZdFjymGjzyTPOUMSoyVyC/gDSH6B Nygs4FkiaoiAlnhWOiYfBQMw3o6dySfaBF6YV5GKNZe5xMXdEay0jzyqEWOc1So/yZ/0 K4s5TtjYIEHfOu0dhI55gUTtmX76MXTTiMPjKhKq0F+PduIrJU2CSEOFci0irqXY1h5g q8maiK/AQxTcXtVDyEoEEozG8rA1QYrgghVCn8gHWJeExy6slKLS9tapPxwHCx+0Ucw+ PoMQ+ipzMTmVQ8Ojdp8xjniaPEkaRG+vMCffuaUAg0Z7xo7/srQ0ZzFG54OH1cM8mcgB 7ftw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:in-reply-to :subject:cc:to:from:date; bh=xnIUk9z+zpJWwyyTmBJDkNMFm6KKH7aw08NEPIXH+SE=; b=IWIda1d1mKUed8apGb7m1LfdmDh0gh/9dZwqO3IvIYexOBTQaOU0SR2msMpggCqtBC BHl54mTT9KE50o9nL68PJxLrtM0mILx47vfLOjzRNVYgqQcpIOZ+rKNBd6sGOMqTK+Qd 9gGjLjdk0Kc9gpmPTP4U3KXSgvlgHjqoOM5uHaEWL+0fHec8VqUrb4S8x2jJ3t0tEPX0 K8Jl9j2TOnh/HojcbEkc8SwRKuLNbjiJIjL2DnnrdvGXYoAopuDgtUt8RRddYnfOC602 c8iTBsxpL0xnHLSKu51vsA/0Kx9g3bvtjT6kZHWaj01ZVvv3OgMOO5mSw6EkJsJMXvLY ThkQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t10-v6si32857981pfk.252.2018.10.21.07.53.42; Sun, 21 Oct 2018 07:53:57 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727875AbeJUXHR (ORCPT + 99 others); Sun, 21 Oct 2018 19:07:17 -0400 Received: from netrider.rowland.org ([192.131.102.5]:40111 "HELO netrider.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1727336AbeJUXHR (ORCPT ); Sun, 21 Oct 2018 19:07:17 -0400 Received: (qmail 23920 invoked by uid 500); 21 Oct 2018 10:52:41 -0400 Received: from localhost (sendmail-bs@127.0.0.1) by localhost with SMTP; 21 Oct 2018 10:52:41 -0400 Date: Sun, 21 Oct 2018 10:52:41 -0400 (EDT) From: Alan Stern X-X-Sender: stern@netrider.rowland.org To: "Paul E. McKenney" cc: Andrea Parri , , , , , , , , , , , , Subject: Re: Interrupts, smp_load_acquire(), smp_store_release(), etc. In-Reply-To: <20181020210646.GC2674@linux.ibm.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, 20 Oct 2018, Paul E. McKenney wrote: > On Sat, Oct 20, 2018 at 10:22:29PM +0200, Andrea Parri wrote: > > [...] > > > > > The second (informal) litmus test has a more interesting Linux-kernel > > > counterpart: > > > > > > void t1_interrupt(void) > > > { > > > r0 = READ_ONCE(y); > > > smp_store_release(&x, 1); > > > } > > > > > > void t1(void) > > > { > > > smp_store_release(&y, 1); > > > } > > > > > > void t2(void) > > > { > > > r1 = smp_load_acquire(&x); > > > r2 = smp_load_acquire(&y); > > > } > > > > > > On store-reordering architectures that implement smp_store_release() > > > as a memory-barrier instruction followed by a store, the interrupt could > > > arrive betweentimes in t1(), so that there would be no ordering between > > > t1_interrupt()'s store to x and t1()'s store to y. This could (again, > > > in paranoid theory) result in the outcome r0==0 && r1==0 && r2==1. > > > > FWIW, I'd rather call "paranoid" the act of excluding such outcome ;-) > > but I admit that I've only run this test in *my mind*: in an SC world, > > > > CPU1 CPU2 > > > > t1() > > t1_interrupt() > > r0 = READ_ONCE(y); // =0 > > t2() > > r1 = smp_load_acquire(&x); // =0 > > smp_store_release(&x, 1); > > smp_store_release(&y, 1); > > r2 = smp_load_acquire(&y); // =1 > > OK, so did I get the outcome messed up again? :-/ Did you mean to say r0==1? If so, the litmus test would be a little clearer if you wrote t1() above t1_interrupt(). That would help to cement the WRC pattern in the reader's mind. In any case, perhaps this indicates the kernel should ensure that a full memory barrier is executed when an interrupt occurs. (Of course, the hardware may already do this for us, depending on the architecture.) Alan