Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1024920pxb; Wed, 29 Sep 2021 15:12:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyurmeHdIHJk3OlOCSqnYOK0gFdW3n0qExL1UeKe/1ynO4TYyHjBdFb46QIane6w2twwYqz X-Received: by 2002:a17:90a:4218:: with SMTP id o24mr4123504pjg.219.1632953532954; Wed, 29 Sep 2021 15:12:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632953532; cv=none; d=google.com; s=arc-20160816; b=qnQUBGDORwV8EVB1qymC+eGg10fpDi4c3QzrQ+uWaegBakb1uQYNV1aDnvNij7WMap 79G1+K9fl7j9HjQn3brC8Pga9yqoQT/5OXiyC/LOhZp7XUm60IeXUgDpj4A/B7g3tFAy gjCkmk/A8McMCbkX1w2o1ZLhBY/mvOpV7IkJOj8NBXEegD5scZzcWtcgDsxrsDAz2mIP KnBYXy/QBquTTR8yjbxC8Ip/GLBc9pVkrrWlrxd2vTeBAyZWcynELtpc4u0SmmwrLBwj YfPyOAGdceHvLpmG/RkfRTbRRl7Qssw8EzGOpRmlS5sUqk2cfJd5s+ajK3k0Ab/xDCka txOw== 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=oW3uqeRIaZDzcdahvYSwaRpsjAZQFrQc727NrTRQjp8=; b=WH4ty/ibPfUONlYx3lbn1yUhd+bKZqP1w6RKkDI758vp6nyX5Ze+U9kdcmWrtb09qk 01JCAcLnO7ZJTK5L0+9ACn8Yi3NfaRDdfqKuQXxRUIgfABath4SdCQn0j/fGFhBY04rw bBvhhryq8ZZgmGRRI/9bTgqWqkJj52mD4V2GPGzPwl95NQDw+AxMBE0z8IH/kc3ORnIk zhrGfjq+IMsSEnllMsqcpRAndhumuk+kuWMqTBmTllye+IYQsKBHe6hj2Q3B/HPTJHp8 F6CLdFOTxKyxtBoAiDFTEDgOaWhuTiCmHMWTdDAfZH05FvwA4j5mUy7d761z8AA3/6q5 VYKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=uqIxEEiZ; 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 p2si1304873pls.293.2021.09.29.15.11.56; Wed, 29 Sep 2021 15:12:12 -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=uqIxEEiZ; 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 S1347251AbhI2WM2 (ORCPT + 99 others); Wed, 29 Sep 2021 18:12:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:32786 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347247AbhI2WMW (ORCPT ); Wed, 29 Sep 2021 18:12:22 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id B9CD161423; Wed, 29 Sep 2021 22:10:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1632953441; bh=n/68oBtmr6qIYwDDlyCGFdycSkrFGc8mKE26O+8/IOc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uqIxEEiZxtg31wyzDfSS45f/wKVxRG42BH6Wm+7btkfloqelFFr4MbpU3mm/I8IDl YG08RdwmqRHvkHX5ZWR+fq67qiFz/NIy4pCS9bs3i8bjmorCZn01mWtaSt+TWn2iYO 4JSXslPkT8W11Q/lnEwfoXUpo45a7dVmVd4Prc8V1RCV/s+tOWx/qRQLroriRGm5U6 Nj8V1RRi0o82bRlL46VO5fFLByYo2OO/UI+bJbtf9KhSo8uyvi+B+sBt1qAn699OcQ SXjYrkJAKfY296fVTUsmGYrat/hR5he+5qYI0HBZYhAqLRbTCpVgl4iQ71LFRxACP5 8yLWZMSuKMz6A== 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 08/11] rcu/nocb: Limit number of softirq callbacks only on softirq Date: Thu, 30 Sep 2021 00:10:09 +0200 Message-Id: <20210929221012.228270-9-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 The current condition to limit the number of callbacks executed in a row checks the offloaded state of the rdp. Not only is it volatile but it is also misleading: the rcu_core() may well be executing callbacks concurrently with NOCB kthreads, and the offloaded state would then be verified on both cases. As a result the limit would spuriously not apply anymore on softirq while in the middle of (de-)offloading process. Another issue with the condition is that rcu_is_callbacks_kthread() doesn't check if we are actually running callbacks from rcuc itself or from a softirq interrupting rcuc. Fix and clarify the condition with those constraints in mind: _ If callbacks are processed either by rcuc or NOCB kthread, the call to cond_resched_tasks_rcu_qs() is enough to take care of the overload. _ If instead callbacks are processed by softirqs: * If need_resched(), exit the callbacks processing * Otherwise if CPU is idle we can continue * Otherwise exit because a softirq shouldn't interrupt a task for too long nor deprive other pending softirq vectors of the CPU. 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 | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c index 1971a4e15e96..35c4abc8df99 100644 --- a/kernel/rcu/tree.c +++ b/kernel/rcu/tree.c @@ -2535,9 +2535,8 @@ static void rcu_do_batch(struct rcu_data *rdp) /* * Stop only if limit reached and CPU has something to do. */ - if (count >= bl && !offloaded && - (need_resched() || - (!is_idle_task(current) && !rcu_is_callbacks_kthread()))) + if (count >= bl && in_serving_softirq() && + (need_resched() || !is_idle_task(current))) break; if (unlikely(tlimit)) { /* only call local_clock() every 32 callbacks */ -- 2.25.1