Received: by 2002:ac0:aa62:0:0:0:0:0 with SMTP id w31-v6csp2486636ima; Mon, 22 Oct 2018 10:32:05 -0700 (PDT) X-Google-Smtp-Source: ACcGV60+nPqFSOMnOCqSnW7AVpIX4leYhIcDIAtS0KSpUyI2lzFKO75xQbd9WBdFngrjK27jsmJJ X-Received: by 2002:aa7:8643:: with SMTP id a3-v6mr46347589pfo.247.1540229525576; Mon, 22 Oct 2018 10:32:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540229525; cv=none; d=google.com; s=arc-20160816; b=rkGlrXN4jolE39HUEaHpdBpl2TB2KFL5hd5KrI8xtCFtUI1RxUeCmi31rRqAceXTHq wGRzZDNa1FCYc9kCvTIK7PF7hRsY7FvZTLkx+GMxP7AzSqgQoZe2axkl6JeJFum4XFzY 2t/2qPj51RlanqH/AI7p6z3TxwtxR8k2v+UpFeixcPl8GX/TXZMif0EEPCL4/LADK0jN ioGxcmbK5AG6rM0wyqpapKMZ1Ebrsv224D5HgvVsqRF+rlF5qdvN9b1CQplsEzc3ePSl TLRZECkUPxASiVYAw3BEDH18HpjeojJHAd7N4SmMDHnu7vhxaBQ/RFjd8QnoX4tjhzJW BnvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:subject:mime-version:user-agent :message-id:in-reply-to:date:references:cc:to:from; bh=Jv5tkNBY20Lc11Z7htmdFaodXdEmG4w/mH5j/oDs8WQ=; b=0Cp2G7EycK/JQ7Xa8aVfaxaqe93BBwumBGzeaR9U3URO1g0x41IxVGdRS0B2Cj2eHA Jy9AQqq6eSj38y5p5RvYk9IEL5r1ZPzC/e8AvJSED01+k60Vn1ZbogUHfNwWwFsoeOKB xPFyc3i2iTVPMhmQEYKPawI1eIvvZXwKt1vOZ8QzIO8ycRUH1S/3Uskr5yif6/GmMmgc X16Vb6dhMo1DR7JOCWHC2tNEiRA+rYltm/ZV84dHQkvvTtVHBUedGH6VcsCCoHzWnm/Y 7VKsPL+IyejaUpTkUrhHSILcmGnNZ2Vmw5sYryIyrf6J8GD9aOFiuuf+3bLnFp+ukEbj AgHw== 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 b34-v6si33840852plc.428.2018.10.22.10.31.49; Mon, 22 Oct 2018 10:32:05 -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 S1728805AbeJWBu1 (ORCPT + 99 others); Mon, 22 Oct 2018 21:50:27 -0400 Received: from out01.mta.xmission.com ([166.70.13.231]:51219 "EHLO out01.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728439AbeJWBu1 (ORCPT ); Mon, 22 Oct 2018 21:50:27 -0400 Received: from in02.mta.xmission.com ([166.70.13.52]) by out01.mta.xmission.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.87) (envelope-from ) id 1gEe2b-0005fF-SJ; Mon, 22 Oct 2018 11:30:57 -0600 Received: from 67-3-154-154.omah.qwest.net ([67.3.154.154] helo=x220.xmission.com) by in02.mta.xmission.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.87) (envelope-from ) id 1gEe2M-0003aC-Dd; Mon, 22 Oct 2018 11:30:57 -0600 From: ebiederm@xmission.com (Eric W. Biederman) To: "Paul E. McKenney" Cc: Alan Stern , linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, davidtgoldblatt@gmail.com, andrea.parri@amarulasolutions.com, will.deacon@arm.com, peterz@infradead.org, boqun.feng@gmail.com, npiggin@gmail.com, dhowells@redhat.com, j.alglave@ucl.ac.uk, luc.maranget@inria.fr, akiyks@gmail.com, dlustig@nvidia.com References: <20181020161049.GA13756@linux.ibm.com> <20181020210413.GB2674@linux.ibm.com> Date: Mon, 22 Oct 2018 12:30:20 -0500 In-Reply-To: <20181020210413.GB2674@linux.ibm.com> (Paul E. McKenney's message of "Sat, 20 Oct 2018 14:04:13 -0700") Message-ID: <87ftwx3n4j.fsf@xmission.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-XM-SPF: eid=1gEe2M-0003aC-Dd;;;mid=<87ftwx3n4j.fsf@xmission.com>;;;hst=in02.mta.xmission.com;;;ip=67.3.154.154;;;frm=ebiederm@xmission.com;;;spf=neutral X-XM-AID: U2FsdGVkX1+IdbSmVJfAU5zgVjTwwlwhZq9+18E93b0= X-SA-Exim-Connect-IP: 67.3.154.154 X-SA-Exim-Mail-From: ebiederm@xmission.com X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on sa07.xmission.com X-Spam-Level: X-Spam-Status: No, score=0.5 required=8.0 tests=ALL_TRUSTED,BAYES_50, DCC_CHECK_NEGATIVE,TVD_RCVD_IP,T_TM2_M_HEADER_IN_MSG,T_TooManySym_01, T_TooManySym_02,XMSubLong autolearn=disabled version=3.4.1 X-Spam-Report: * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP * 0.8 BAYES_50 BODY: Bayes spam probability is 40 to 60% * [score: 0.4953] * 0.0 TVD_RCVD_IP Message was received from an IP address * 0.7 XMSubLong Long Subject * 0.0 T_TM2_M_HEADER_IN_MSG BODY: No description available. * -0.0 DCC_CHECK_NEGATIVE Not listed in DCC * [sa07 1397; Body=1 Fuz1=1 Fuz2=1] * 0.0 T_TooManySym_02 5+ unique symbols in subject * 0.0 T_TooManySym_01 4+ unique symbols in subject X-Spam-DCC: XMission; sa07 1397; Body=1 Fuz1=1 Fuz2=1 X-Spam-Combo: ;"Paul E. McKenney" X-Spam-Relay-Country: X-Spam-Timing: total 15022 ms - load_scoreonly_sql: 0.05 (0.0%), signal_user_changed: 2.8 (0.0%), b_tie_ro: 1.91 (0.0%), parse: 0.78 (0.0%), extract_message_metadata: 2.9 (0.0%), get_uri_detail_list: 1.31 (0.0%), tests_pri_-1000: 2.9 (0.0%), tests_pri_-950: 1.25 (0.0%), tests_pri_-900: 1.00 (0.0%), tests_pri_-90: 25 (0.2%), check_bayes: 23 (0.2%), b_tokenize: 7 (0.0%), b_tok_get_all: 9 (0.1%), b_comp_prob: 2.1 (0.0%), b_tok_touch_all: 3.3 (0.0%), b_finish: 0.60 (0.0%), tests_pri_0: 248 (1.6%), check_dkim_signature: 0.54 (0.0%), check_dkim_adsp: 3.9 (0.0%), tests_pri_10: 3.5 (0.0%), compile_eval: 0.19 (0.0%), tests_pri_500: 14726 (98.0%), poll_dns_idle: 14717 (98.0%), rewrite_mail: 0.00 (0.0%) Subject: Re: Interrupts, smp_load_acquire(), smp_store_release(), etc. X-Spam-Flag: No X-SA-Exim-Version: 4.2.1 (built Thu, 05 May 2016 13:38:54 -0600) X-SA-Exim-Scanned: Yes (on in02.mta.xmission.com) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org "Paul E. McKenney" writes: > On Sat, Oct 20, 2018 at 04:18:37PM -0400, Alan Stern wrote: >> 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. > Good point, and I was in fact assuming that t1() and t1_interrupt() > were executing on the same CPU. > > This sort of thing happens naturally in the kernel when both t1() > and t1_interrupt() are accessing per-CPU variables. Interrupts have a cpumask of the cpus they may be dlievered on. I believe networking does in fact have places where percpu actions happen as well as interrupts pinned to a single cpu. And yes I agree percpu variables mean that you do not need to pin an interrupt to a single cpu to cause this to happen. Eric