Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2956509imm; Mon, 28 May 2018 20:54:32 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrGzHWiIBa6vWU5dfSAVChoiWKSI2GawNtQmVKpvA7xpVLaQqOkFRCq+8LM+WVc7VQXxUeM X-Received: by 2002:a63:7a03:: with SMTP id v3-v6mr12133665pgc.285.1527566072581; Mon, 28 May 2018 20:54:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527566072; cv=none; d=google.com; s=arc-20160816; b=z3ueVm6kH4Ou1vifp1GQ14IP+8hMhZf6AUURMP38ptuxjQK59JQm0hOp2GpCe++IfV zonDSjQEejjqZCSZtzUfbvbn/gWd/jF1qMyuwR8jAFYBN2aVPI8TG1Xni7Mv5q+g0szF mK0erW5AI2RucLsDfzEU0tjrsLM0Q2ov/xUxq3dTjzfAAJuqtwWAstFxPFaRxa05EJfj aExDCOceONCCoTI8+bRr/b9/T7yuWr9OoeJDH2wvvjEP8b+caItl7MW3dczHHgrdHhac YpuVmgj1Kr1DkfY365yVvU+4Yh/gnBFL8xTAnFajcoo5cqeSNaU2PKlmiidYDr46TBA0 3flw== 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:content-disposition :mime-version:reply-to:subject:cc:to:from:date :arc-authentication-results; bh=nh0OnXUhtbz1A7/iby1jf55iCNggdTwSJQcQkFqX7mE=; b=SrQoNXg88HOpgkL8NiSTgzDmw++SRGSivNzPhdNbmhDLwm5CE3j40fvp3zCvBvONgd rTBxZG1ONlgBGIEjt6dC6LsPnyc5wqoJIk4H+oLnQDYYfw+uYorJqY/qDUt8WPuSI9bz gE26VN1NVE9FsOPDMdxX3VG2Xo5QXpRAm597/sN/COnZ9pY5FUlx6pmVLoG1NF6yUsR8 LOsQwH3oI5rH8uVEY1ZSTqUdff3BQS9AVXdLu3UIb7qqot7Z5p+o6e2QORJNbK19uIK9 RRuSoxjiNGzwZQAjJz3kDEAQvKidi/54E86itYpqBkTuD5Xf4K4gzihpSSTP2ws86e24 V5PA== 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 p63-v6si20720549pga.484.2018.05.28.20.54.18; Mon, 28 May 2018 20:54:32 -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 S934915AbeE1WGk (ORCPT + 99 others); Mon, 28 May 2018 18:06:40 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:56168 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934805AbeE1WGg (ORCPT ); Mon, 28 May 2018 18:06:36 -0400 Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w4SM4FL9129422 for ; Mon, 28 May 2018 18:06:36 -0400 Received: from e18.ny.us.ibm.com (e18.ny.us.ibm.com [129.33.205.208]) by mx0a-001b2d01.pphosted.com with ESMTP id 2j8n1hhsaq-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 28 May 2018 18:06:36 -0400 Received: from localhost by e18.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 28 May 2018 18:06:34 -0400 Received: from b01cxnp22034.gho.pok.ibm.com (9.57.198.24) by e18.ny.us.ibm.com (146.89.104.205) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Mon, 28 May 2018 18:06:29 -0400 Received: from b01ledav003.gho.pok.ibm.com (b01ledav003.gho.pok.ibm.com [9.57.199.108]) by b01cxnp22034.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w4SM6Srs1180132 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 28 May 2018 22:06:28 GMT Received: from b01ledav003.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B11F4B2064; Mon, 28 May 2018 19:08:10 -0400 (EDT) Received: from b01ledav003.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8F80DB205F; Mon, 28 May 2018 19:08:10 -0400 (EDT) Received: from paulmck-ThinkPad-W541 (unknown [9.85.155.31]) by b01ledav003.gho.pok.ibm.com (Postfix) with ESMTP; Mon, 28 May 2018 19:08:10 -0400 (EDT) Received: by paulmck-ThinkPad-W541 (Postfix, from userid 1000) id 17ECE16C6191; Mon, 28 May 2018 15:08:11 -0700 (PDT) Date: Mon, 28 May 2018 15:08:11 -0700 From: "Paul E. McKenney" To: linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org Cc: stern@rowland.harvard.edu, 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: LKMM litmus test for Roman Penyaev's rcu-rr Reply-To: paulmck@linux.vnet.ibm.com MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-TM-AS-GCONF: 00 x-cbid: 18052822-0044-0000-0000-0000041E72E2 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00009096; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000263; SDB=6.01039070; UDB=6.00531776; IPR=6.00818198; MB=3.00021346; MTD=3.00000008; XFM=3.00000015; UTC=2018-05-28 22:06:32 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18052822-0045-0000-0000-000008509605 Message-Id: <20180528220811.GA5221@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-05-28_13:,, 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-1805280262 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. 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. */ 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). */ } 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); 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!!! *)