Received: by 2002:ab2:620c:0:b0:1ef:ffd0:ce49 with SMTP id o12csp1131394lqt; Tue, 19 Mar 2024 13:45:13 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXViAt2DtMfbJq6mCQiHyDr+spNIhMz2GWiGl0Xy9znEdAycc3tXxyKnAMQE6IctiBixC9rxGRDyGw0v3fvLz7mrZJRnfkTmonb7276lA== X-Google-Smtp-Source: AGHT+IEfN2fGccxMD8CcEnl/jzeXg02bVzgaZ+gVqkh+5kG59FZ/b1g9DTlT4WMsqXhc66TsZrEg X-Received: by 2002:a05:620a:c93:b0:78a:10c:fa2f with SMTP id q19-20020a05620a0c9300b0078a010cfa2fmr7060830qki.39.1710881112800; Tue, 19 Mar 2024 13:45:12 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710881112; cv=pass; d=google.com; s=arc-20160816; b=ihrN340u+1ybbHlG6UNvMolQiLHiAM8C8twTx9XxSNWML0yl1CroadkD70INaESpZl d/JKZyqGSytYx/ERh1ellSLlEn91q+0rKYfBViVnEdDQKi2uobxcrK4FndclCRLfpf6i dBHdb9JpxzTXHnRdBGB3YTOYEa+aKAhoeJ0KVFw0ge9y6EBvoAnkF1DpIA7q8jv9tY5o O/zobvLnWDKs663waBmx+deJwgY2cvhA1APQ3gjFoekLDLOcFjN4VMdN2VltimhAzdZg X8sToq95t3y8yzsmeYKugXLXXthvT7LYiTmYoJTtmMIyKIBOqFIVLBVWTSVdEyk3rjde ImAw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=DhzHlt2GgEWWpszDk+jfUxmmnOotOx21FcVTcjSCNeQ=; fh=iRXIEdGsjJB/ego5OEMyxKn0UbVupx5CrO4AEpAZND8=; b=p8sxGDLLuW10K6HpC8VUOkfU2tbeTkfXlhnIjcoS2g43+N5gwl5FoEuFWAEiMRVvlj 058h4nKPq3JFP1ZOde99Jc7tEhTLJAHHFR3jQ2Q/SaQaVwHLtGT2WDaGl6iQn2NK0HdM EGZan9cz3PzXjKCFMtHsPbvKErGeRBDPA5UMbFACg3ittinyli/8z24tlxqpJ7nn9JJF eP4F8qq6C120jWco5tpYatv3lE8nqp8Tk1aaazfp0tYyJ+vktIPelNCn955S/uvIvgDv Xu2jhqK6PevZNnzngm63bs7Ey0R6qz73nP5eCmHFvsjMWTe0vZ+xOwLy2iYeByFPBbOA RbZg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@cloudflare.com header.s=google09082023 header.b=WjVndhal; arc=pass (i=1 spf=pass spfdomain=cloudflare.com dkim=pass dkdomain=cloudflare.com dmarc=pass fromdomain=cloudflare.com); spf=pass (google.com: domain of linux-kernel+bounces-108116-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-108116-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=cloudflare.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id x5-20020ae9e645000000b00789e3c002f0si10241283qkl.669.2024.03.19.13.45.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Mar 2024 13:45:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-108116-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=@cloudflare.com header.s=google09082023 header.b=WjVndhal; arc=pass (i=1 spf=pass spfdomain=cloudflare.com dkim=pass dkdomain=cloudflare.com dmarc=pass fromdomain=cloudflare.com); spf=pass (google.com: domain of linux-kernel+bounces-108116-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-108116-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=cloudflare.com 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 79B391C21D09 for ; Tue, 19 Mar 2024 20:45:12 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D49C43FBB6; Tue, 19 Mar 2024 20:44:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=cloudflare.com header.i=@cloudflare.com header.b="WjVndhal" Received: from mail-qt1-f178.google.com (mail-qt1-f178.google.com [209.85.160.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1B7803BBFA for ; Tue, 19 Mar 2024 20:44:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.178 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710881080; cv=none; b=suORAGIHF6F7CPhkWpZ9fZimcBTBQLSqqHiSZzAnmWNlx9XbGROtOWBCx+cESO0yh0fqEHr35O1aKgqV2K9pQhlYEaNN7W2P2a49yNdo3azJ9E4RyCwUwpWk4s3Xj0xj2olOmhH2fLCmwp7AP6TihINIqjJUj8wfXgEOFQpm8o0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710881080; c=relaxed/simple; bh=ZAThU7X8Id0Ifv3iZYWLGZRQ2drhENDwE2HLxuCty7Y=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=H6CYV4BLNJy0agQauQz9apFogO3aOlHKYtQk4NzTeW0OuORG7H9xvAPo0hVhQg4WMBqXmSsm5hFSVs2nnV4j/X+UlrSrpdJIVK8Bqwd1nA/8yiSno3jip741IezkHqP1necxMrA9Z/96u4KI5moRDKazQq6qzpS2rO8uY1YT/Xc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=cloudflare.com; spf=pass smtp.mailfrom=cloudflare.com; dkim=pass (2048-bit key) header.d=cloudflare.com header.i=@cloudflare.com header.b=WjVndhal; arc=none smtp.client-ip=209.85.160.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=cloudflare.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=cloudflare.com Received: by mail-qt1-f178.google.com with SMTP id d75a77b69052e-42ee23c64e3so24450311cf.2 for ; Tue, 19 Mar 2024 13:44:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloudflare.com; s=google09082023; t=1710881078; x=1711485878; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=DhzHlt2GgEWWpszDk+jfUxmmnOotOx21FcVTcjSCNeQ=; b=WjVndhalYYr9Sz1PTyICYsAXuaQju457TgXB1vmBCskifqLPojR0+IxYYPcOaWTQiZ +zafvpQZtkBi3IUAhY3AG0eu3kpeIWb9MXwoz35NJOXpqhBesEBB7mutauHACMAsBbfk OKD5k9teYFOPQVUqTZYQBjaVnWCz2wd2FJcC8tZk7rm51R29g/6zFEDlx2pjQzaUVdrd 8qZJz/7dnkPOg0F7NjMlJQ1ZpYn44Jw1rpnILbQbIRRzxvPnS0SXA0k9zFZvEI49utBX vz8U577AqGnSyi0rgWLgOqGU01YUtw7y1HRYRiE8Pte5WKITOWmAlDY9vMn+xpumFWgS 6mAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710881078; x=1711485878; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=DhzHlt2GgEWWpszDk+jfUxmmnOotOx21FcVTcjSCNeQ=; b=elaqa14LX+RBDmy48FWFbxfiZ0du60NM7+rLbYWHe80YnQaEbDE8rhoevMtkyrWp8y Eur19zO7VUmKmK7fkSyyjtw9x697gjKiQVr3JntjQIRfQC5plKhc9ATURSAxZPqeKtqw lMPPXj0yGS6vpNWWm3ddB7GXrgBFQ+kE7G22CVVBgV0ygLgQ+oLYc1IVfM0dK0THsosj QNN6pPQ0oERv8RDgPxGllx+4DX2+P6sUyajsL74MRjGMdBqMq8b8KBcsxO9yU7obEYYt muuHX/yxH5JaiuvCUxrWluMz2zOJiOOe82gKlqy7VMqcytEL/XBgiZEzM93WAkcHTjPh x+qA== X-Forwarded-Encrypted: i=1; AJvYcCUOvLyFQWQAYaYW96Q3RwNkf6JnMiV8zjNhvCzKIW3Uu1SrvtfzR7xY8IWvfv7DMaNOqqwRHJIpIN/zIfnAlGQe/pcNPAu+FO6RXpdA X-Gm-Message-State: AOJu0YwZMM9YFVf2t//8/HC+e1IxnX+t0V/gJejiMkQw2rbMkDxex/l/ kEg7n2Hi7Hj1jBVFoVLLWH413jOyfNRHmKo27UR63JZ6GIu5juqQ3BibKSw68no= X-Received: by 2002:a05:622a:1746:b0:430:eeba:b30 with SMTP id l6-20020a05622a174600b00430eeba0b30mr2430930qtk.43.1710881077371; Tue, 19 Mar 2024 13:44:37 -0700 (PDT) Received: from debian.debian ([2a09:bac5:7a49:1cd2::2df:49]) by smtp.gmail.com with ESMTPSA id i13-20020a05622a08cd00b00430eecd29c5sm790856qte.63.2024.03.19.13.44.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Mar 2024 13:44:36 -0700 (PDT) Date: Tue, 19 Mar 2024 13:44:34 -0700 From: Yan Zhai To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jiri Pirko , Simon Horman , Daniel Borkmann , Lorenzo Bianconi , Coco Li , Wei Wang , Alexander Duyck , linux-kernel@vger.kernel.org, rcu@vger.kernel.org, bpf@vger.kernel.org, kernel-team@cloudflare.com, Joel Fernandes , "Paul E. McKenney" , Toke =?utf-8?Q?H=C3=B8iland-J=C3=B8rgensen?= , Alexei Starovoitov , Steven Rostedt , mark.rutland@arm.com, Jesper Dangaard Brouer , Sebastian Andrzej Siewior Subject: [PATCH v5 net 1/3] rcu: add a helper to report consolidated flavor QS Message-ID: <90431d46ee112d2b0af04dbfe936faaca11810a5.1710877680.git.yan@cloudflare.com> References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 --- v4->v5: adjusted kernel docs and commit message v3->v4: kernel docs error --- include/linux/rcupdate.h | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h index 16f519914415..17d7ed5f3ae6 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.30.2