From: Yan Zhai <yan@cloudflare.com>
To: netdev@vger.kernel.org
Cc: "David S. Miller" <davem@davemloft.net>,
"Eric Dumazet" <edumazet@google.com>,
"Jakub Kicinski" <kuba@kernel.org>,
"Paolo Abeni" <pabeni@redhat.com>,
"Jiri Pirko" <jiri@resnulli.us>,
"Simon Horman" <horms@kernel.org>,
"Daniel Borkmann" <daniel@iogearbox.net>,
"Lorenzo Bianconi" <lorenzo@kernel.org>,
"Coco Li" <lixiaoyan@google.com>, "Wei Wang" <weiwan@google.com>,
"Alexander Duyck" <alexanderduyck@fb.com>,
linux-kernel@vger.kernel.org, rcu@vger.kernel.org,
bpf@vger.kernel.org, kernel-team@cloudflare.com,
"Joel Fernandes" <joel@joelfernandes.org>,
"Paul E. McKenney" <paulmck@kernel.org>,
"Toke Høiland-Jørgensen" <toke@redhat.com>,
"Alexei Starovoitov" <alexei.starovoitov@gmail.com>,
"Steven Rostedt" <rostedt@goodmis.org>,
mark.rutland@arm.com, "Jesper Dangaard Brouer" <hawk@kernel.org>,
"Sebastian Andrzej Siewior" <bigeasy@linutronix.de>
Subject: [PATCH v5 net 3/3] bpf: report RCU QS in cpumap kthread
Date: Tue, 19 Mar 2024 13:44:40 -0700 [thread overview]
Message-ID: <c17b9f1517e19d813da3ede5ed33ee18496bb5d8.1710877680.git.yan@cloudflare.com> (raw)
In-Reply-To: <cover.1710877680.git.yan@cloudflare.com>
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_CPUMAP")
Reviewed-by: Jesper Dangaard Brouer <hawk@kernel.org>
Signed-off-by: Yan Zhai <yan@cloudflare.com>
---
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_entry *rcpu, void **frames,
static int cpu_map_kthread_run(void *data)
{
struct bpf_cpu_map_entry *rcpu = data;
+ unsigned long last_qs = jiffies;
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 = 1;
+ last_qs = jiffies;
} else {
__set_current_state(TASK_RUNNING);
}
} else {
+ rcu_softirq_qs_periodic(last_qs);
sched = cond_resched();
}
--
2.30.2
next prev parent reply other threads:[~2024-03-19 20:44 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-19 20:44 [PATCH v5 net 0/3] Report RCU QS for busy network kthreads Yan Zhai
2024-03-19 20:44 ` [PATCH v5 net 1/3] rcu: add a helper to report consolidated flavor QS Yan Zhai
2024-03-19 21:31 ` Paul E. McKenney
2024-03-19 22:00 ` Yan Zhai
2024-03-19 22:08 ` Paul E. McKenney
2024-03-22 11:24 ` Sebastian Andrzej Siewior
2024-03-22 21:30 ` Paul E. McKenney
2024-03-23 2:02 ` Yan Zhai
2024-03-23 23:53 ` Paul E. McKenney
2024-04-05 13:49 ` Sebastian Andrzej Siewior
2024-04-05 18:13 ` Paul E. McKenney
2024-03-19 20:44 ` [PATCH v5 net 2/3] net: report RCU QS on threaded NAPI repolling Yan Zhai
2024-03-19 21:32 ` Paul E. McKenney
2024-03-19 20:44 ` Yan Zhai [this message]
2024-03-19 21:32 ` [PATCH v5 net 3/3] bpf: report RCU QS in cpumap kthread Paul E. McKenney
2024-03-20 10:30 ` [PATCH v5 net 0/3] Report RCU QS for busy network kthreads Jesper Dangaard Brouer
2024-03-21 4:40 ` patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c17b9f1517e19d813da3ede5ed33ee18496bb5d8.1710877680.git.yan@cloudflare.com \
--to=yan@cloudflare.com \
--cc=alexanderduyck@fb.com \
--cc=alexei.starovoitov@gmail.com \
--cc=bigeasy@linutronix.de \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=hawk@kernel.org \
--cc=horms@kernel.org \
--cc=jiri@resnulli.us \
--cc=joel@joelfernandes.org \
--cc=kernel-team@cloudflare.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lixiaoyan@google.com \
--cc=lorenzo@kernel.org \
--cc=mark.rutland@arm.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=paulmck@kernel.org \
--cc=rcu@vger.kernel.org \
--cc=rostedt@goodmis.org \
--cc=toke@redhat.com \
--cc=weiwan@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®