[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20221013234349.1165689-2-yury.norov@gmail.com>
Date: Thu, 13 Oct 2022 16:43:45 -0700
From: Yury Norov <yury.norov@...il.com>
To: netdev@...r.kernel.org, "David S . Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>,
Sebastian Andrzej Siewior <bigeasy@...utronix.de>,
Menglong Dong <imagedong@...cent.com>,
Kuniyuki Iwashima <kuniyu@...zon.com>,
Petr Machata <petrm@...dia.com>,
Guo Ren <guoren@...ux.alibaba.com>,
"Michael S . Tsirkin" <mst@...hat.com>
Cc: Yury Norov <yury.norov@...il.com>, linux-kernel@...r.kernel.org
Subject: [PATCH v2 1/4] net: move setup code out of mutex in __netif_set_xps_queue()
maps_sz, nr_ids and online_mask may be set out of the mutex.
Signed-off-by: Yury Norov <yury.norov@...il.com>
---
net/core/dev.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/net/core/dev.c b/net/core/dev.c
index fa53830d0683..70fa12c6551c 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -2563,9 +2563,6 @@ int __netif_set_xps_queue(struct net_device *dev, const unsigned long *mask,
return -EINVAL;
}
- mutex_lock(&xps_map_mutex);
-
- dev_maps = xmap_dereference(dev->xps_maps[type]);
if (type == XPS_RXQS) {
maps_sz = XPS_RXQ_DEV_MAPS_SIZE(num_tc, dev->num_rx_queues);
nr_ids = dev->num_rx_queues;
@@ -2579,6 +2576,10 @@ int __netif_set_xps_queue(struct net_device *dev, const unsigned long *mask,
if (maps_sz < L1_CACHE_BYTES)
maps_sz = L1_CACHE_BYTES;
+ mutex_lock(&xps_map_mutex);
+
+ dev_maps = xmap_dereference(dev->xps_maps[type]);
+
/* The old dev_maps could be larger or smaller than the one we're
* setting up now, as dev->num_tc or nr_ids could have been updated in
* between. We could try to be smart, but let's be safe instead and only
--
2.34.1
Powered by blists - more mailing lists