Received: by 2002:ac0:aa62:0:0:0:0:0 with SMTP id w31-v6csp562730ima; Sat, 20 Oct 2018 13:20:37 -0700 (PDT) X-Google-Smtp-Source: ACcGV631+eMy59vVELW/PTYnaFU2uNeE24ScIE7x6QddpRoJy4h1YrfiNfWnJ6KnpOYMWuySCQa8 X-Received: by 2002:a63:9a19:: with SMTP id o25-v6mr37378869pge.440.1540066837786; Sat, 20 Oct 2018 13:20:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540066837; cv=none; d=google.com; s=arc-20160816; b=f0GHZKV7pM6nHsYHZl7M0QUSf1V8/8J+UPbvC+PL16NdjrxjSfEUEPljIjLvzyFjJq ntbeUTxVuUkvO0zaNB05BChuLZB1MdPuoF+7B5gKwYLEJe3g/ngsCr2hk7a25iDjxQZo sOm1hIyj50f22uLAL7F9X9w/P9ICw/VxlmxI25IDjOvCkXJqcW3/C7mMkmUrJlm0Sg3b FiRyUJjq6MLn+lFcSsKLJNrRBAFbuZ55SySmFaepfbd6k8JrNwjliVsVHm8BnIvDOgkC aEXh4fsUlYH2HXlSB0+Y2a7hUUYE/gB0dDApTTP3QeErtWUj9s0SScQXrs460XpmOvc/ 8NnQ== 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=ObUup1dTz3gI6UCMhSUbIHecEWpM1F/XiFkqiD1tNUU=; b=bkb95DpgVCy6Kg3otv1hIXI90NsICjkY2sxiJtp31gIyuCpqyCtwIP4T5e/FJykMqP vfR9y7I++UT9pEgiaXXJ4sIM5CxyeBo1EkLH71of1d9S4MZAsLAyFRwW4ftYthAl+Yp7 LswCwg+W3FdHCeBbYs7xX3iqpODG+guFB+7PzfwvHTDsAxz4TfOAtIc2tMJ0AJpsS3uA I76t+TNISGzqSfIdZNkSpsl/TxyJvZoCi83oR+Dr9wlxpLhT/gwb5hcmmLVFmdx+kcLO nH95h22dAjFgq+CQCLbnjuw6YBsjDeSBFYZDZxXFp5pv4jEVa82Bkmm/f5FuoThvTkCj 7UFw== 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 p21-v6si29273634pgi.199.2018.10.20.13.20.22; Sat, 20 Oct 2018 13:20:37 -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 S1726138AbeJUEaP (ORCPT + 99 others); Sun, 21 Oct 2018 00:30:15 -0400 Received: from netrider.rowland.org ([192.131.102.5]:51441 "HELO netrider.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1725746AbeJUEaP (ORCPT ); Sun, 21 Oct 2018 00:30:15 -0400 Received: (qmail 29885 invoked by uid 500); 20 Oct 2018 16:18:37 -0400 Received: from localhost (sendmail-bs@127.0.0.1) by localhost with SMTP; 20 Oct 2018 16:18:37 -0400 Date: Sat, 20 Oct 2018 16:18:37 -0400 (EDT) From: Alan Stern X-X-Sender: stern@netrider.rowland.org To: "Paul E. McKenney" cc: linux-kernel@vger.kernel.org, , , , , , , , , , , , Subject: Re: Interrupts, smp_load_acquire(), smp_store_release(), etc. In-Reply-To: <20181020161049.GA13756@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: > 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. This is disconcerting only if we assume that t1_interrupt() has to be executed by the same CPU as t1(). If the interrupt could be fielded by a different CPU then the paranoid outcome is perfectly understandable, even in an SC context. So the question really should be limited to situations where a handler is forced to execute in the context of a particular thread. While POSIX does allow such restrictions for user programs, I'm not aware of any similar mechanism in the kernel. Alan