Received: by 10.192.165.148 with SMTP id m20csp2949051imm; Sun, 22 Apr 2018 20:07:00 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+/fneJvqflvVjjwqD7ewiO/bLiiN2QuNNAUMsY3EOkl4g5kY0+ZA1fnJLhtlt3P0SZIvRF X-Received: by 10.99.1.10 with SMTP id 10mr15639777pgb.444.1524452820673; Sun, 22 Apr 2018 20:07:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524452820; cv=none; d=google.com; s=arc-20160816; b=mt6mYjZKEIvv8Uij2TzN6tVDt6ZB4UOCmGnH/0EYjKCZJhBXbs1E0hhj37UMQdsp20 QJamYvldNcV80aChN1EHqFjzh8G/rGGiNL1b6YKRX9wijKiNMETDBK6As3p7dH+XyX36 3Zu7PKtcy/Zp0fU6wa61mXCJwbZ78c1JlYR6MElIWpBfYqOZtC74EDA1/BtI9vqS3265 hR9KcKPlzoDDJvtRz+YFmdOVSpPWIcei32DsaVUzA4ZtdF7hSO1vFWPuvAi8qAwTYeFD tNG+T6k9QBzFZwnaqtjBWfnhu+IxHcwC07JJZWtNX1mp4fdzLE27mEF+vKfqvaxr1cpb qLPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:references:in-reply-to:date :subject:cc:to:from:arc-authentication-results; bh=qi7alqxBDX4PSUzLg02a3CBejOLvqiH5woz1Wm5f+nM=; b=Vd12RM2y8k6/Tc7GTdahaQxNM5RtNVU5xo3YkX9bT+b5V3CSzm7nrL3TyrBXVpwNJr P6zE6IxJiTUi6kjMRPmO/bN4vpu+VYTier2xWlCiYa4vAUUEknbg2UNOboCNgXpsRkXT hzLJXueXxyyhyJMigKMD5+VWM97y3eW8GR5TIGvNYCiPSDx2uJwHxgDG/ChMngHjBcdf 8Gq1LZQKnBxdJZjQsVFTuUACeaP/fvHfdrHFAhd4cHkwMQ53jlsSnE3rkgaAOAXgYhkh ho2kV7bTeK6NLmyIAMrtyx4JhDb5OhW25a/MHn3+guEd8qc0wFhjdR/dzn0/T8a2UTz+ PsUA== 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 bi10-v6si6926492plb.49.2018.04.22.20.06.46; Sun, 22 Apr 2018 20:07:00 -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 S1754001AbeDWDCl (ORCPT + 99 others); Sun, 22 Apr 2018 23:02:41 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:39846 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753848AbeDWDCi (ORCPT ); Sun, 22 Apr 2018 23:02:38 -0400 Received: from pps.filterd (m0098393.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w3N2xZf4103622 for ; Sun, 22 Apr 2018 23:02:38 -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 2hh45g580k-1 (version=TLSv1.2 cipher=AES256-SHA256 bits=256 verify=NOT) for ; Sun, 22 Apr 2018 23:02:37 -0400 Received: from localhost by e18.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Sun, 22 Apr 2018 23:02:36 -0400 Received: from b01cxnp23034.gho.pok.ibm.com (9.57.198.29) by e18.ny.us.ibm.com (146.89.104.205) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Sun, 22 Apr 2018 23:02:32 -0400 Received: from b01ledav003.gho.pok.ibm.com (b01ledav003.gho.pok.ibm.com [9.57.199.108]) by b01cxnp23034.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w3N32WKV51052674; Mon, 23 Apr 2018 03:02:32 GMT Received: from b01ledav003.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CF10DB2067; Mon, 23 Apr 2018 00:04:34 -0400 (EDT) Received: from paulmck-ThinkPad-W541 (unknown [9.85.149.45]) by b01ledav003.gho.pok.ibm.com (Postfix) with ESMTP id 9AE32B2054; Mon, 23 Apr 2018 00:04:34 -0400 (EDT) Received: by paulmck-ThinkPad-W541 (Postfix, from userid 1000) id 1A05616C8D4F; Sun, 22 Apr 2018 20:03:45 -0700 (PDT) From: "Paul E. McKenney" To: linux-kernel@vger.kernel.org Cc: mingo@kernel.org, jiangshanlai@gmail.com, dipankar@in.ibm.com, akpm@linux-foundation.org, mathieu.desnoyers@efficios.com, josh@joshtriplett.org, tglx@linutronix.de, peterz@infradead.org, rostedt@goodmis.org, dhowells@redhat.com, edumazet@google.com, fweisbec@gmail.com, oleg@redhat.com, joel.opensrc@gmail.com, torvalds@linux-foundation.org, npiggin@gmail.com, "Paul E. McKenney" Subject: [PATCH tip/core/rcu 06/21] rcu: Avoid losing ->need_future_gp[] values due to GP start/end races Date: Sun, 22 Apr 2018 20:03:29 -0700 X-Mailer: git-send-email 2.5.2 In-Reply-To: <20180423030258.GA23370@linux.vnet.ibm.com> References: <20180423030258.GA23370@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18042303-0044-0000-0000-0000040974B2 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00008903; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000257; SDB=6.01021898; UDB=6.00521542; IPR=6.00801133; MB=3.00020719; MTD=3.00000008; XFM=3.00000015; UTC=2018-04-23 03:02:36 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18042303-0045-0000-0000-0000083B7DB2 Message-Id: <1524452624-27589-6-git-send-email-paulmck@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-04-23_01:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 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-1804230032 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The rcu_cbs_completed() function provides the value of ->completed at which new callbacks can safely be invoked. This is recorded in two-element ->need_future_gp[] arrays in the rcu_node structure, and the elements of these arrays corresponding to the just-completed grace period are zeroed at the end of that grace period. However, the rcu_cbs_completed() function can return the current ->completed value plus either one or two, so it is possible for the corresponding ->need_future_gp[] entry to be cleared just after it was set, thus losing a request for a future grace period. This commit avoids this race by expanding ->need_future_gp[] to four elements. Signed-off-by: Paul E. McKenney --- kernel/rcu/tree.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/kernel/rcu/tree.h b/kernel/rcu/tree.h index bd1103763551..952cd0c223fe 100644 --- a/kernel/rcu/tree.h +++ b/kernel/rcu/tree.h @@ -150,8 +150,7 @@ struct rcu_node { struct swait_queue_head nocb_gp_wq[2]; /* Place for rcu_nocb_kthread() to wait GP. */ #endif /* #ifdef CONFIG_RCU_NOCB_CPU */ - int need_future_gp[2]; - /* Counts of upcoming no-CB GP requests. */ + int need_future_gp[4]; /* Counts of upcoming no-CB GP requests. */ raw_spinlock_t fqslock ____cacheline_internodealigned_in_smp; spinlock_t exp_lock ____cacheline_internodealigned_in_smp; -- 2.5.2