Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp673020ybh; Sat, 3 Aug 2019 07:26:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqxeWKfCsYA7/GQ2FHMyacpnU9QZBVqCPe7HQqDO/cs9CvDBLnU4U8orFouR+yBzfuPPAtNx X-Received: by 2002:a17:90a:2767:: with SMTP id o94mr9207681pje.25.1564842385588; Sat, 03 Aug 2019 07:26:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564842385; cv=none; d=google.com; s=arc-20160816; b=WgaOT7T40aKYmV4c2A2KD/SG+tl/3xtBqg/DpfCEUQsFjD6rvjF4jJxYlB7xeyxcwO 7bX2wZ42c2nVFbyHs1R4/Zewlj2qA5nOzNyeyLFmj8TbqRqIgulWN1+HKLq6Om0NjlHZ H/COi9YqewvkbpBEVckEGRHqn1VXHNKygavmGZsKtc91fehktmRu57EpRDFATsTg0s7L dO4OJWaamwCEbVCXHUjvYUVD7ey4BKDKz462FjRF66x7l2EYp1FUqnfOlTHVrYnM3H8k LtEaAEAmyapJrn+NqFvC0MCZPcISbJ4gh3rZyx0Yb3W1228i53fiPDCOMX4+w0UJDR0q 2eVw== 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; bh=frfIOLqJDNrf0gH6QZ4IH2bOCL3LQZbiD2lSV1GAwpU=; b=Q5gYnrXQ4jXVjOTlosH45HIwr9zdVc/rjPDJh67TcHcX+15uOPD/yAsdtIfAbCZKFx IwLakYq0JptS13FSLQtL1F8ttPxwAlDjTNwJfXrDadDt1uAm2xtf2dEcEc4hqA3aKrL9 Fekb895AaV/oLklY+ifvZeLRxekbaoQ3eLdU3E9hnsYlezBnEOqya2Wzl25oa3yZVsDw lJXqOKLt7ohe1/+j4+JOi9K4cyyGMNj3VLT0e5xKv4YxGpAYk9vhz+r88VWR5m5oSlhc dSTktT6IpuYc8c7iy3vZ7Tlg5YNfhQgWkgmgkh7TnqZsah28ovVFrryGieBejtuj/BTa M2OA== 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 h11si9098963pju.90.2019.08.03.07.26.10; Sat, 03 Aug 2019 07:26:25 -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 S2388205AbfHBPPI (ORCPT + 99 others); Fri, 2 Aug 2019 11:15:08 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:5948 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2387655AbfHBPPI (ORCPT ); Fri, 2 Aug 2019 11:15:08 -0400 Received: from pps.filterd (m0098413.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x72F7cOx004338 for ; Fri, 2 Aug 2019 11:15:06 -0400 Received: from e12.ny.us.ibm.com (e12.ny.us.ibm.com [129.33.205.202]) by mx0b-001b2d01.pphosted.com with ESMTP id 2u4nqd5fd5-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 02 Aug 2019 11:15:06 -0400 Received: from localhost by e12.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 2 Aug 2019 16:15:06 +0100 Received: from b01cxnp23033.gho.pok.ibm.com (9.57.198.28) by e12.ny.us.ibm.com (146.89.104.199) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Fri, 2 Aug 2019 16:15:02 +0100 Received: from b01ledav003.gho.pok.ibm.com (b01ledav003.gho.pok.ibm.com [9.57.199.108]) by b01cxnp23033.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x72FF1uN12452104 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 2 Aug 2019 15:15:01 GMT Received: from b01ledav003.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id ED372B2070; Fri, 2 Aug 2019 15:15:00 +0000 (GMT) Received: from b01ledav003.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D01CCB2065; Fri, 2 Aug 2019 15:15:00 +0000 (GMT) Received: from paulmck-ThinkPad-W541 (unknown [9.70.82.154]) by b01ledav003.gho.pok.ibm.com (Postfix) with ESMTP; Fri, 2 Aug 2019 15:15:00 +0000 (GMT) Received: by paulmck-ThinkPad-W541 (Postfix, from userid 1000) id 07F2C16C9A4A; Fri, 2 Aug 2019 08:15:02 -0700 (PDT) From: "Paul E. McKenney" To: rcu@vger.kernel.org Cc: linux-kernel@vger.kernel.org, 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@joelfernandes.org, "Paul E. McKenney" Subject: [PATCH RFC tip/core/rcu 07/14] rcu/nocb: Reduce nocb_cb_wait() leaf rcu_node ->lock contention Date: Fri, 2 Aug 2019 08:14:54 -0700 X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190802151435.GA1081@linux.ibm.com> References: <20190802151435.GA1081@linux.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 19080215-0060-0000-0000-000003680564 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00011538; HX=3.00000242; KW=3.00000007; PH=3.00000004; SC=3.00000287; SDB=6.01241060; UDB=6.00654494; IPR=6.01022491; MB=3.00028010; MTD=3.00000008; XFM=3.00000015; UTC=2019-08-02 15:15:05 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19080215-0061-0000-0000-00004A6567C9 Message-Id: <20190802151501.13069-7-paulmck@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-08-02_07:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=13 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908020156 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently, nocb_cb_wait() advances callbacks on each pass through its loop, though only if it succeeds in conditionally acquiring its leaf rcu_node structure's ->lock. Despite the conditional acquisition of ->lock, this does increase contention. This commit therefore avoids advancing callbacks unless there are callbacks in ->cblist whose grace period has completed. Note that nocb_cb_wait() doesn't worry about callbacks that have not yet been assigned a grace period. The idea is that the only reason for nocb_cb_wait() to advance callbacks is to allow it to continue invoking callbacks. Time will tell whether this is the correct choice. Signed-off-by: Paul E. McKenney --- kernel/rcu/tree_plugin.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/kernel/rcu/tree_plugin.h b/kernel/rcu/tree_plugin.h index 5db39ce1cae1..02739366ef5d 100644 --- a/kernel/rcu/tree_plugin.h +++ b/kernel/rcu/tree_plugin.h @@ -2076,6 +2076,7 @@ static int rcu_nocb_gp_kthread(void *arg) */ static void nocb_cb_wait(struct rcu_data *rdp) { + unsigned long cur_gp_seq; unsigned long flags; bool needwake_gp = false; struct rcu_node *rnp = rdp->mynode; @@ -2088,7 +2089,9 @@ static void nocb_cb_wait(struct rcu_data *rdp) local_bh_enable(); lockdep_assert_irqs_enabled(); rcu_nocb_lock_irqsave(rdp, flags); - if (raw_spin_trylock_rcu_node(rnp)) { /* irqs already disabled. */ + if (rcu_segcblist_nextgp(&rdp->cblist, &cur_gp_seq) && + rcu_seq_done(&rnp->gp_seq, cur_gp_seq) && + raw_spin_trylock_rcu_node(rnp)) { /* irqs already disabled. */ needwake_gp = rcu_advance_cbs(rdp->mynode, rdp); raw_spin_unlock_rcu_node(rnp); /* irqs remain disabled. */ } -- 2.17.1