Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1071753pxb; Wed, 29 Sep 2021 16:28:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzG06cw5lUMWb3CasddX7dxI0sLzfJWB3enSipmR/+87fscJX0q+iR+XMKJC2aLaFhRttLl X-Received: by 2002:a17:90a:de0f:: with SMTP id m15mr2789458pjv.114.1632958124477; Wed, 29 Sep 2021 16:28:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632958124; cv=none; d=google.com; s=arc-20160816; b=dA9GxDnWcWkWzu6UZDMIoBwMLDVjcXhrpCSOmlDlt+Lj16Fn9I2/GrpMBXuqTTCCng KMyWq4/ef8bNgSexMHqgP/32vDZRiU7BYo38A5XWgVd2zNzv0UMKWzY8lxFumslynepg mcwya7ARy7vvygASdZuidXZIWpNGWWmW+Ab3wLarFf5xWy6h/v1cXC6Rj5kuzrzPkyZn QVSfLZX3XJoWXpfCdj/2TeErs2sz5V4Xa7FKT2fkKJg9NR6Qxebn9fF2oyEDpvdwim0R z2CAFjyr3qlrvBJ5yJMH4Wjmb5LtFApkj7o/YR8BlEaH2Ig6wIWzH6hCZ7Pt2TpSOrxG XQHw== 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=oMhMo4pasADp/pfDPbFDiuGkxp4KaF8CNr3Ewp4BxuY=; b=j38OBqiSqf7Us4XDTrRZA9FT5OXv/y1RKovgrSwe3e+ja8eRg7B6sLgi0jxMF00nV/ 0nNAj8wv/SbggmxX6UbdCPs30WlzEizzPxDWFGDVLSHBDxtLOZWHp/qgzAOW/fxFtBQ9 RLAvC+ZO6ntTceCpbLpyflfOOhs4Z+eyHgWEob9hAyHo1k95X8q3zWVWDCZvum2scjWb agB+JzXmp4ZeJpLxJCHOgpUCgIQDNJi/MpwThRk3+at7ZCEiP6xfIBjafL9w51dDuSa8 +MRbS7wDw1jCp0tLALSXvGhXyejZl74vgD/PK3F2VcGwL7rQupl30vXaNn3+qIqjhgRt a6gA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=aBKuCagf; 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 z18si1435068pgj.8.2021.09.29.16.28.30; Wed, 29 Sep 2021 16:28:44 -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=aBKuCagf; 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 S1347296AbhI2WMm (ORCPT + 99 others); Wed, 29 Sep 2021 18:12:42 -0400 Received: from mail.kernel.org ([198.145.29.99]:32900 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347255AbhI2WMZ (ORCPT ); Wed, 29 Sep 2021 18:12:25 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9818361425; Wed, 29 Sep 2021 22:10:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1632953444; bh=bWGuMKX/2J0zp8HS74KRYMqzjTCxrHugNyNTncu2H3k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aBKuCagfiLkehqBlDkyOONZdoAs5yRE9tK/zpAJEBfurwh1NL0YOKIAavuuBDIwvy P/R4iFv+hj0muGwVPDA/tFiCO9Royn+3lgMhKjXzCe86HceUOnU24M3b8Sy0VdGaAa faLDHn6DZ49P9wCNYcZ/ZQpnVm7CdKSZqbXxUb8u4lq1HlWnKYmCx+8o9uqYAGPI8u bKeAE7uvUN7eKZ+iRlFLfacZDNlr977/aXA/VcC0B/RwPu0VAz+YqFNXMy9t5GHgLC whVj7XJ9hLQOop7iX4sv/6CYCaIhS9Kb+wXB90N6tgrXQU5XvYwgCisqpCQFE13s4V +lvTg+EZSM/nA== 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 09/11] rcu: Fix callbacks processing time limit retaining cond_resched() Date: Thu, 30 Sep 2021 00:10:10 +0200 Message-Id: <20210929221012.228270-10-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 callbacks processing time limit makes sure we are not exceeding a given amount of time executing the queue. However its "continue" clause bypasses the cond_resched() call on rcuc and NOCB kthreads, delaying it until we reach the limit, which can be very long... Make sure the scheduler has a higher priority than the time limit. 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 | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c index 35c4abc8df99..bfc8e2727e35 100644 --- a/kernel/rcu/tree.c +++ b/kernel/rcu/tree.c @@ -2535,9 +2535,21 @@ static void rcu_do_batch(struct rcu_data *rdp) /* * Stop only if limit reached and CPU has something to do. */ - if (count >= bl && in_serving_softirq() && - (need_resched() || !is_idle_task(current))) - break; + if (in_serving_softirq()) { + if (count >= bl && (need_resched() || !is_idle_task(current))) + break; + } else { + local_bh_enable(); + lockdep_assert_irqs_enabled(); + cond_resched_tasks_rcu_qs(); + lockdep_assert_irqs_enabled(); + local_bh_disable(); + } + + /* + * Make sure we don't spend too much time here and deprive other + * softirq vectors of CPU cycles. + */ if (unlikely(tlimit)) { /* only call local_clock() every 32 callbacks */ if (likely((count & 31) || local_clock() < tlimit)) @@ -2545,13 +2557,6 @@ static void rcu_do_batch(struct rcu_data *rdp) /* Exceeded the time limit, so leave. */ break; } - if (!in_serving_softirq()) { - local_bh_enable(); - lockdep_assert_irqs_enabled(); - cond_resched_tasks_rcu_qs(); - lockdep_assert_irqs_enabled(); - local_bh_disable(); - } } rcu_nocb_lock_irqsave(rdp, flags); -- 2.25.1