Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp4038434pxk; Tue, 29 Sep 2020 12:34:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzV7EhSqktn1QZ0YZaojm8V4Y0XJh8D1oiVhUIvpRPi5gVc5xhluCEjn3LLhh98bTU2/zwF X-Received: by 2002:a05:6402:7d2:: with SMTP id u18mr5072497edy.69.1601408066778; Tue, 29 Sep 2020 12:34:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601408066; cv=none; d=google.com; s=arc-20160816; b=rbYpx6sgrnceQaK0f+v/bOYNPQdX8A4tEfJWenf7JlzkXkq/T1Y0O8KG3vHfiaUmg0 +Lf5Lc2GIvHNXpuX9VEljGeW+EnO9HErcsoeonjs5KoMPF0HZwrWZ7dP+iO2SqsqV8Jt epmZOBzvpLa0H/Eo+pHS74POpuhNZSUIAVmI6ROuLahlI9n6xxsyVvSjAMRG7i2SurZp 21qTUaSIy6skibd4Ul4yCenPhvWHbAWYULc6emXsZSisrOqUwN8Dnwb8Kq57g0t0Kiq+ hCLJDGAJQyhL0ditU62vXE/pN+YRh2rRmCkIscM2RfHPTJF80rRO3T5LTKr/hKzUCNFv D6/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=Zg8iMIsBc8YQg4a8RQTBuYUHUxGslvf65TSd1TPBfWg=; b=v7SGdIczdYPcsEnGXf8xeWT+ysyz+gb3W59/ESjchkVUPQmU09vfiOJaCSVQgh3ZLS SUiGKlsI2tT7qKMXPiJ1k7DxVBMU5yeIIbqfWNAJsTNIBsFHSLjBcIqB+uxHk9ezDwEz 6oqrddYKClLDB2pVcdMZgkIBqBBaM2SyCdCPmr1DHfk/Wv02m3ZsT/v/Sexd3lQCTYZR Dp2m+cSAeaLOO5F6227/gfTWjh3vWOrjkoDVe0R9ERTIRipjRLU+T9xHRk3osZJitga7 QMfaRXPUmCJdYcY+5O/8+Yy7Bdu2dv3x5jaQfWpSN2yX42K7K/8df4tUbnllVue6b3iD NToQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=RG93ImRV; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id rs1si3450109ejb.201.2020.09.29.12.34.03; Tue, 29 Sep 2020 12:34:26 -0700 (PDT) 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=@joelfernandes.org header.s=google header.b=RG93ImRV; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727740AbgI2Tcw (ORCPT + 99 others); Tue, 29 Sep 2020 15:32:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55662 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728337AbgI2Tcv (ORCPT ); Tue, 29 Sep 2020 15:32:51 -0400 Received: from mail-qk1-x741.google.com (mail-qk1-x741.google.com [IPv6:2607:f8b0:4864:20::741]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 74728C0613D1 for ; Tue, 29 Sep 2020 12:32:51 -0700 (PDT) Received: by mail-qk1-x741.google.com with SMTP id q5so5588593qkc.2 for ; Tue, 29 Sep 2020 12:32:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=Zg8iMIsBc8YQg4a8RQTBuYUHUxGslvf65TSd1TPBfWg=; b=RG93ImRVwF+OzQrBZ8j5zTbvCaOPy7Xp/13LbPge6pGaB3bKpqb1rgobFK4hOK3wOU Y4yOvSQ2gSxm9OSBGLGMylRedgr6a9fMhUtOVuviFDxbmpq+8Si0hneHqdEhr/i2jDlN bvi4t/A5P2Z6x6UpLOkYgtvwcedCmUdyOE+EQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=Zg8iMIsBc8YQg4a8RQTBuYUHUxGslvf65TSd1TPBfWg=; b=UwJfCG3lE2lyo+iZ00GTvdYzDeXrJmUudsV1P0+U932Z6sNLTcMybbj8A9YzSkxHHe 6cQkt7LjGbJ09O9afrf/pUFG/OqETsCc5iGH+mInbG9AqbUSrTI/9QTxxnBscsQz+zHI OSRLFMV46bXz/3+E9qJB//988LV29mXIft+Ka1M6o/ywgpHA5hHHe3D2EEVV0YUCN/9p n9/Op3CAPZp5Rp3DkIdpJQjpsvBTd1UMzoCjZrKmHsYsfPJmIu094IyJnjCnFEFWVpdX YJIHRPPpwCNMpT+w+Htygim4NuHh0t3dxno5rrFTTFUC65j3bUD7CG2W8Zhcv89tcLvh 4+uw== X-Gm-Message-State: AOAM5315xqi+3vb9E+IYm7gCcB13+tM36LBZAfBgPfvHH0YuajfvLSgQ pMoauMZ/kLWyP899TSffJ67oruTRoyGJGA== X-Received: by 2002:a37:a5c6:: with SMTP id o189mr5748497qke.209.1601407970312; Tue, 29 Sep 2020 12:32:50 -0700 (PDT) Received: from localhost ([2620:15c:6:12:cad3:ffff:feb3:bd59]) by smtp.gmail.com with ESMTPSA id q8sm6062295qkq.57.2020.09.29.12.32.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Sep 2020 12:32:49 -0700 (PDT) Date: Tue, 29 Sep 2020 15:32:48 -0400 From: Joel Fernandes To: linux-kernel@vger.kernel.org, "Paul E. McKenney" Cc: Jonathan Corbet , Josh Triplett , Lai Jiangshan , linux-doc@vger.kernel.org, Mathieu Desnoyers , Mauro Carvalho Chehab , Neeraj Upadhyay , Randy Dunlap , rcu@vger.kernel.org, Steven Rostedt , Will Deacon Subject: Re: [PATCH 2/2] docs: Update RCU's hotplug requirements with a bit about design Message-ID: <20200929193248.GA3749988@google.com> References: <20200929192928.3749502-1-joel@joelfernandes.org> <20200929192928.3749502-2-joel@joelfernandes.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200929192928.3749502-2-joel@joelfernandes.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Paul, On Tue, Sep 29, 2020 at 03:29:28PM -0400, Joel Fernandes (Google) wrote: > RCU's hotplug design will help understand the requirements an RCU > implementation needs to fullfill, such as dead-lock avoidance. > > The rcu_barrier() section of the "Hotplug CPU" section already talks > about deadlocks, however the description of what else can deadlock other > than rcu_barrier is rather incomplete. > > This commit therefore continues the section by describing how RCU's > design handles CPU hotplug in a deadlock-free way. > > Signed-off-by: Joel Fernandes (Google) > --- > .../RCU/Design/Requirements/Requirements.rst | 30 +++++++++++++++++-- > 1 file changed, 28 insertions(+), 2 deletions(-) > > diff --git a/Documentation/RCU/Design/Requirements/Requirements.rst b/Documentation/RCU/Design/Requirements/Requirements.rst > index 1ae79a10a8de..e0413aa989dd 100644 > --- a/Documentation/RCU/Design/Requirements/Requirements.rst > +++ b/Documentation/RCU/Design/Requirements/Requirements.rst > @@ -1929,8 +1929,10 @@ The Linux-kernel CPU-hotplug implementation has notifiers that are used > to allow the various kernel subsystems (including RCU) to respond > appropriately to a given CPU-hotplug operation. Most RCU operations may > be invoked from CPU-hotplug notifiers, including even synchronous > -grace-period operations such as ``synchronize_rcu()`` and > -``synchronize_rcu_expedited()``. > +grace-period operations such as. However, the synchronous variants > +(``synchronize_rcu()`` and ``synchronize_rcu_expedited()``) should not > +from notifiers that execute via ``stop_machine()`` -- specifically those The "should not from notifiers" should be "should not be used from notifiers" here. Sorry and hope you can fix it up. thanks, - Joel > +between the ``CPUHP_AP_OFFLINE`` and ``CPUHP_AP_ONLINE`` states. > > However, all-callback-wait operations such as ``rcu_barrier()`` are also > not supported, due to the fact that there are phases of CPU-hotplug > @@ -1940,6 +1942,30 @@ deadlock. Furthermore, ``rcu_barrier()`` blocks CPU-hotplug operations > during its execution, which results in another type of deadlock when > invoked from a CPU-hotplug notifier. > > +Also, RCU's implementation avoids serious deadlocks which could occur due to > +interaction between hotplug, timers and grace period processing. It does so by > +maintaining its own books of every CPU's hotplug state, independent of > +the existing general-purpose CPU masks and by reporting quiescent states > +explictly when an online CPU is going down. Due to this design, the force > +quiescent state loop (FQS) is not required to report quiescent states for > +offline CPUs, like it does for idle CPUs, but it does splat if offline CPUs are > +stalling the RCU grace period for too long. > + > +For an offline CPU, the quiescent state will be reported in either of: > +1. During CPU offlining, using RCU's hotplug notifier (``rcu_report_dead()``). > +2. During grace period initialization (``rcu_gp_init()``) if it detected a race > + with CPU offlining, or a race with a task unblocking on a node which > + previously had all of its CPUs offlined. > + > +The CPU onlining path (``rcu_cpu_starting()``) does not need to report a > +quiescent state for an offline CPU; in fact it would trigger a warning if a > +quiescent state was not already reported for that CPU. > + > +During the checking/modification of RCU's hotplug bookkeeping, the > +corresponding CPU's leaf node lock is held. This avoids race conditions between > +RCU's hotplug notifier hooks, grace period initialization code and the FQS loop > +which can concurrently refer to or modify the bookkeeping. > + > Scheduler and RCU > ~~~~~~~~~~~~~~~~~ > > -- > 2.28.0.709.gb0816b6eb0-goog >