Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2399051pxa; Fri, 7 Aug 2020 10:09:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy1S9x6dDk7L0QH8XkQkSTfEASJrchKHS+2xXCORrChmvGI+BWWOu9RLBojaugiVkOBzGt4 X-Received: by 2002:a17:906:2e09:: with SMTP id n9mr10923035eji.0.1596820154663; Fri, 07 Aug 2020 10:09:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596820154; cv=none; d=google.com; s=arc-20160816; b=T6vnpA2b35i981/Ha+KjgUzqfMNmfXHHQCHbC/Yla9pwcFdqitivd68wAh/mHdzxjJ Ls9UKP5m5uliP5+8S3iVQ7HM/paGLWClo1TeekqUdD8tl3UROqq1vEu2kvSAhGfCTNzl K/1PwwILzqNu8WmYcYjDnZWswpxGGuXNSwFgSEN7ax9961eeKjAh/mWTSUGT6cJddOyE KWMkOkyEm2rZzGEVOjnnyflUMAxt2Hwi8xrujcBf7rikoxPfouDw9+1zNdY1segtXW0O kba62ZqWOnRPLbyB83+niJ/6NbAxv768kkG8BdOTwi88WVMckWbtrNjRuxDdxYdugMnH xrFA== 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:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=r/kgVzAykl5yGnJA2GIl6acqSPrU9q7mp174snysesk=; b=sx7M1lv0QiBxO+atdoBOQCbBqFBQ9qK5jFgUfNkKDwEj5rXnsXaHwEQIO7XuVyQLUD fVCqLERVCxOlekhjhDAZzjAqcVhxFOcikdSvgGFbtQtvK8M0Aq4RWOwP662+1LRMOupe oVnp3G155CfWLb/jeVxfprbh0LrggI3ABq8M8S1KGIOTj5jRvT8kkuDJtU3DtUHCiP6b XMhTjda0/qtskx+VuyCUJxP+GYHif4CHdqKuGE/CzkYS75JW6LQJhEqq7VybJ+F9W2hV 3IzaWMvQuGjcED5LBaNiz0ZxsZL9joz0ckdKshDVHaa12GaqRZ2vQyRlZ32pjrCl3UXM u42A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=wXfzHbu+; 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 j18si5248580edq.576.2020.08.07.10.08.52; Fri, 07 Aug 2020 10:09:14 -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=wXfzHbu+; 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 S1726974AbgHGRII (ORCPT + 99 others); Fri, 7 Aug 2020 13:08:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41552 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726058AbgHGRH6 (ORCPT ); Fri, 7 Aug 2020 13:07:58 -0400 Received: from mail-qt1-x844.google.com (mail-qt1-x844.google.com [IPv6:2607:f8b0:4864:20::844]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 92706C061D7C for ; Fri, 7 Aug 2020 10:07:34 -0700 (PDT) Received: by mail-qt1-x844.google.com with SMTP id s23so1773303qtq.12 for ; Fri, 07 Aug 2020 10:07:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=r/kgVzAykl5yGnJA2GIl6acqSPrU9q7mp174snysesk=; b=wXfzHbu+Q0Ah3V/z4NLs6+FKnKMptcw04eJgCWIYFED1/z/Ph9Ow8uHQ4P0cBdv47P ZcU0rMPMlQkFOleTqPHawzaA1I7aH7QVeEs020BX+4THmB2Ehfg++kaXysKXhC/m1m+a +ags24NlB5PWImrQVaJpjxSpxujkCoOslN7aA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=r/kgVzAykl5yGnJA2GIl6acqSPrU9q7mp174snysesk=; b=lloOkYbIxbzy1eFVZ6sISHoQrtzkVrARDIZW1FyFRsH3WhGwfT77mWbK9QUVDAObma LLaCFOC5WBLcQf4puPSJibsgWboRL6RY0tNUbyoXtriiYp2DK11+dVhfLGtUpOGYtVCd wPlwIlBUg4YKR+qXhNLJc8GIp0vIwpzQrFyBs1pGDNaK2P1jiw2j8f19RN61Ac2/Msl1 w0vIOdYY7gxuAsePGCe8ZMS8+FQn7F6U5RlPNW8VVa1frGmdoonzCYy1oMdHIeM0z3B7 Oy2qYAKgKzgWj+2YWjV4fY0y5LsVl0ObYBFI4KU9Ps+JKySvzj2mm6M1HqAtILTilFdP bGYA== X-Gm-Message-State: AOAM533jZVHELjQJs3c4JStSq5x7g8n/hDtAdm14lZIop89gN21//8TU xdHLF8rnYleEkpJzPgCm8ooTBRWxyzY= X-Received: by 2002:ac8:4719:: with SMTP id f25mr15357892qtp.291.1596820053592; Fri, 07 Aug 2020 10:07:33 -0700 (PDT) Received: from joelaf.cam.corp.google.com ([2620:15c:6:12:cad3:ffff:feb3:bd59]) by smtp.gmail.com with ESMTPSA id w18sm8559905qtk.1.2020.08.07.10.07.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Aug 2020 10:07:33 -0700 (PDT) From: "Joel Fernandes (Google)" To: linux-kernel@vger.kernel.org Cc: "Joel Fernandes (Google)" , 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, Randy Dunlap , rcu@vger.kernel.org, Steven Rostedt , tglx@linutronix.de, vineethrp@gmail.com Subject: [PATCH v4 5/5] docs: Update RCU's hotplug requirements with a bit about design Date: Fri, 7 Aug 2020 13:07:22 -0400 Message-Id: <20200807170722.2897328-6-joel@joelfernandes.org> X-Mailer: git-send-email 2.28.0.236.gb10cc79966-goog In-Reply-To: <20200807170722.2897328-1-joel@joelfernandes.org> References: <20200807170722.2897328-1-joel@joelfernandes.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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()``). +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 a report +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.236.gb10cc79966-goog