From nobody Wed Feb 11 07:47:16 2026 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=cloudflare.com header.i=@cloudflare.com header.b="WjVndhal" 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-Google-Smtp-Source: AGHT+IE0UM9LxDtJtc5S/HyOTxf5CvZO+23gx12ZhJ+rAVD9OduvA+dRZqVWHTNHXmdvPaVSKpTvmg== 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-Disposition: inline In-Reply-To: Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 Acked-by: Jesper Dangaard Brouer Reviewed-by: Paul E. McKenney --- 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) =20 +/** + * 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 w= ill + * 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 w= ould + * have more chance to invoke schedule() calls and provide necessary quies= cent + * states. As a contrast, calling cond_resched() only won't achieve the sa= me + * effect because cond_resched() does not provide RCU-Tasks quiescent stat= es. + */ +#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) =3D jiffies; \ + } \ +} while (0) + /* * Infrastructure to implement the synchronize_() primitives in * TREE_RCU and rcu_barrier_() primitives in TINY_RCU. --=20 2.30.2 From nobody Wed Feb 11 07:47:16 2026 Received: from mail-qt1-f169.google.com (mail-qt1-f169.google.com [209.85.160.169]) (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 8372B3BBFE for ; Tue, 19 Mar 2024 20:44:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710881083; cv=none; b=Kbn/QAYQelPAEjfCfywzX46OPaFL/p4yC5rnV8inPfjNnfq4b8JPHWsDJnLUo3kfljQ2WhAu5/9UKFQmOdOplydSHtgL/k0V23lPvGi8z1Bo6p7pzm85skmOY4cab1tZjeLeOP8RhuYh9jboc3wgaHun0/fVnII9gD4SCkpGXT4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710881083; c=relaxed/simple; bh=lIO9MabCA0Vp4l3RyBQKLB7GagIDesVLqRMDYikDatA=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=k2ZlFX7LX1xw+nl4J2ywVozOqLfgymthyh/vVWLNHpi8sJ4MOC5byDJqVdrVF4s6f1cO1S8a3VAl0s9tEyqhT8mklaJuLkhSggSZgtKm8SXlFsXlP3PttDLiA3NNLgBv2xmKmeJz6hpKs/7CN2dW8vl3k1zOfBlB6ZRT43dwtuQ= 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=HCAA8OEY; arc=none smtp.client-ip=209.85.160.169 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="HCAA8OEY" Received: by mail-qt1-f169.google.com with SMTP id d75a77b69052e-430b870163eso2338471cf.1 for ; Tue, 19 Mar 2024 13:44:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloudflare.com; s=google09082023; t=1710881080; x=1711485880; 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=VcyYWRaJ2z9OCo3//n/tTkrj0ma4Eol6nlX2m3ez4hs=; b=HCAA8OEYnfyjXPN2g/n0nTxMowCW9mbg6CmydUQ4bRuoUnuFFjOGSe7LQBcrPfVCfo O66rE/8zgWpIJpaOa3Sq+UhcGgXJ8m0MpKrQuuknWJ4oCXcMR8+RGly5ALckHNlubq/A 3imWG14J7mdr1txJbwWOxf/G1VJXAsNkGYW3/Y1BvDEhytt4RZ8G75qa09HIHpz+mOIS KlyE0+eCY68tqAyxdvT2yzzjl1XSWGtD00xXOwuBDHrdr0ve8mMC2+1rOVhKxuYrgB7K ZmbZ47+/QWKD+AFC8NSvtJ/0JVlW01OCOSplfV0JulmAm408jLy7fWSn8VOutYm+ajyv dMmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710881080; x=1711485880; 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=VcyYWRaJ2z9OCo3//n/tTkrj0ma4Eol6nlX2m3ez4hs=; b=FdCOwCVdm5yRbuQmM2rvPpLrH+StT+20mRqB06LC941BNuJikcQ/rbDu6w+CCql8vm QLY+FEHQq6m1X9UOirRbzZwLYuXCtUtrTdYqphDEYWA41sAGtoAOeP9cDA8x3x/escGv lnShV3Cryhs0i48NHAN2iX51TREqoxPUSUdRWbBmHSa8Tivh76An17HIndL+b/xbaO5H ZxRlKYP8y8CGEayE4ag0wCI+CRm5YYBjPKEUOlgDhipqWn4hE0geeQOCBl3I9mZ73dpY Eo+DSk5R+s1wIdDQYtOkm3aeRBxugExy409GqWC3Sc2bfk6zMvGCjk8CbpHzgvQ/T3LX Hy9w== X-Forwarded-Encrypted: i=1; AJvYcCV9GI7ypL5FCWHJ3V0H4I1Pd3io7Tg9bL0J6vQGNYByTrGUqGdHoGbXCyRcrWYGSWInWrjcYM08qJGACxwgVKzIDki8IPHNOgl0OP6O X-Gm-Message-State: AOJu0Yw9liTm/ef8KqUY8ZGNM8970kNyE1tmFVx2LWhJA+g7AwxIJZmO ctlGjrLvxoIYxRwRnn2VRR5ott9u5/UH4TzO9QPn2kq7MfxUKktXigbNud1BGWQ= X-Google-Smtp-Source: AGHT+IEqJqSfTz5bjyf6+FFNUXSLrbwrdMDLWUdtYJ2krdBAfEjY8Q3lzIBNIXbpm1TJn+LzQI6kHw== X-Received: by 2002:a05:6214:14b0:b0:691:3cf5:b7ad with SMTP id bo16-20020a05621414b000b006913cf5b7admr1034118qvb.12.1710881080537; Tue, 19 Mar 2024 13:44:40 -0700 (PDT) Received: from debian.debian ([2a09:bac5:7a49:1cd2::2df:49]) by smtp.gmail.com with ESMTPSA id pn4-20020a056214130400b006961c1d2b6fsm2822954qvb.80.2024.03.19.13.44.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Mar 2024 13:44:40 -0700 (PDT) Date: Tue, 19 Mar 2024 13:44:37 -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 2/3] net: report RCU QS on threaded NAPI repolling Message-ID: <4c3b0d3f32d3b18949d75b18e5e1d9f13a24f025.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-Disposition: inline In-Reply-To: Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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{@=3Dcount();} 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: Jesper Dangaard Brouer 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; =20 while (!napi_thread_wait(napi)) { + unsigned long last_qs =3D jiffies; + for (;;) { bool repoll =3D false; =20 @@ -6767,6 +6769,7 @@ static int napi_threaded_poll(void *data) if (!repoll) break; =20 + rcu_softirq_qs_periodic(last_qs); cond_resched(); } } --=20 2.30.2 From nobody Wed Feb 11 07:47:16 2026 Received: from mail-qt1-f179.google.com (mail-qt1-f179.google.com [209.85.160.179]) (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 6CA984F5F2 for ; Tue, 19 Mar 2024 20:44:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710881086; cv=none; b=pvOmBo4Nro0kHoBChwXN8yAVtkmqae5vFTeh0aj4aCeLEYCDU0uQK3wquanEP9VCjPekgfhkd6gLVzVUU1RswrdYe0FseGKLis1sBWZZjeArp5Alw2TGsgZr8OA8Ck8X0/8SA2kpHFMdmU6Q11qZLqXBgT4Hi1CZZ1YKfizsDWE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710881086; c=relaxed/simple; bh=pKj7+vVBWGpGFKTYgRlu4W1CFWQUya7L1Dw9/pmHtFI=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=RCaRpL8nLktAK7uj+91Y613LLPFaMXM5rZrsGNEwX1s2cVfg6UXrZH7btwU2QjaBCB62hMnCUkW9MhXZDCwvvnL2l2BPmnBK6afcaY51Yf0lMpyiTQjSdsUE36e+k3XEHYkj5zc5Qs4OTvb+e9vK3jJHI3KJSrlflv47wSZ+8eY= 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=NyPcINls; arc=none smtp.client-ip=209.85.160.179 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="NyPcINls" Received: by mail-qt1-f179.google.com with SMTP id d75a77b69052e-430b6ff2a20so23722531cf.2 for ; Tue, 19 Mar 2024 13:44:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloudflare.com; s=google09082023; t=1710881083; x=1711485883; 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=Gsx2/BRS29DSIob/mTwxuIGO/Q7o98NCGCF5KqdWFH8=; b=NyPcINlsz3mOKL4xDbVdw6Rfilhtx668TBFIaThh32Uh0ARXv5MpM8I1QgpWsKEsZU a5/ABSppF6qhjspk7/xTU5i9Qhrjla4Pi+uo/FYCrRS5fzSrW3nC9NWpE87cgrioOCrz O6kkGkpFyQct36jifR34OvNZMaOtffrHEW39S/LZ3cXCD06nPFN+moBcKz2HlJ6YE1p1 QYDFhj5GntPQ3HgeP+r9r2Acc2S6+6Dbpz/R9NV/KEiRfZ60NCnZLOXGTPWqwXN76owU 7QtNxGKR81MhVxM/tEJKwqn12QaggklRczAlJz2u+UsVdZdra8zpsidFxYYEYCusO/GP kAKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710881083; x=1711485883; 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=Gsx2/BRS29DSIob/mTwxuIGO/Q7o98NCGCF5KqdWFH8=; b=YbGEF/nEwON9Kj7KONoQYy9V7dyQmczxoi12qq8WGI+Rd81czLzBTwjLCH5fFk0kjB dTQ77rmgNeGn3diQpqh6dMiJF5SmGC7whRXlU7IwobXxqCqsZ8pHk9MDK/vmvVMPcVAw GjVDEDCPdPrBjy8vwmoyKF6c2DKAqvunVFv6ZW9rb9mdw+9L3Qj8EnTpmqlH/VxvW4mj tosbX1rQwIkPJGzMOj0BahooinmJZI5CFixzJkX7pMqbXyUcaVBQpfZlaDXVC6FLoapP hyBir9Z3lIthRU7rZDClwc1CQcSNluJ70I2kggbcm4ITZJPbWNJR7mbH0wH0z1gfyQKT UuiQ== X-Forwarded-Encrypted: i=1; AJvYcCVcNZVEWXXBMtECJNZIpKF4jmxjl12q8MYqMs+PCbmfqk+Eizfh+7dvC2nPg1Y+x8DqoQ2M21VIMCedjsrlOOo/Y2DWtc1In5VaqLK0 X-Gm-Message-State: AOJu0YyACCVBC07sRyv81sEo198soIJ+JJ2JcSmlVcIAZaVcPh+ufz3r yZz7+hV6w26JmonjNuN82SD4if7FZ/8qyAfsJtlflElhuQxCKGMe1/8GddDdBik= X-Google-Smtp-Source: AGHT+IH9gvsMwQ8Z4rqJt6819bKxcNAcmqm6NPCZSQ8iSNVkJDu8nkaCee0sRubQEvo4jJt+9rGXIg== X-Received: by 2002:a05:622a:1115:b0:431:167:280 with SMTP id e21-20020a05622a111500b0043101670280mr63581qty.51.1710881083436; Tue, 19 Mar 2024 13:44:43 -0700 (PDT) Received: from debian.debian ([2a09:bac5:7a49:1cd2::2df:49]) by smtp.gmail.com with ESMTPSA id cr13-20020a05622a428d00b00430b0f40532sm5307248qtb.9.2024.03.19.13.44.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Mar 2024 13:44:42 -0700 (PDT) Date: Tue, 19 Mar 2024 13:44:40 -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 3/3] bpf: report RCU QS in cpumap kthread Message-ID: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" When there are heavy load, cpumap kernel threads can be busy polling packets from redirect queues and block out RCU tasks from reaching quiescent states. It is insufficient to just call cond_resched() in such context. Periodically raise a consolidated RCU QS before cond_resched fixes the problem. Fixes: 6710e1126934 ("bpf: introduce new bpf cpu map type BPF_MAP_TYPE_CPUM= AP") Reviewed-by: Jesper Dangaard Brouer Signed-off-by: Yan Zhai Acked-by: Jesper Dangaard Brouer Acked-by: Paul E. McKenney --- kernel/bpf/cpumap.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/kernel/bpf/cpumap.c b/kernel/bpf/cpumap.c index 9ee8da477465..a8e34416e960 100644 --- a/kernel/bpf/cpumap.c +++ b/kernel/bpf/cpumap.c @@ -263,6 +263,7 @@ static int cpu_map_bpf_prog_run(struct bpf_cpu_map_entr= y *rcpu, void **frames, static int cpu_map_kthread_run(void *data) { struct bpf_cpu_map_entry *rcpu =3D data; + unsigned long last_qs =3D jiffies; =20 complete(&rcpu->kthread_running); set_current_state(TASK_INTERRUPTIBLE); @@ -288,10 +289,12 @@ static int cpu_map_kthread_run(void *data) if (__ptr_ring_empty(rcpu->queue)) { schedule(); sched =3D 1; + last_qs =3D jiffies; } else { __set_current_state(TASK_RUNNING); } } else { + rcu_softirq_qs_periodic(last_qs); sched =3D cond_resched(); } =20 --=20 2.30.2