Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1589205pxb; Thu, 4 Mar 2021 15:37:35 -0800 (PST) X-Google-Smtp-Source: ABdhPJxx8ZhLkGGY4FgtloPKqQu/WCwv8duCuJ+0FEQYfgwPwASCCxAnQ399RMBqUE2PgwaSdnxH X-Received: by 2002:a17:906:3b47:: with SMTP id h7mr6666679ejf.377.1614901055063; Thu, 04 Mar 2021 15:37:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614901055; cv=none; d=google.com; s=arc-20160816; b=it5fhcWkQ9EkFY2r/e+lekuj8m9H8jd64PC/VSh0Al1OTqQtghE5oOvwhCNn3ShJOa GaInOezXtuPDb9WeS0H64BZ9D3B5qdV5uysAz4c8Zv6v4KPGp/dvI4+M5Y2p8yLeMLri ODFPAq73A6X7XtS06tGXaDJIbpsalbZMKIDZZsoxuxL8vdZtrtFbiezUorz3T0jgb0sk I9yIsR3dNewsaCOGI01GopBcXcZLB9KOttQU/OYbNJGEAaRdW86/GAX2F6AYVgklxArE Ex1jN9kcS24Vkohypfrhe+ZHdJP8+P0ZVJnceLfH9xKuMPM7cGWs1mk0X0RVGRj5Hdzk 4w6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=7b0CJi8uy1ok3Mw6MayfrA+ssnw7y8osQlnNan695ho=; b=xsAg4T2mrtDq27/OagjpAgOBIfB7wA0UTFAHRB2pjAO23y6uWIBW0gfXGqLZu3gSNW qrGuy538DVQUsQXrqEe1j1vwowLoS6KZPMBCY+TF0dF4xLntaPoUqvW3935pnL43XqGM phg77K2D2ws5suWgm0y99M6sZIQil0KR3/eE1FcCAKOt7zLBj2DQcHx80qan1Xz7e6r6 Fk1ZNa7h2edwP8T553FrJj4EyRt7AjrkjgqjqSFPo6FYLzWu6VpurXrcQVdRp0iV1jii DsgILjPFuczCubmznx0d5IKxYlzIPqSdcoBd2EUQfe9ZJ4KVUMIrceWA6JxX9jKtZcM3 NAUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Li29YnL4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x18si348663eji.400.2021.03.04.15.37.12; Thu, 04 Mar 2021 15:37:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Li29YnL4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353374AbhCDBDS (ORCPT + 99 others); Wed, 3 Mar 2021 20:03:18 -0500 Received: from mail.kernel.org ([198.145.29.99]:47848 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1388624AbhCDAZF (ORCPT ); Wed, 3 Mar 2021 19:25:05 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4BEC964EDF; Thu, 4 Mar 2021 00:23:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1614817394; bh=nqO6TCOJhj9m7vFGpNCgO5kA+pzLX+aLpvXtcO7bMFE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Li29YnL4knzKbhz4QlThEAV2niOb35zxKqlnwEW6YDoZVEssz5m1M0qeIis+BAqLN tWIlQWjFr2+vCO1Z1sl06GyHWgpmpiTQbZ4CFd6oBpcRRgCFRLJusAb0xhCZLZ+JVF jwlCwb9EJGiBGHL9Wcbe/gOv/tjVzWrheGyP7SYxeGPPdVWX8ld07CpiwM3ymXMgCm 0eDG4zWon5ABrsOpmMV+DJc3+heWIo1hmUkD3IlKwvXikaQGuA85EMkkb/krcpVF2K 9+WZBkX905vEZ6WVZiQAeORAs4Ry8hmRHJdiQxzzVw1ogbM0oc7H7o2PmS1/YcQy40 efpFV4rbTltEQ== From: paulmck@kernel.org To: rcu@vger.kernel.org Cc: linux-kernel@vger.kernel.org, kernel-team@fb.com, mingo@kernel.org, jiangshanlai@gmail.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, Frederic Weisbecker , Neeraj Upadhyay , Boqun Feng , "Paul E . McKenney" Subject: [PATCH tip/core/rcu 06/12] rcu/nocb: Only (re-)initialize segcblist when needed on CPU up Date: Wed, 3 Mar 2021 16:23:05 -0800 Message-Id: <20210304002311.23655-6-paulmck@kernel.org> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20210304002225.GA23492@paulmck-ThinkPad-P72> References: <20210304002225.GA23492@paulmck-ThinkPad-P72> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Frederic Weisbecker At the start of a CPU-hotplug operation, the incoming CPU's callback list can be in a number of states: 1. Disabled and empty. This is the case when the boot CPU has not invoked call_rcu(), when a non-boot CPU first comes online, and when a non-offloaded CPU comes back online. In this case, it is both necessary and permissible to initialize ->cblist. Because either the CPU is currently running with interrupts disabled (boot CPU) or is not yet running at all (other CPUs), it is not necessary to acquire ->nocb_lock. In this case, initialization is required. 2. Disabled and non-empty. This cannot occur, because early boot call_rcu() invocations enable the callback list before enqueuing their callback. 3. Enabled, whether empty or not. In this case, the callback list has already been initialized. This case occurs when the boot CPU has executed an early boot call_rcu() and also when an offloaded CPU comes back online. In both cases, there is no need to initialize the callback list: In the boot-CPU case, the CPU has not (yet) gone offline, and in the offloaded case, the rcuo kthreads are taking care of business. Because it is not necessary to initialize the callback list, it is also not necessary to acquire ->nocb_lock. Therefore, checking if the segcblist is enabled suffices. This commit therefore initializes the callback list at rcutree_prepare_cpu() time only if that list is disabled. Signed-off-by: Frederic Weisbecker Cc: Josh Triplett Cc: Lai Jiangshan Cc: Joel Fernandes Cc: Neeraj Upadhyay Cc: Boqun Feng Signed-off-by: Paul E. McKenney --- kernel/rcu/tree.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c index ee77858..402ea36 100644 --- a/kernel/rcu/tree.c +++ b/kernel/rcu/tree.c @@ -4084,14 +4084,13 @@ int rcutree_prepare_cpu(unsigned int cpu) rdp->dynticks_nesting = 1; /* CPU not up, no tearing. */ rcu_dynticks_eqs_online(); raw_spin_unlock_rcu_node(rnp); /* irqs remain disabled. */ + /* - * Lock in case the CB/GP kthreads are still around handling - * old callbacks. + * Only non-NOCB CPUs that didn't have early-boot callbacks need to be + * (re-)initialized. */ - rcu_nocb_lock(rdp); - if (rcu_segcblist_empty(&rdp->cblist)) /* No early-boot CBs? */ + if (!rcu_segcblist_is_enabled(&rdp->cblist)) rcu_segcblist_init(&rdp->cblist); /* Re-enable callbacks. */ - rcu_nocb_unlock(rdp); /* * Add CPU to leaf rcu_node pending-online bitmask. Any needed -- 2.9.5