Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp3707547imm; Tue, 29 May 2018 12:02:39 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoBU/kwiwlePkwx3ez+qB27/KtEEahx5hlmt2ZV+zDZ/ur9U/x8jLXKe0z2BMpLx7kjCqEf X-Received: by 2002:a62:f909:: with SMTP id o9-v6mr18567050pfh.256.1527620559289; Tue, 29 May 2018 12:02:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527620559; cv=none; d=google.com; s=arc-20160816; b=Fu98qDvAVejgiVVpm+eJuCtcYGiesKNh6ICCf0S4mcmWprCC3aNNCWiRtVn7NcbIO8 o0JOLcHXxcZ+/2Gi+dPmdpFqIIpnmMZAnykfEd9CPtLBSTsi+JUhdJeKU1fkMl9k6Jvz 5JcbTl+CM6nAM/bYXXllBIvXOww5ify1+BT3IgeyzLjqi20izHpEss42wU8a8PRlfVsA y9OcXWwH4fRydJpDMai1YacYaRHagiq/x1dfXJmJZW06Wb+09H8fwXwHqQ0HQJg7Abzw p56KdOE8hbKyFeaTSdlli8qrK5kZhw+Eb1XnM9rgaHCZYE7dm3FjkQvsEz5qSFgXLtvq T9GQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:user-agent:in-reply-to :content-disposition:mime-version:references:reply-to:subject:cc:to :from:date:arc-authentication-results; bh=FkuE/I2tc30lozAAORmbQvDaS6nJKUBD7c04y2zuGx8=; b=TCcRImriCpacBNrNTChvruEIxXZCoo0Vr4YFbgbErq2CPvhen0v8ZYMqMmoBFrnwJV 9WazU+wMvBhYdOTUFY/iVoMlPQuCUxSBUCBpdoCvj6VXwqlw11yDyrhlKwcALKc2PLeg AEHeLAxrZoM0xJm1WPAJZU4FonhwwekR/QnmVk+TJW9JNgwXd5asZ7AQDF87bZ0ro0D6 Ik/BVKEVmeLei7NsX8do81s26vw/z2KZ23muJNrLn+563/mWaz8xhBUOLuAPmVo0aDKu 9vxmTVg76yUSOYFF1MkK0s4kTGnuska5iYZqHdhFa75YPnWdnzsVUGTrD9roaSQL43aH DNQQ== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o11-v6si2355902pgq.506.2018.05.29.12.02.23; Tue, 29 May 2018 12:02:39 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966106AbeE2TCA (ORCPT + 99 others); Tue, 29 May 2018 15:02:00 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:46398 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S965425AbeE2TB5 (ORCPT ); Tue, 29 May 2018 15:01:57 -0400 Received: from pps.filterd (m0098413.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w4TIx0Y2077061 for ; Tue, 29 May 2018 15:01:56 -0400 Received: from e16.ny.us.ibm.com (e16.ny.us.ibm.com [129.33.205.206]) by mx0b-001b2d01.pphosted.com with ESMTP id 2j993s1v48-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 29 May 2018 15:01:56 -0400 Received: from localhost by e16.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 29 May 2018 15:01:55 -0400 Received: from b01cxnp22036.gho.pok.ibm.com (9.57.198.26) by e16.ny.us.ibm.com (146.89.104.203) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Tue, 29 May 2018 15:01:51 -0400 Received: from b01ledav003.gho.pok.ibm.com (b01ledav003.gho.pok.ibm.com [9.57.199.108]) by b01cxnp22036.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w4TJ1o1x55181564 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 29 May 2018 19:01:50 GMT Received: from b01ledav003.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4EAA5B2064; Tue, 29 May 2018 16:03:31 -0400 (EDT) Received: from b01ledav003.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 18A6BB2067; Tue, 29 May 2018 16:03:31 -0400 (EDT) Received: from paulmck-ThinkPad-W541 (unknown [9.85.153.176]) by b01ledav003.gho.pok.ibm.com (Postfix) with ESMTP; Tue, 29 May 2018 16:03:31 -0400 (EDT) Received: by paulmck-ThinkPad-W541 (Postfix, from userid 1000) id C6F5716C5F41; Tue, 29 May 2018 12:03:32 -0700 (PDT) Date: Tue, 29 May 2018 12:03:32 -0700 From: "Paul E. McKenney" To: Alan Stern Cc: linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, 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, mingo@kernel.org, torvalds@linux-foundation.org, roman.penyaev@profitbricks.com Subject: Re: LKMM litmus test for Roman Penyaev's rcu-rr Reply-To: paulmck@linux.vnet.ibm.com References: <20180528220811.GA5221@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-TM-AS-GCONF: 00 x-cbid: 18052919-0024-0000-0000-000003622057 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00009097; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000264; SDB=6.01039489; UDB=6.00532024; IPR=6.00818617; MB=3.00021361; MTD=3.00000008; XFM=3.00000015; UTC=2018-05-29 19:01:54 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18052919-0025-0000-0000-0000482BCB35 Message-Id: <20180529190332.GO3803@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-05-29_08:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1805290203 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 29, 2018 at 02:35:34PM -0400, Alan Stern wrote: > On Mon, 28 May 2018, Paul E. McKenney wrote: > > > Hello! > > > > The litmus test below is a first attempt to model Roman's rcu-rr > > round-robin RCU-protected linked list. His test code, which includes > > the algorithm under test, may be found here: > > > > https://github.com/rouming/rcu-rr/blob/master/rcu-rr.c > > > > The P0() process below roughly corresponds to remove_conn_from_arr(), > > with litmus-test variable "c" standing in for the per-CPU ppcpu_con. > > Similarly, P1() roughly corresponds to get_next_conn_rr(). It claims > > that the algorithm is safe, and also claims that it becomes unsafe if > > either synchronize_rcu() is removed. > > This algorithm (the one in the litmus test; I haven't looked at Roman's > code) does seem valid. In addition to removing either > synchronize_rcu(), interchanging the order of the stores in P0 (c > first, then w) would also invalidate it. > > This is a little unusual in that c is written by more than one thread > with no protection. It works because the writes are all stores of a > single pointer. > > Why does the litmus test use smp_store_release() in three places? > There doesn't seem to be any need; WRITE_ONCE() would be sufficient. Because the algorithm did. A bit of a stretch for kfree, but... ;-) Let's try removing them, please see below. > Alan > > > Does this in fact realistically model Roman's algorithm? Either way, > > is there a better approach? > > > > Thanx, Paul > > > > ------------------------------------------------------------------------ > > > > C C-RomanPenyaev-list-rcu-rr > > > > { > > int *z=1; (* List: v->w->x->y->z. Noncircular, but long enough. *) > > int *y=z; > > int *x=y; > > int *w=x; > > int *v=w; (* List head is v. *) > > int *c=w; (* Cache, emulating ppcpu_con. *) > > } > > > > P0(int *c, int *v, int *w, int *x, int *y) > > { > > rcu_assign_pointer(*w, y); /* Remove x from list. */ No change when converting this to WRITE_ONCE(); > > synchronize_rcu(); > > r1 = READ_ONCE(*c); > > if (r1 == x) { > > WRITE_ONCE(*c, 0); /* Invalidate cache. */ > > synchronize_rcu(); > > } > > smp_store_release(x, 0); /* Emulate kfree(x). */ Converting this one to WRITE_ONCE() does have an effect: Test C-RomanPenyaev-list-rcu-rr Allowed States 8 0:r1=0; 1:r1=w; 1:r2=x; 1:r3=x; 1:r4=0; c=0; v=w; w=y; x=0; y=z; 0:r1=w; 1:r1=w; 1:r2=y; 1:r3=y; 1:r4=z; c=z; v=w; w=y; x=0; y=z; 0:r1=x; 1:r1=w; 1:r2=x; 1:r3=w; 1:r4=y; c=y; v=w; w=y; x=0; y=z; 0:r1=x; 1:r1=w; 1:r2=x; 1:r3=x; 1:r4=y; c=0; v=w; w=y; x=0; y=z; 0:r1=x; 1:r1=w; 1:r2=x; 1:r3=x; 1:r4=y; c=y; v=w; w=y; x=0; y=z; 0:r1=y; 1:r1=w; 1:r2=x; 1:r3=x; 1:r4=y; c=y; v=w; w=y; x=0; y=z; 0:r1=y; 1:r1=w; 1:r2=y; 1:r3=y; 1:r4=z; c=z; v=w; w=y; x=0; y=z; 0:r1=z; 1:r1=w; 1:r2=y; 1:r3=y; 1:r4=z; c=z; v=w; w=y; x=0; y=z; Ok Witnesses Positive: 1 Negative: 7 Condition exists (1:r1=0 \/ 1:r2=0 \/ 1:r3=0 \/ 1:r4=0) Observation C-RomanPenyaev-list-rcu-rr Sometimes 1 7 Time C-RomanPenyaev-list-rcu-rr 0.40 Hash=2ec66290a6622117b9877436950e6a08 Maybe reordered with READ_ONCE(*c) when r1 != x? > > } > > > > P1(int *c, int *v) > > { > > rcu_read_lock(); > > r1 = READ_ONCE(*c); /* Pick up cache. */ > > if (r1 == 0) { > > r1 = READ_ONCE(*v); /* Cache empty, start from head. */ > > } > > r2 = rcu_dereference(*r1); /* Advance to next element. */ > > smp_store_release(c, r2); /* Update cache. */ > > rcu_read_unlock(); > > > > /* And repeat. */ > > rcu_read_lock(); > > r3 = READ_ONCE(*c); > > if (r3 == 0) { > > r3 = READ_ONCE(*v); > > } > > r4 = rcu_dereference(*r3); > > smp_store_release(c, r4); Converting this to WRITE_ONCE() has no effect. > > rcu_read_unlock(); > > } > > > > locations [0:r1; 1:r1; 1:r3; c; v; w; x; y] > > exists (1:r1=0 \/ 1:r2=0 \/ 1:r3=0 \/ 1:r4=0) (* Better not be freed!!! *) > Thanx, Paul