From patchwork Wed Mar 13 16:25:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yan Zhai X-Patchwork-Id: 13591569 Received: from mail-qk1-f181.google.com (mail-qk1-f181.google.com [209.85.222.181]) (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 8C7A54AEEA for ; Wed, 13 Mar 2024 16:25:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710347155; cv=none; b=DNJawFXBT/uVli6QY/lYQQD2n9TY8QF3vKVNm4fwykO61n8yRlZrwtKTPL5kKtd4aecckJUMwETh9WLHGP6C3K7m8YGvCHgBqbyqfpItxaolvhISGBaYH8hkkzpbdZqnuSa3f3QzFMZPfxpMCSQyd1Yq9wJtZ6i/To7P2YO1tlE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710347155; c=relaxed/simple; bh=waophCxTcodcZBiaZRBq4Vcy/9u+Db/aHwd0TOyESlA=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=hjNGCYBUrU7qpuaboIxw366T7rXYAQzsx+JCFnGi99sUyRyQlda7S4tY/XIKJRRqaKgVx9uDjAy6Z/htkfoR2Q2b/pUgjr7v29b+64R6vJ8yDHQOMWr8WkTQk5M7VLlcM06uKXSeLteguG7uGkjQHkNe4C9XUYL+ubuPl7DTYyw= 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=RdSU3EY0; arc=none smtp.client-ip=209.85.222.181 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=cloudflare.com header.i=@cloudflare.com header.b="RdSU3EY0" Received: by mail-qk1-f181.google.com with SMTP id af79cd13be357-788412a4b2eso250617585a.1 for ; Wed, 13 Mar 2024 09:25:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloudflare.com; s=google09082023; t=1710347152; x=1710951952; 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=hz52VDhsyBUm+rkXRTpJXcM4FSy0vt7HjYW4U4Q0pQw=; b=RdSU3EY000ormZCobNVsi8X8ZcmHO2hUrQybNRFpiTKEhAbnstxVmtInPHXSt2aKxb PS3A5Z9vFgtBWo3OPKELMRGKXRFnYFn8oEm0OKdRZqBg8XqlpdTDHmYxlpIMgtpWIHro jzi7Vw1k9/zp0D+bp8lbe8/J0BOahc1XAJakEumFQ0uR9j3An0CbhrWPdBJMZc6eUzy1 zYo0kk+DpgXL9eMpD62O/sjKMw4puhi8quHZVoOpGurS7WHZkzM4GR2S6jxq55FJZFoc jAX2H1BZSlt7eZcJQ/IwKdhWWSjdo/fakbvzyJD7sBBG28olu8Ns0gmSrQ9khAJMSaXx P/Dg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710347152; x=1710951952; 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=hz52VDhsyBUm+rkXRTpJXcM4FSy0vt7HjYW4U4Q0pQw=; b=qGCc+RdD49X9YowJ1yyIv6BxuYLDDQpaLuAIHmVKfNO8eYBtl0b1t4YASIgkcdHPyQ LPlFiL6GmM18zFp7A2Iap/x/xw7A4cehNEr7jzggfZH8Dj0RkkEqxpNU9Vs5uEdiILC5 SKKcDSHhfp8qwuX3K90Y5UpMgFZ24/EBt/SIXsNUZpEWL57AdaPG3MypL+hsAT5u00Xj WEcKCOg7jJ9KlGUdyFIq5qqObVcUc+qmsQjnZM79w7Q1+WH5kSQ//fjopdHS2c5MnmMT ek0G/XGZsgBjSXxVoOG7D7/v2nqX7FWp3wrVcCX5bsyHnpkysHa73Ap30RYSjhTtnAdm pLew== X-Forwarded-Encrypted: i=1; AJvYcCVwhonfx33a+VNj3i2lE+bG9s+uZoeB4W3PBFhKeBCyGo+tWU/nG87Ve7SW+8LN0zOaLicpYhJkfj0zuc/lKydQTD/K X-Gm-Message-State: AOJu0YwOSudCpveTelcWJE2ByFZQDOQMHh1xhqm24tEl3cjnIUvmfMJM qafGDZA+MktZTJTYVpdcyPFpme+uZcdIx3VwKSdGfraYdEu8e7zvi8UggwfppEQ= X-Google-Smtp-Source: AGHT+IHG2Wo7WJzKa6z0HU+as2odTaqY/F5UrV7eoi67pzTk35M3ZippREVklQyBwoPl9T2v05w+XQ== X-Received: by 2002:a05:620a:28d1:b0:788:2dd5:6f12 with SMTP id l17-20020a05620a28d100b007882dd56f12mr467010qkp.67.1710347152457; Wed, 13 Mar 2024 09:25:52 -0700 (PDT) Received: from debian.debian ([2a09:bac5:7a49:f91::18d:37]) by smtp.gmail.com with ESMTPSA id az39-20020a05620a172700b00789ca2c923esm818990qkb.114.2024.03.13.09.25.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Mar 2024 09:25:51 -0700 (PDT) Date: Wed, 13 Mar 2024 09:25:49 -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 , Hannes Frederic Sowa , 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?= =?utf-8?q?=C3=B8rgensen?= , Alexei Starovoitov , Steven Rostedt , mark.rutland@arm.com, Jesper Dangaard Brouer Subject: [PATCH v3 net 1/3] rcu: add a helper to report consolidated flavor QS Message-ID: References: Precedence: bulk X-Mailing-List: rcu@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: There are several scenario in network processing that can run extensively under heavy traffic. In such situation, RCU synchronization might not observe desired quiescent states for indefinitely long period. Create a helper to safely raise the desired RCU quiescent states for such scenario. Reviewed-by: Jesper Dangaard Brouer Signed-off-by: Yan Zhai --- include/linux/rcupdate.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h index 0746b1b0b663..e91ae38c33e3 100644 --- a/include/linux/rcupdate.h +++ b/include/linux/rcupdate.h @@ -247,6 +247,29 @@ do { \ cond_resched(); \ } while (0) +/** + * rcu_softirq_qs_periodic - Periodically report consolidated quiescent states + * + * This helper is for network processing in non-RT kernels, where there could + * be busy polling threads that block RCU synchronization indefinitely. In + * such context, simply calling cond_resched is insufficient, so give it a + * stronger push to eliminate potential blockage of all RCU types. + * + * NOTE: unless absolutely sure, this helper should in general be called + * outside of bh lock section to avoid reporting a surprising QS to updaters, + * who could be expecting RCU read critical section to end at local_bh_enable(). + */ +#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.