Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1078836pxb; Wed, 29 Sep 2021 16:41:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwmgv46rvbgPR70Kp8dVBn8c7fkiTR4GsNwrQWJyNsDQ9NdQKZIGMVU7cf+cArtS8Nc7wDT X-Received: by 2002:a17:906:4b09:: with SMTP id y9mr2540090eju.426.1632958867401; Wed, 29 Sep 2021 16:41:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632958867; cv=none; d=google.com; s=arc-20160816; b=hgFa6jC34AdfYEUCCY60QCmtuuk2v5LnKvvUCJg7D+5qieRHGN87uyCbpXsp9b4vy8 IxPV9vr88W2azY0nd3kpI0FDK3kvl/Thk8EeC/FdkbTjjowv2R6+kKZuNCrca/6Bd6eg Q/2zja4H4mt8KHfzg3HKiW59vJsmhwZ7gyspCKiPElXhG6zGNHffDeP3OSsBPY9HK9Wa 9lEoj9VSCPs4TMXqGPl/4ulRHXZ1Ijt+DQzq7ezprdo52ktlSqpYkf86hn6wB/0c/+kq 9mM0S6f1kWMWjjV6i8OHoGseYEE38GvLD8eZ/tOOjr/AMzLJG3jQgCbign4QZh8/R6uJ WI2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=k8ktWCqWe/6n8JCW9FKnw7MzNm/CDVeWId8BXc1eXXY=; b=uqiotXdmVo/INckk3GzqwOWcZmaOr6CmLf/zs3tx2OOz0p1MT0yVVmDbuSz/PievuA bN/2euwE5HookvyKQ8ypabPoCT/LKzkQbJ0J/mgESedShWVUwbM6v0C82CZPlqZXxNUX Bjv02y0O/v/IUKxyOAcq/Kh6iJf6A8RNtnJ5XTNjGg9osoGSmNKb8RYNHi/38IdiIWIp 2g8mJvjXRj+JAtOufa7vkX2Hhf/+fysPOgrVGtt+JHJ+xGj7uAQ26qKjDRYlWZ11NTPE spKVZM7LSdRuBFDaqeF0DlWh+QMK7CxMvXTuqgcCqyeRQb9RAt593lNt/B14hOPTb2Tf iUOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=fnpTQdc6; 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 b24si1514012edy.524.2021.09.29.16.40.44; Wed, 29 Sep 2021 16:41:07 -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=@kernel.org header.s=k20201202 header.b=fnpTQdc6; 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 S1347209AbhI2WMS (ORCPT + 99 others); Wed, 29 Sep 2021 18:12:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:60748 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347201AbhI2WMO (ORCPT ); Wed, 29 Sep 2021 18:12:14 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1882061440; Wed, 29 Sep 2021 22:10:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1632953432; bh=HHEYbmDWJcCLR1Dcr206w9h3MV5IHYYb74Xn1Ko6x28=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fnpTQdc6YiYV7xvuR6uAf7RRF3JWFT9iIXW4w+YUlxW+A1W/tcrd0ye6HyHRK53tv 5YQm6TBCDC0mLkaBRiNw8pHzT+vkK+f7CR5368jquzmL/gzehM6WLYVTQURAAJNNnP xkOuusudZCeboVRep+pH3Uvo1pkQVAtpABw9yOCdCEXtdd6VxAFVw/wd1dHxDJc9gP C/ba4W4CJjqMS1C9vsQmLZHtNwP2sOklTP6FIITmewpGzYuZZGfgdAOOub2ABQ+mVM 4nA2VOgUoHctZh2jAnZDGOhxk2dVRBP+sM6iNoDA5J445Wu7K6XRIVB+TNWSSctfLW HeyD+7pZI+Ylg== From: Frederic Weisbecker To: "Paul E . McKenney" Cc: LKML , Frederic Weisbecker , Sebastian Andrzej Siewior , Peter Zijlstra , Uladzislau Rezki , Valentin Schneider , Thomas Gleixner , Boqun Feng , Neeraj Upadhyay , Josh Triplett , Joel Fernandes , rcu@vger.kernel.org Subject: [PATCH 05/11] rcu/nocb: Make rcu_core() callbacks acceleration (de-)offloading safe Date: Thu, 30 Sep 2021 00:10:06 +0200 Message-Id: <20210929221012.228270-6-frederic@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210929221012.228270-1-frederic@kernel.org> References: <20210929221012.228270-1-frederic@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When callbacks are offloaded, the NOCB kthreads handle the callbacks progression on behalf of rcu_core(). However during the (de-)offloading process, the kthread may not be entirely up to the task. As a result some callbacks grace period sequence number may remain stale for a while because rcu_core() won't take care of them either. Fix this with forcing callbacks acceleration from rcu_core() as long as the offloading process isn't complete. Reported-by: Valentin Schneider Signed-off-by: Frederic Weisbecker Cc: Valentin Schneider Cc: Peter Zijlstra Cc: Sebastian Andrzej Siewior Cc: Josh Triplett Cc: Joel Fernandes Cc: Boqun Feng Cc: Neeraj Upadhyay Cc: Uladzislau Rezki Cc: Thomas Gleixner --- kernel/rcu/tree.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c index 32303070b20b..73971b8024d8 100644 --- a/kernel/rcu/tree.c +++ b/kernel/rcu/tree.c @@ -2288,6 +2288,7 @@ rcu_report_qs_rdp(struct rcu_data *rdp) unsigned long flags; unsigned long mask; bool needwake = false; + bool needacc = false; struct rcu_node *rnp; WARN_ON_ONCE(rdp->cpu != smp_processor_id()); @@ -2315,16 +2316,29 @@ rcu_report_qs_rdp(struct rcu_data *rdp) * This GP can't end until cpu checks in, so all of our * callbacks can be processed during the next GP. * - * NOCB kthreads have their own way to deal with that. + * NOCB kthreads have their own way to deal with that... */ - if (!rcu_rdp_is_offloaded(rdp)) + if (!rcu_rdp_is_offloaded(rdp)) { needwake = rcu_accelerate_cbs(rnp, rdp); + } else if (!rcu_segcblist_completely_offloaded(&rdp->cblist)) { + /* + * ...but NOCB kthreads may miss or delay callbacks acceleration + * if in the middle of a (de-)offloading process. + */ + needacc = true; + } rcu_disable_urgency_upon_qs(rdp); rcu_report_qs_rnp(mask, rnp, rnp->gp_seq, flags); /* ^^^ Released rnp->lock */ if (needwake) rcu_gp_kthread_wake(); + + if (needacc) { + rcu_nocb_lock_irqsave(rdp, flags); + rcu_accelerate_cbs_unlocked(rnp, rdp); + rcu_nocb_unlock_irqrestore(rdp, flags); + } } } -- 2.25.1