Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp131753imu; Wed, 12 Dec 2018 13:35:09 -0800 (PST) X-Google-Smtp-Source: AFSGD/WF3ZLlypOA8z5BM02dM88lC/sOSokEbs8y6Y8DTKI2EkRpM+f+rWrk8PYdFUZIWyflG2RR X-Received: by 2002:a62:c302:: with SMTP id v2mr21950464pfg.155.1544650509714; Wed, 12 Dec 2018 13:35:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544650509; cv=none; d=google.com; s=arc-20160816; b=nlJOS+BtdQyFz4JqjHNN2iT2vNeST1Qn+iz1mPZz6GBxEgeRWGo/P7vB2JDCt3S2tZ sOy/PgVk4w2CdwJHBawXfTAYhf+uJ3nmetCsGn6jGBxbZYeIVV77vGXgu3He5mDeWJCn 2criUgy9jsV+efF0R+1kpemqVrQJP3gKutC2rcU6ovaPwAy0OgB4UOuehn9o2HDAQrXc L12OjWFUoHegFZBWtvRBEf6rlPYX4Qqtziao0D1rJFBX3LlB/4r0e4bP0xRHDVqFfQw5 DByldg04nxmXNNGqUkClHWCQzYfompw3dbgH9IXQ0A3koTauBJhLVxExlKkQ3qg1K6z0 RRvQ== 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=X/pP9JS3o8i6/XSgNnFqKl4FBaxVWNZPxQWR2RweI2c=; b=pANNE9MoZYq/pHKgVTrIbz0/aWsw1oxKad50w9DOl1qYY6rFEOBUYxyz1RVuunutni AWhqOqmhvpPl4u4zP/XzArQItE2BO37Bs4VT3TqHg36iKCbyOglExK0bz9EznYbIt/L+ NUnJE0EFBIpPpUCvsRQi8xwAYVwCiZOZO5RyJfdYrtePhtFi1pdfL2/BpTTBmXXI0S88 tAxRKHVSLFD7LsCNhYYDCbuKfKjJOWNRdeES2cxroBeqcxPkHvGiBEuXZ70I62AAtmlO UmG2QxDXOnFqh5ghzvrIZICll+KF0IWD7lI/E2u+aohU+VH319RVU2+F7nHZKVkiM/Sh N/UA== 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 y12si14575445pgh.289.2018.12.12.13.34.54; Wed, 12 Dec 2018 13:35:09 -0800 (PST) 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 S1727999AbeLLVcv (ORCPT + 99 others); Wed, 12 Dec 2018 16:32:51 -0500 Received: from iolanthe.rowland.org ([192.131.102.54]:55798 "HELO iolanthe.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1726248AbeLLVcv (ORCPT ); Wed, 12 Dec 2018 16:32:51 -0500 Received: (qmail 5709 invoked by uid 2102); 12 Dec 2018 16:32:50 -0500 Received: from localhost (sendmail-bs@127.0.0.1) by localhost with SMTP; 12 Dec 2018 16:32:50 -0500 Date: Wed, 12 Dec 2018 16:32:50 -0500 (EST) From: Alan Stern X-X-Sender: stern@iolanthe.rowland.org To: "Paul E. McKenney" cc: David Goldblatt , , Florian Weimer , , , , , , , , , , , , , , Subject: Re: [PATCH] Linux: Implement membarrier function In-Reply-To: <20181212194225.GB4170@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 Wed, 12 Dec 2018, Paul E. McKenney wrote: > OK. How about this one? > > P0 P1 P2 P3 > Wa=2 rcu_read_lock() Wc=2 Wd=2 > memb Wb=2 Rd=0 synchronize_rcu(); > Rb=0 Rc=0 Ra=0 > rcu_read_unlock() > > The model should say that it is allowed. Taking a look... > > P0 P1 P2 P3 > Rd=0 > Wd=2 > synchronize_rcu(); > Ra=0 > Wa=2 > membs > rcu_read_lock() > [m01] > Rc=0 > Wc=2 > [m02] [m03] > membe > Rb=0 > Wb=2 > rcu_read_unlock() > > Looks allowed to me. If the synchronization of P1 and P2 were > interchanged, it should be forbidden: > > P0 P1 P2 P3 > Wa=2 Wb=2 rcu_read_lock() Wd=2 > memb Rc=0 Wc=2 synchronize_rcu(); > Rb=0 Rd=0 Ra=0 > rcu_read_unlock() > > Taking a look... > > P0 P1 P2 P3 > rcu_read_lock() > Rd=0 > Wa=2 Wb=2 Wd=2 > membs synchronize_rcu(); > [m01] > Rc=0 > Wc=2 > rcu_read_unlock() > [m02] Ra=0 [Forbidden?] > membe > Rb=0 Have you tried writing these as real litmus tests and running them through herd? > I believe that this ordering forbids the cycle: > > Wa=1 > membs -> [m01] -> Rc=0 -> Wc=2 -> rcu_read_unlock() -> > return from synchronize_rcu() -> Ra > > Does this make sense, or am I missing something? It's hard to tell. What you have written here isn't justified by the litmus test source code, since the position of m01 in P1's program order is undetermined. How do you justify m01 -> Rc, for example? Write it this way instead, using the relations defined in the sys_membarrier patch for linux-kernel.cat: memb ->memb-gp memb ->rcu-link Rc ->memb-rscsi Rc ->rcu-link rcu_read_unlock ->rcu-rscsi rcu_read_lock ->rcu-link synchronize_rcu ->rcu-gp synchronize_rcu ->rcu-link memb Recall that: memb-gp is the identity relation on sys_membarrier events, rcu-link includes (po? ; fre ; po), memb-rscsi is the identity relation on all events, rcu-rscsi links unlocks to their corresponding locks, and rcu-gp is the identity relation on synchronize_rcu events. These facts justify the cycle above. Leaving off the final rcu-link step, the sequence matches the definition of rcu-fence (the relations are memb-gp, memb-rscsi, rcu-rscsi, rcu-gp with rcu-links in between). Therefore the cycle is forbidden. Alan