Received: by 2002:ab2:620c:0:b0:1ef:ffd0:ce49 with SMTP id o12csp1153014lqt; Tue, 19 Mar 2024 14:32:32 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW5zT/VYPXy2Jvr/AiEvBfl+SF0+/eKbbRCldz44b6kkBnkaIltb69rekwpBDOtxy538i20/fndeaX3dDjDjwlQdHsC4KXZ/vEDeUs07A== X-Google-Smtp-Source: AGHT+IHY4cCut4jmJNPwTorUwzlGqJb0FOmK/ys/2GdXCgla8RNcJbJ94N0XRy7any7drjaAxpEt X-Received: by 2002:a17:906:fb11:b0:a46:ec77:848 with SMTP id lz17-20020a170906fb1100b00a46ec770848mr749362ejb.12.1710883952144; Tue, 19 Mar 2024 14:32:32 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710883952; cv=pass; d=google.com; s=arc-20160816; b=he4Y9x/Ikou4brRw3j6AKf2hsMz9EffOX15fZcVBdXif6THODxVi0AyFCpNazbydzk Epf/+ttKlYnBETKdVhXWZHjRUeIh4XhoSgfmCaA9njTDG/aaQDMxh35xJkG+mI5veJ40 oN5ZKu1veMX4g0UTbz16JqjGpgSuSSehXRQ97d7cmZhlQiQLTHiljGGF0tdiwOFI13px PG7DjGCVc3GUqJCBPh7qsCNynT1Ji4AduI45mGd1Rq/z1hfR1XhyBH/UhGBYCRO9eS6Q zrrUxnO8QfBpyDTO6uyvY5HeOHN4KuJ48PL6l0XIDkqGb02zT+T8zcT7pYrymLt12Ycn 3etw== 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:reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=pho0nUEwp6wuSq5NGoYfIWwdr5IEFkJ1G/FH4Ul8yww=; fh=IPfoympBUn2hmjH/3zoAae5/cm+1JOfoMlFH2h+zs8Q=; b=izExs4o224kwxkrJMNSfR5ceTaV2CQJ16Aywd9yJ2UsVZod6RqtqdVFtHGpc9dGkep C9fY90emKrztDJ6bHTV2tbsXjvR1ikiAKQVb7I7UnTyWiKpIuJNg73VJIR+8nk819UsO Vemfk8ZB/buaceRSXK/7RFhz04uXLFhVUhbXSP4GqbjJ/64KEGdDcgk6PWvrtkgW0oHn 3ca3s67klwFd2nhOpsQjFvqjBPfpXrTtFgJPRqCSc/YFlrTyH4Xilxb6FPmJcXzTzAiM PklpdjoveNwjg2JPZ+BRRvoRnK1RpW46QEloz8k5z6SFeojurmArEV5O1cgdRxOfPaju jtPQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=f9ueXtCv; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-108155-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-108155-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id ne35-20020a1709077ba300b00a46e7568fa2si674340ejc.870.2024.03.19.14.32.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Mar 2024 14:32:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-108155-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=f9ueXtCv; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-108155-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-108155-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 am.mirrors.kernel.org (Postfix) with ESMTPS id C6A9F1F22EF9 for ; Tue, 19 Mar 2024 21:32:31 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7C15E4CB58; Tue, 19 Mar 2024 21:32:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="f9ueXtCv" 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 97A1440844; Tue, 19 Mar 2024 21:32:19 +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=1710883939; cv=none; b=R+KWUXIiM+/1xVoc897tFNlziBKU1g+23ejfNSdKziy8q9gaYRZAdt5JHwibM6fVd2K/jps5sJwiu89iqH/6H5u+GrZjUwNiF69ME4dlkhO95fNv0mZ3/59E6YufdOes06pcBRQCNtHehEb2oZKQ2RfRCHRFXDgP4gzpBwiowdM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710883939; c=relaxed/simple; bh=wHi1QgX7LbP6dkCBxVzG1neumr3N6oxJ810Rng9EFVM=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=bG2GnGAM/GP6M4yisk1AqOI/sy+TLnTB3TUiCALKL+VvodvoZc4q+QBwXoUpeKRPfu73EC9n80FXaUXUibeJnLE3O359Ermtaoo4lQHW1euik17ko0GX069Kyk3sEzE3mEgl+jwH0/GqcfYznd44ktYMnS0N1YsJ2sOkWU/nBxU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=f9ueXtCv; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id CA9D5C433C7; Tue, 19 Mar 2024 21:32:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710883939; bh=wHi1QgX7LbP6dkCBxVzG1neumr3N6oxJ810Rng9EFVM=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=f9ueXtCv+oeQzrfUVrvcMV6FTHy+HXrdV7p/VhHpfole0YRA+M8SmwkhlUunVr9Te M2O3ks/cUjqfWYu2MCU+5U/Rh1P7RHHD1p7LYxutcJ+kht55pEYVucbHDBzzSYRbxg YBpeQPOmEUc7OrWnY9LcS9Ju0ABHaWNp5SlRaCoqrlmafklmH7PRCC9L9KxIBTbFlD t1apSMCBjotewL4t0lKjSBgf+RDsfbL530BFxMoe+5AQ54/ukr6VBXhXyfaLBy5NYo YK1bbMm/IJnlJuWFCeHvqId23ij6qzbGRYK3+4scK07y6hIPBwtQ+y6kVXZkSiekwa tr7xafevR970A== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 30369CE16D7; Tue, 19 Mar 2024 14:32:16 -0700 (PDT) Date: Tue, 19 Mar 2024 14:32:16 -0700 From: "Paul E. McKenney" To: Yan Zhai Cc: netdev@vger.kernel.org, "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 , Toke =?iso-8859-1?Q?H=F8iland-J=F8rgensen?= , Alexei Starovoitov , Steven Rostedt , mark.rutland@arm.com, Jesper Dangaard Brouer , Sebastian Andrzej Siewior Subject: Re: [PATCH v5 net 2/3] net: report RCU QS on threaded NAPI repolling Message-ID: <417655d4-ba74-4f21-89f4-4cf41c6645ae@paulmck-laptop> Reply-To: paulmck@kernel.org References: <4c3b0d3f32d3b18949d75b18e5e1d9f13a24f025.1710877680.git.yan@cloudflare.com> 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: <4c3b0d3f32d3b18949d75b18e5e1d9f13a24f025.1710877680.git.yan@cloudflare.com> On Tue, Mar 19, 2024 at 01:44:37PM -0700, Yan Zhai wrote: > NAPI threads can keep polling packets under load. Currently it is only > calling cond_resched() before repolling, but it is not sufficient to > clear out the holdout of RCU tasks, which prevent BPF tracing programs > from detaching for long period. This can be reproduced easily with > following set up: > > ip netns add test1 > ip netns add test2 > > ip -n test1 link add veth1 type veth peer name veth2 netns test2 > > ip -n test1 link set veth1 up > ip -n test1 link set lo up > ip -n test2 link set veth2 up > ip -n test2 link set lo up > > ip -n test1 addr add 192.168.1.2/31 dev veth1 > ip -n test1 addr add 1.1.1.1/32 dev lo > ip -n test2 addr add 192.168.1.3/31 dev veth2 > ip -n test2 addr add 2.2.2.2/31 dev lo > > ip -n test1 route add default via 192.168.1.3 > ip -n test2 route add default via 192.168.1.2 > > for i in `seq 10 210`; do > for j in `seq 10 210`; do > ip netns exec test2 iptables -I INPUT -s 3.3.$i.$j -p udp --dport 5201 > done > done > > ip netns exec test2 ethtool -K veth2 gro on > ip netns exec test2 bash -c 'echo 1 > /sys/class/net/veth2/threaded' > ip netns exec test1 ethtool -K veth1 tso off > > Then run an iperf3 client/server and a bpftrace script can trigger it: > > ip netns exec test2 iperf3 -s -B 2.2.2.2 >/dev/null& > ip netns exec test1 iperf3 -c 2.2.2.2 -B 1.1.1.1 -u -l 1500 -b 3g -t 100 >/dev/null& > bpftrace -e 'kfunc:__napi_poll{@=count();} interval:s:1{exit();}' > > Report RCU quiescent states periodically will resolve the issue. > > Fixes: 29863d41bb6e ("net: implement threaded-able napi poll loop support") > Reviewed-by: Jesper Dangaard Brouer > Signed-off-by: Yan Zhai Acked-by: Paul E. McKenney > --- > v2->v3: abstracted the work into a RCU helper > v1->v2: moved rcu_softirq_qs out from bh critical section, and only > raise it after a second of repolling. Added some brief perf test result. > > v2: https://lore.kernel.org/bpf/ZeFPz4D121TgvCje@debian.debian/ > v1: https://lore.kernel.org/lkml/Zd4DXTyCf17lcTfq@debian.debian/#t > --- > net/core/dev.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/net/core/dev.c b/net/core/dev.c > index 303a6ff46e4e..9a67003e49db 100644 > --- a/net/core/dev.c > +++ b/net/core/dev.c > @@ -6743,6 +6743,8 @@ static int napi_threaded_poll(void *data) > void *have; > > while (!napi_thread_wait(napi)) { > + unsigned long last_qs = jiffies; > + > for (;;) { > bool repoll = false; > > @@ -6767,6 +6769,7 @@ static int napi_threaded_poll(void *data) > if (!repoll) > break; > > + rcu_softirq_qs_periodic(last_qs); > cond_resched(); > } > } > -- > 2.30.2 > >