From patchwork Fri Mar 15 19:55:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yan Zhai X-Patchwork-Id: 13593940 Received: from mail-qv1-f49.google.com (mail-qv1-f49.google.com [209.85.219.49]) (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 43292535AA for ; Fri, 15 Mar 2024 19:55:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710532510; cv=none; b=HBwmKG5Gqo0WfOsmCiorYPEcsTd1+IdY1JEuN1ro1GHiqu3w6lHCPRUZNo3jZd97mj95Aw0uXTgniaus55b1J0j2g7i+oqPe35V4quXwUbgaTmdh1leLC6JfxDwIAFo0bDmJq1hUQX+NakRlbtE3+6NDXoViOHNzkJk011Fhpk4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710532510; c=relaxed/simple; bh=h0zEXR9iEwGcrR1alN0rw2NJr4Lf0gOSf4DLUKJT8MY=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=CSOM1QSPjOJBBY4DxwgD98SOyg9f2htuIBo6FCyBBfLeFqciSWV6j3NBBAOnvyNT+SUePZDkg9paqNhdEHS2CBQOkezHpsx+9/bo7k3xQkgschCRoDpcoBEtbgliASomUYWpainoKkbNNL0Qp3UI6TkhciPSMVZKAJ2/5tIvH3Q= 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=T7F54xHe; arc=none smtp.client-ip=209.85.219.49 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="T7F54xHe" Received: by mail-qv1-f49.google.com with SMTP id 6a1803df08f44-68ee2c0a237so18823346d6.1 for ; Fri, 15 Mar 2024 12:55:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloudflare.com; s=google09082023; t=1710532506; x=1711137306; 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=EbbNmWl+lfF606jlI7tSahkKxu0DvLBvSy6/KumUR7w=; b=T7F54xHezWeUQNF5aqawytxJFmXZ7+aOPuXm9nRL2MKfWcJaIVNzOn1AdFQcc8GbYR EyEk2XPpV5hHAkP1/TuB6BQJwRZ1yCLZgn6WDWAqmhqcZWZlnDD9BvwZK4dIbEIsO8GG sj5G76cggqxJNvyN1WX857CVruQJ1Hj6qDrsWADsLjgLnCcDv+0A90iJkgYwmwnj9x28 RnDSx7v0Kt1af285HTRFSDM+Ya8wPgF8EVPX0dcMRjUmzW94N3mRG4Mt/HAFifCeyKvc DedU16B7L7ZaxdYfsZEhZpPfoYVJrRsQlz5L9LaOUSfn7KnOYP0CpcokHySokXGxVmCj 5oxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710532506; x=1711137306; 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=EbbNmWl+lfF606jlI7tSahkKxu0DvLBvSy6/KumUR7w=; b=lP9qOnEYjjk6duL1sp+T43OwAQR4SPxTY+6lYpHhKvZXvtDkJVO2+8SbODafdHJOTt mkaIHu6P+XvLWdGk84AHvEjACBi+tpnyfSvJrtTrb7ilSRC0t/jP7wPpVd8HGvyRtit1 Iy2N5HAjL2H7EKUoBHnG9XigLfovUo1qbyRdHvm//JmJvE71HJIAXm/8RuaSutySFYrD MYHjs/Z7iIZbK7v8JxwvKBZEw8kgb4SMddJiDgSVmrtvTEmIsagZve6ObVAk6NzXjwZ/ LQckXh1AqopI1rSzyyRA7zpjP2I4ZiRKgFaW3BdP2+kSaFDGDn7dIXFzfGRPV0qrYy4b XFcw== X-Forwarded-Encrypted: i=1; AJvYcCXDqIQLpkUjAeaVYQizVX5ao3pEj86SFKEcVkGzkcmEGK1rMAWDUtyuN4JcHW5J9892N4ZlTHbzAepkOETsN3vT4mTr X-Gm-Message-State: AOJu0Yyrg1nW/u6Hn9yXFBg0f0q1XoPfZpLX4sV3i7PvX7OiP82YN9A2 3D673giXq8iwntEhVfFaGuVN4A5Ve8AR2oaElhN9cosZJ1Apr6dowHAj9PmsdP8= X-Google-Smtp-Source: AGHT+IEZQd7hDHzs8WEgt9d/S5CteOD7EJxWIfDQQlT75NalMwM1VREuk3EwSMns3glFGvmJhcYR/g== X-Received: by 2002:a05:6214:1187:b0:691:4d1f:6a65 with SMTP id t7-20020a056214118700b006914d1f6a65mr9684907qvv.27.1710532506319; Fri, 15 Mar 2024 12:55:06 -0700 (PDT) Received: from debian.debian ([2a09:bac5:7a49:1046::19f:c]) by smtp.gmail.com with ESMTPSA id i14-20020a0c9c8e000000b0069160557ec1sm2139110qvf.136.2024.03.15.12.55.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Mar 2024 12:55:05 -0700 (PDT) Date: Fri, 15 Mar 2024 12:55:03 -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 v4 net 1/3] rcu: add a helper to report consolidated flavor QS Message-ID: <491d3af6c7d66dfb3b60b2f210f38e843dfe6ed2.1710525524.git.yan@cloudflare.com> 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. Currently the frequency is locked at HZ/10, i.e. 100ms, which is sufficient to address existing problems around RCU tasks. It's unclear yet if there is any future scenario for it to be further tuned down. Suggested-by: Paul E. McKenney Reviewed-by: Jesper Dangaard Brouer Signed-off-by: Yan Zhai --- v3->v4: comment fixup --- include/linux/rcupdate.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h index 0746b1b0b663..da224706323e 100644 --- a/include/linux/rcupdate.h +++ b/include/linux/rcupdate.h @@ -247,6 +247,30 @@ do { \ cond_resched(); \ } while (0) +/** + * rcu_softirq_qs_periodic - Periodically report consolidated quiescent states + * @old_ts: last jiffies when QS was reported. Might be modified in the macro. + * + * 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 all 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.