Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2405790lqp; Sun, 24 Mar 2024 18:11:17 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVgZusd4PacO//GRSxZiq/zaQoUOwcw3y1KzYEO+BPSM99TnXsrcfJ/ILsLKMKCtVw7zSckKzOHlOKWjFjUUQZggYspjjE5xQ36YlVPBw== X-Google-Smtp-Source: AGHT+IHocewrpWOSD8JJagRLs9R4eQ3nGYNfIZfyq1A+bR42im3FvtEkGq/tuNN6astLn4Aa5M0m X-Received: by 2002:a05:620a:4949:b0:78a:3b08:97c2 with SMTP id vz9-20020a05620a494900b0078a3b0897c2mr6073019qkn.77.1711329077646; Sun, 24 Mar 2024 18:11:17 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711329077; cv=pass; d=google.com; s=arc-20160816; b=h12tH922OzzFkQ7jzbz51lRPTddq8C1/Aa4bKK+dvS45d/tvj8oyq4lqgt5TGRw5CL S2oRA+CST0VyB5bSjLMBc39wYJGd15xfhwv+CvGP8PuNs8N3ttG4kvnFcxYYS39yggnH nVezLiidFVWUzDoKdYGPHfcXs08Ln+wupMdfUsyjE5dHkrfGejwRmOK9xP30kes33IBo HlcnkX8nj9WQLKR7EyxH8OeG/JDjnGw3drWPOZ2m+6BQuGqud73Se2YVgC4/EBh2yHRh Ln+jCUDfNuA1iUrzkBjbHzWoEvN0G061NZCK2mDE2U3RStOoXjxQc1clORZsboS5OGHY B7Fg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=SkZbB3Gfs4nYdChWzv9HFwStC2NbvEPFdK/AxNThzY4=; fh=AVoVdUYUPE1dM4qqv+2qakUnjM2gtIvit8jB1eF1ZG4=; b=E8lyO5OoTikyxeAkmgRcfju15WVlwMP5kfu94BJPQfXTDVvQlHNjjoLaU9ArKwEiky nlduwRO4nh0fKMN9XZqF9tT19VqjX7mfCkDdntDku8/yCbYk5bC7pNcebzdYTCFKkPN1 GABrQFnOBP8+i2hk0+LeRrpWzrfeZlO3H7C/bNrbfB1KTwrsKwVWq0u97IZV7n+Qyqcd H1EGt9rrUVU0LXq9fUq30p5TpyKGNImVNUj83XGp39XzTYsf9Dvge2jvitaM6b1sSTV2 Th0Mry78DK3E9ayBjDdsLeXqRBosD04Ed53If0yKJOgv8ChN+/OdAYMVCRmw16nHw4/A x3zQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=F2LKT3Qo; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-113594-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-113594-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id q18-20020a05620a0c9200b0078a3a95c3dbsi4392124qki.106.2024.03.24.18.11.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Mar 2024 18:11:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-113594-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=F2LKT3Qo; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-113594-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-113594-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 60B231C24F12 for ; Mon, 25 Mar 2024 01:11:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4C9761CCE48; Sun, 24 Mar 2024 22:46:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="F2LKT3Qo" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6993F1CCE26; Sun, 24 Mar 2024 22:46:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711320397; cv=none; b=ATMHDc3VCAJb5Pd1qkLNi91Q9KdozhSbGC+F8l5zBb6E3xA0XrvPEO3JPzFk9QBWfYi40LNFB23xkAUwWI8wjl2Hy3vlbKsSEg3ImcIAq3nMu7UuoDf/DXhRAMG3IhrJ4uuAV5NsiW6Mt9M9/vRYFOD2HYqsrVLQpTEGBJ0W/aQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711320397; c=relaxed/simple; bh=Km4ENcWFfQoMIJIZTdNgW7E+woHN8o8HNtOCGwvqt14=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gRt0GHjpXflp7s7Lgo/KBV6PYtC9n6zO+F191Uf+3fT9c15fEoImTDSPNzfQ1YiCSmMP2dDWSpwP3RSEHNU5O2bqWrbM2xFaa76Z8Gr7e6OHTmUGjS3cWtJfuP8S6+eiw2o8w7A/3dAXGps/WkEInyZKLZT3OGCgSKNHuKRyK2U= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=F2LKT3Qo; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2947AC43399; Sun, 24 Mar 2024 22:46:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711320397; bh=Km4ENcWFfQoMIJIZTdNgW7E+woHN8o8HNtOCGwvqt14=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=F2LKT3QoGf6V5M6tK00uCuKF3PgmFu4lmm6jec3sDKPo4hFHSjpJK6QyMcfdlRFIS QOwh7ECYQUnVB4cx71j0BHzGqudS5eP4SEuilm9JKwIuIfbAkPRL1GSPN0Qe3S2Q9u i/ToD9Ruc6wCfuhob5kyDmNSj/WygxRtQHRzLLLALYEEh8zo7eEqowTk7MqnMq9smb ikTB0kt9bhSD0tZQ3n7UoDucrkJqPUaljsbrM/+4MtazBnjyAndaGd8GLpFhJcVvFW XGEmtIrj/+l2TeI4gZphFUa2bB03SgYyKxh1oPYW9biNmfO1/EM4GOba1eqNXPebr8 E6ntaegxhzjQg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Yan Zhai , "Paul E . McKenney" , Jesper Dangaard Brouer , Jakub Kicinski , Sasha Levin Subject: [PATCH 6.8 703/715] rcu: add a helper to report consolidated flavor QS Date: Sun, 24 Mar 2024 18:34:42 -0400 Message-ID: <20240324223455.1342824-704-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240324223455.1342824-1-sashal@kernel.org> References: <20240324223455.1342824-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit From: Yan Zhai [ Upstream commit 1a77557d48cff187a169c2aec01c0dd78a5e7e50 ] When under heavy load, network processing can run CPU-bound for many tens of seconds. Even in preemptible kernels (non-RT kernel), this can block RCU Tasks grace periods, which can cause trace-event removal to take more than a minute, which is unacceptably long. This commit therefore creates a new helper function that passes through both RCU and RCU-Tasks quiescent states every 100 milliseconds. This hard-coded value suffices for current workloads. Suggested-by: Paul E. McKenney Reviewed-by: Jesper Dangaard Brouer Signed-off-by: Yan Zhai Reviewed-by: Paul E. McKenney Acked-by: Jesper Dangaard Brouer Link: https://lore.kernel.org/r/90431d46ee112d2b0af04dbfe936faaca11810a5.1710877680.git.yan@cloudflare.com Signed-off-by: Jakub Kicinski Stable-dep-of: d6dbbb11247c ("net: report RCU QS on threaded NAPI repolling") Signed-off-by: Sasha Levin --- include/linux/rcupdate.h | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h index 0746b1b0b6639..9d69e4bd6f0a8 100644 --- a/include/linux/rcupdate.h +++ b/include/linux/rcupdate.h @@ -247,6 +247,37 @@ do { \ cond_resched(); \ } while (0) +/** + * rcu_softirq_qs_periodic - Report RCU and RCU-Tasks quiescent states + * @old_ts: jiffies at start of processing. + * + * This helper is for long-running softirq handlers, such as NAPI threads in + * networking. The caller should initialize the variable passed in as @old_ts + * at the beginning of the softirq handler. When invoked frequently, this macro + * will invoke rcu_softirq_qs() every 100 milliseconds thereafter, which will + * provide both RCU and RCU-Tasks quiescent states. Note that this macro + * modifies its old_ts argument. + * + * Because regions of code that have disabled softirq act as RCU read-side + * critical sections, this macro should be invoked with softirq (and + * preemption) enabled. + * + * The macro is not needed when CONFIG_PREEMPT_RT is defined. RT kernels would + * have more chance to invoke schedule() calls and provide necessary quiescent + * states. As a contrast, calling cond_resched() only won't achieve the same + * effect because cond_resched() does not provide RCU-Tasks quiescent states. + */ +#define rcu_softirq_qs_periodic(old_ts) \ +do { \ + if (!IS_ENABLED(CONFIG_PREEMPT_RT) && \ + time_after(jiffies, (old_ts) + HZ / 10)) { \ + preempt_disable(); \ + rcu_softirq_qs(); \ + preempt_enable(); \ + (old_ts) = jiffies; \ + } \ +} while (0) + /* * Infrastructure to implement the synchronize_() primitives in * TREE_RCU and rcu_barrier_() primitives in TINY_RCU. -- 2.43.0