Commit da65ad1f authored by Sasha Levin's avatar Sasha Levin Committed by David S. Miller

net: allow sleeping when modifying store_rps_map

Commit 10e4ea75 ("net: Fix race condition in store_rps_map") has moved the
manipulation of the rps_needed jump label under a spinlock. Since changing
the state of a jump label may sleep this is incorrect and causes warnings
during runtime.

Make rps_map_lock a mutex to allow sleeping under it.

Fixes: 10e4ea75 ("net: Fix race condition in store_rps_map")
Signed-off-by: default avatarSasha Levin <sasha.levin@oracle.com>
Acked-by: default avatarTom Herbert <tom@herbertland.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 968d7cb8
...@@ -689,7 +689,7 @@ static ssize_t store_rps_map(struct netdev_rx_queue *queue, ...@@ -689,7 +689,7 @@ static ssize_t store_rps_map(struct netdev_rx_queue *queue,
struct rps_map *old_map, *map; struct rps_map *old_map, *map;
cpumask_var_t mask; cpumask_var_t mask;
int err, cpu, i; int err, cpu, i;
static DEFINE_SPINLOCK(rps_map_lock); static DEFINE_MUTEX(rps_map_mutex);
if (!capable(CAP_NET_ADMIN)) if (!capable(CAP_NET_ADMIN))
return -EPERM; return -EPERM;
...@@ -722,9 +722,9 @@ static ssize_t store_rps_map(struct netdev_rx_queue *queue, ...@@ -722,9 +722,9 @@ static ssize_t store_rps_map(struct netdev_rx_queue *queue,
map = NULL; map = NULL;
} }
spin_lock(&rps_map_lock); mutex_lock(&rps_map_mutex);
old_map = rcu_dereference_protected(queue->rps_map, old_map = rcu_dereference_protected(queue->rps_map,
lockdep_is_held(&rps_map_lock)); mutex_is_locked(&rps_map_mutex));
rcu_assign_pointer(queue->rps_map, map); rcu_assign_pointer(queue->rps_map, map);
if (map) if (map)
...@@ -732,7 +732,7 @@ static ssize_t store_rps_map(struct netdev_rx_queue *queue, ...@@ -732,7 +732,7 @@ static ssize_t store_rps_map(struct netdev_rx_queue *queue,
if (old_map) if (old_map)
static_key_slow_dec(&rps_needed); static_key_slow_dec(&rps_needed);
spin_unlock(&rps_map_lock); mutex_unlock(&rps_map_mutex);
if (old_map) if (old_map)
kfree_rcu(old_map, rcu); kfree_rcu(old_map, rcu);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment