Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1207033 > unrolled thread
| Started by | Sasha Levin <sasha.levin@oracle.com> |
|---|---|
| First post | 2015-08-13 20:10 +0200 |
| Last post | 2015-08-14 07:00 +0200 |
| Articles | 3 — 3 participants |
Back to article view | Back to linux.kernel
[PATCH] net: allow sleeping when modifying store_rps_map Sasha Levin <sasha.levin@oracle.com> - 2015-08-13 20:10 +0200
Re: [PATCH] net: allow sleeping when modifying store_rps_map Tom Herbert <tom@herbertland.com> - 2015-08-13 20:50 +0200
Re: [PATCH] net: allow sleeping when modifying store_rps_map David Miller <davem@davemloft.net> - 2015-08-14 07:00 +0200
| From | Sasha Levin <sasha.levin@oracle.com> |
|---|---|
| Date | 2015-08-13 20:10 +0200 |
| Subject | [PATCH] net: allow sleeping when modifying store_rps_map |
| Message-ID | <pX56V-2ug-7@gated-at.bofh.it> |
Commit 10e4ea751 ("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: 10e4ea751 ("net: Fix race condition in store_rps_map")
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
---
net/core/net-sysfs.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
index 39ec694..b279077 100644
--- a/net/core/net-sysfs.c
+++ b/net/core/net-sysfs.c
@@ -689,7 +689,7 @@ static ssize_t store_rps_map(struct netdev_rx_queue *queue,
struct rps_map *old_map, *map;
cpumask_var_t mask;
int err, cpu, i;
- static DEFINE_SPINLOCK(rps_map_lock);
+ static DEFINE_MUTEX(rps_map_mutex);
if (!capable(CAP_NET_ADMIN))
return -EPERM;
@@ -722,9 +722,9 @@ static ssize_t store_rps_map(struct netdev_rx_queue *queue,
map = NULL;
}
- spin_lock(&rps_map_lock);
+ mutex_lock(&rps_map_mutex);
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);
if (map)
@@ -732,7 +732,7 @@ static ssize_t store_rps_map(struct netdev_rx_queue *queue,
if (old_map)
static_key_slow_dec(&rps_needed);
- spin_unlock(&rps_map_lock);
+ mutex_unlock(&rps_map_mutex);
if (old_map)
kfree_rcu(old_map, rcu);
--
1.7.10.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [next] | [standalone]
| From | Tom Herbert <tom@herbertland.com> |
|---|---|
| Date | 2015-08-13 20:50 +0200 |
| Message-ID | <pX5JE-3dG-13@gated-at.bofh.it> |
| In reply to | #1207033 |
On Thu, Aug 13, 2015 at 11:03 AM, Sasha Levin <sasha.levin@oracle.com> wrote:
> Commit 10e4ea751 ("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: 10e4ea751 ("net: Fix race condition in store_rps_map")
> Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
> ---
> net/core/net-sysfs.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
> index 39ec694..b279077 100644
> --- a/net/core/net-sysfs.c
> +++ b/net/core/net-sysfs.c
> @@ -689,7 +689,7 @@ static ssize_t store_rps_map(struct netdev_rx_queue *queue,
> struct rps_map *old_map, *map;
> cpumask_var_t mask;
> int err, cpu, i;
> - static DEFINE_SPINLOCK(rps_map_lock);
> + static DEFINE_MUTEX(rps_map_mutex);
>
> if (!capable(CAP_NET_ADMIN))
> return -EPERM;
> @@ -722,9 +722,9 @@ static ssize_t store_rps_map(struct netdev_rx_queue *queue,
> map = NULL;
> }
>
> - spin_lock(&rps_map_lock);
> + mutex_lock(&rps_map_mutex);
> 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);
>
> if (map)
> @@ -732,7 +732,7 @@ static ssize_t store_rps_map(struct netdev_rx_queue *queue,
> if (old_map)
> static_key_slow_dec(&rps_needed);
>
> - spin_unlock(&rps_map_lock);
> + mutex_unlock(&rps_map_mutex);
>
> if (old_map)
> kfree_rcu(old_map, rcu);
> --
> 1.7.10.4
>
Thanks Sasha!
Acked-by: Tom Herbert <tom@herbertland.com>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | David Miller <davem@davemloft.net> |
|---|---|
| Date | 2015-08-14 07:00 +0200 |
| Message-ID | <pXffY-79-3@gated-at.bofh.it> |
| In reply to | #1207033 |
From: Sasha Levin <sasha.levin@oracle.com>
Date: Thu, 13 Aug 2015 14:03:16 -0400
> Commit 10e4ea751 ("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: 10e4ea751 ("net: Fix race condition in store_rps_map")
> Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
Applied, thanks.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web