Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2698975pxa; Fri, 7 Aug 2020 19:11:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyOkF3R/7ztYtroCUQirGW0y62OJehEaEFnefDuwax0yh3D+H9SlZlClkLO3sQr6tVyXc9d X-Received: by 2002:a17:906:4ec6:: with SMTP id i6mr12049566ejv.358.1596852706149; Fri, 07 Aug 2020 19:11:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596852706; cv=none; d=google.com; s=arc-20160816; b=p0Gzi7usB/eTJRS1pAqWkDhf9RkGsUM6sH93BaSBqAAtVVndTnY7wcaOfuzNOOs+fG 7rFXSeubLdKWdgYGX56SbizMaZ8PTMtn/6qnxjoTb6xd58Ah1gpObqMretaU7o8mwRPh Qs576n65BZbNx4UV+236mjGpcYrJJlIi5aIS9fMSkiOsX+JA4ey/YAVB9lKf4n4AaNGZ RBqRkMEtHMuQZYCT+vUzKWHqiG+7Wm5l3pSHzm2RzyjQK3/Q6/59rh4qEGT6QCHRIR9K ceP47UEs+pvFR+pJvccfFwvEVwVQSAZTHll8cyR4StIelL084Uxtyk9CVCoPzpNnvK8q lACQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=dAc45tHUZg/nA18kqJXnyW3iWQd/66a54f+Y05m+B4M=; b=kkSUZjGZRanhWq6PRrT0ERcfuzHBjLeIKYt+aq89h9tsAm0OStKNd+BxFbean1v/Vn jHaoKFeEUmuHr6i7XdohmKqCy1J0NgzmvCSkLgj1qSczvBIieopX1fa1P8h7Qg7Vm07s c/u6NrF2CaEDabieLlUA4G/BddAL+97kwPpMMiW6cFOfFrE9mhwAvsp7nL+yo7jg77TO qEzHXGoEBXILSTOkHLbmp70sGlwKlzZXC/3hfYz1xlo4Fg1vaMNNsLn3M2rTmSE1AOc6 unge8WWSsaip3POq6MvNhPttGr4cE8NuqGB8KoD3h5Bu+cUEwwSkbvN0Plsu0Cfp4LvS MtMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=casper.20170209 header.b=cUedCzUV; 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 t28si6568249edt.38.2020.08.07.19.11.22; Fri, 07 Aug 2020 19:11:46 -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=fail header.i=@infradead.org header.s=casper.20170209 header.b=cUedCzUV; 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 S1726224AbgHHCKy (ORCPT + 99 others); Fri, 7 Aug 2020 22:10:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40056 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726186AbgHHCKy (ORCPT ); Fri, 7 Aug 2020 22:10:54 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F3688C061756; Fri, 7 Aug 2020 19:10:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:Content-Type: In-Reply-To:MIME-Version:Date:Message-ID:From:References:Cc:To:Subject:Sender :Reply-To:Content-ID:Content-Description; bh=dAc45tHUZg/nA18kqJXnyW3iWQd/66a54f+Y05m+B4M=; b=cUedCzUVuG/kdcYUB1LvFSU407 db62UF1AmSSOaTKZgCLiqYvGMoT4022iaa3WsY1YgYWNBPy/yWqwZwnlc2yDgg4Q/nd+6/sOOA2eS p2VmSw3Nats5kSNswVWnDDvvv09PIUSOvMf1bWT5n1HrvwQvdop9tbVDDsQQAopV4WDyE8ucGXNcJ bfCj2GfIfcDaxkSM+6SY/ifXpX809XezL1UX4oX9HdUuVGneaA7g1h02mPD4D9cY71XSnBaCJZc29 ny9XPuB46xQZaiYYUnAVq8ZHpHcy96pRaRYrUCP3Ai0TP9XxaDEgrZxqYsN7WCgFxvlv7mQaeWltj vgXnt4Vg==; Received: from [2601:1c0:6280:3f0:897c:6038:c71d:ecac] by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1k4EJm-000702-Vl; Sat, 08 Aug 2020 02:10:43 +0000 Subject: Re: [PATCH v4 5/5] docs: Update RCU's hotplug requirements with a bit about design To: "Joel Fernandes (Google)" , linux-kernel@vger.kernel.org Cc: Davidlohr Bueso , Jonathan Corbet , Josh Triplett , Lai Jiangshan , linux-doc@vger.kernel.org, Mathieu Desnoyers , Mauro Carvalho Chehab , neeraju@codeaurora.org, "Paul E. McKenney" , peterz@infradead.org, rcu@vger.kernel.org, Steven Rostedt , tglx@linutronix.de, vineethrp@gmail.com References: <20200807170722.2897328-1-joel@joelfernandes.org> <20200807170722.2897328-6-joel@joelfernandes.org> From: Randy Dunlap Message-ID: <4b8646fd-7644-bd8a-54ad-d0cb80b04317@infradead.org> Date: Fri, 7 Aug 2020 19:10:38 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20200807170722.2897328-6-joel@joelfernandes.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi-- On 8/7/20 10:07 AM, 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 | 22 +++++++++++++++++++ > 1 file changed, 22 insertions(+) > > diff --git a/Documentation/RCU/Design/Requirements/Requirements.rst b/Documentation/RCU/Design/Requirements/Requirements.rst > index 16c64a2eff93..0a4148b9f743 100644 > --- a/Documentation/RCU/Design/Requirements/Requirements.rst > +++ b/Documentation/RCU/Design/Requirements/Requirements.rst > @@ -1940,6 +1940,28 @@ 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 bookkeeping of every CPU's hotplug state, independent of > +the various CPU masks and by reporting quiescent states at explicit points. It > +may come across as a surprise, but the force quiescent state loop (FQS) does > +not report quiescent states for offline CPUs and is not required to. > + > +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()``). note, uses (), which is good: () > +2. During grace period initialization (``rcu_gp_init``) if it detected a race add for consistency & readability: rcu_gp_init() > + 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 a report ditto: rcu_cpu_starting() > +quiescent state for an offline CPU in fact it would trigger a warning if a Missing something; maybe like so: for an offline CPU; in fact > +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 > ~~~~~~~~~~~~~~~~~ > > cheers. -- ~Randy