diff options
| author | Eric Dumazet <edumazet@google.com> | 2024-08-21 17:53:39 +0000 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2024-09-04 13:30:07 +0200 |
| commit | 5f5f7366dda8ae870e8305d6e7b3c0c2686cd2cf (patch) | |
| tree | 03e4e8e69bd2ec90fa0c6fc64662736ac2289462 /net | |
| parent | 0d1064dc06be0b8a5a2198ad10bf200d9a3b3598 (diff) | |
| download | linux-5f5f7366dda8ae870e8305d6e7b3c0c2686cd2cf.tar.gz linux-5f5f7366dda8ae870e8305d6e7b3c0c2686cd2cf.tar.bz2 linux-5f5f7366dda8ae870e8305d6e7b3c0c2686cd2cf.zip | |
pktgen: use cpus_read_lock() in pg_net_init()
[ Upstream commit 979b581e4c69257acab1af415ddad6b2d78a2fa5 ]
I have seen the WARN_ON(smp_processor_id() != cpu) firing
in pktgen_thread_worker() during tests.
We must use cpus_read_lock()/cpus_read_unlock()
around the for_each_online_cpu(cpu) loop.
While we are at it use WARN_ON_ONCE() to avoid a possible syslog flood.
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Link: https://patch.msgid.link/20240821175339.1191779-1-edumazet@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'net')
| -rw-r--r-- | net/core/pktgen.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/net/core/pktgen.c b/net/core/pktgen.c index ea55a758a475..197a50ef8e2e 100644 --- a/net/core/pktgen.c +++ b/net/core/pktgen.c @@ -3654,7 +3654,7 @@ static int pktgen_thread_worker(void *arg) struct pktgen_dev *pkt_dev = NULL; int cpu = t->cpu; - WARN_ON(smp_processor_id() != cpu); + WARN_ON_ONCE(smp_processor_id() != cpu); init_waitqueue_head(&t->queue); complete(&t->start_done); @@ -3989,6 +3989,7 @@ static int __net_init pg_net_init(struct net *net) goto remove; } + cpus_read_lock(); for_each_online_cpu(cpu) { int err; @@ -3997,6 +3998,7 @@ static int __net_init pg_net_init(struct net *net) pr_warn("Cannot create thread for cpu %d (%d)\n", cpu, err); } + cpus_read_unlock(); if (list_empty(&pn->pktgen_threads)) { pr_err("Initialization failed for all threads\n"); |
