* [PATCH v2] openvswitch: Disable bottom half when grabbing stats lock in userspace context
@ 2014-02-27 22:10 ` Zoltan Kiss
0 siblings, 0 replies; 3+ messages in thread
From: Zoltan Kiss @ 2014-02-27 22:10 UTC (permalink / raw)
To: Jesse Gross, pshelar, dev; +Cc: netdev, linux-kernel, Zoltan Kiss
The megaflow feature introduced per-CPU stats, and the new code did some
refactoring as well [1]. However the new functions doesn't disable bottom halves
when locking the stat, and as they can be called from userspace context, they
can be interrupted by netif_receive_skb.
[1] e298e50570: openvswitch: Per cpu flow stats.
Signed-off-by: Zoltan Kiss <zoltan.kiss@citrix.com>
---
v2: use _bh instead of _irqsave/restore
net/openvswitch/flow.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/net/openvswitch/flow.c b/net/openvswitch/flow.c
index 16f4b46..9110cf4 100644
--- a/net/openvswitch/flow.c
+++ b/net/openvswitch/flow.c
@@ -90,13 +90,13 @@ static void stats_read(struct flow_stats *stats,
struct ovs_flow_stats *ovs_stats,
unsigned long *used, __be16 *tcp_flags)
{
- spin_lock(&stats->lock);
+ spin_lock_bh(&stats->lock);
if (time_after(stats->used, *used))
*used = stats->used;
*tcp_flags |= stats->tcp_flags;
ovs_stats->n_packets += stats->packet_count;
ovs_stats->n_bytes += stats->byte_count;
- spin_unlock(&stats->lock);
+ spin_unlock_bh(&stats->lock);
}
void ovs_flow_stats_get(struct sw_flow *flow, struct ovs_flow_stats *ovs_stats,
@@ -130,12 +130,12 @@ void ovs_flow_stats_get(struct sw_flow *flow, struct ovs_flow_stats *ovs_stats,
static void stats_reset(struct flow_stats *stats)
{
- spin_lock(&stats->lock);
+ spin_lock_bh(&stats->lock);
stats->used = 0;
stats->packet_count = 0;
stats->byte_count = 0;
stats->tcp_flags = 0;
- spin_unlock(&stats->lock);
+ spin_unlock_bh(&stats->lock);
}
void ovs_flow_stats_clear(struct sw_flow *flow)
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH v2] openvswitch: Disable bottom half when grabbing stats lock in userspace context
@ 2014-02-27 22:10 ` Zoltan Kiss
0 siblings, 0 replies; 3+ messages in thread
From: Zoltan Kiss @ 2014-02-27 22:10 UTC (permalink / raw)
To: Jesse Gross, pshelar-l0M0P4e3n4LQT0dZR+AlfA, dev-yBygre7rU0TnMu66kgdUjQ
Cc: netdev-u79uwXL29TY76Z2rM5mHXA, linux-kernel-u79uwXL29TY76Z2rM5mHXA
The megaflow feature introduced per-CPU stats, and the new code did some
refactoring as well [1]. However the new functions doesn't disable bottom halves
when locking the stat, and as they can be called from userspace context, they
can be interrupted by netif_receive_skb.
[1] e298e50570: openvswitch: Per cpu flow stats.
Signed-off-by: Zoltan Kiss <zoltan.kiss-Sxgqhf6Nn4DQT0dZR+AlfA@public.gmane.org>
---
v2: use _bh instead of _irqsave/restore
net/openvswitch/flow.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/net/openvswitch/flow.c b/net/openvswitch/flow.c
index 16f4b46..9110cf4 100644
--- a/net/openvswitch/flow.c
+++ b/net/openvswitch/flow.c
@@ -90,13 +90,13 @@ static void stats_read(struct flow_stats *stats,
struct ovs_flow_stats *ovs_stats,
unsigned long *used, __be16 *tcp_flags)
{
- spin_lock(&stats->lock);
+ spin_lock_bh(&stats->lock);
if (time_after(stats->used, *used))
*used = stats->used;
*tcp_flags |= stats->tcp_flags;
ovs_stats->n_packets += stats->packet_count;
ovs_stats->n_bytes += stats->byte_count;
- spin_unlock(&stats->lock);
+ spin_unlock_bh(&stats->lock);
}
void ovs_flow_stats_get(struct sw_flow *flow, struct ovs_flow_stats *ovs_stats,
@@ -130,12 +130,12 @@ void ovs_flow_stats_get(struct sw_flow *flow, struct ovs_flow_stats *ovs_stats,
static void stats_reset(struct flow_stats *stats)
{
- spin_lock(&stats->lock);
+ spin_lock_bh(&stats->lock);
stats->used = 0;
stats->packet_count = 0;
stats->byte_count = 0;
stats->tcp_flags = 0;
- spin_unlock(&stats->lock);
+ spin_unlock_bh(&stats->lock);
}
void ovs_flow_stats_clear(struct sw_flow *flow)
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2] openvswitch: Disable bottom half when grabbing stats lock in userspace context
2014-02-27 22:10 ` Zoltan Kiss
(?)
@ 2014-02-27 23:04 ` Pravin Shelar
-1 siblings, 0 replies; 3+ messages in thread
From: Pravin Shelar @ 2014-02-27 23:04 UTC (permalink / raw)
To: Zoltan Kiss; +Cc: Jesse Gross, dev, netdev, LKML
On Thu, Feb 27, 2014 at 2:10 PM, Zoltan Kiss <zoltan.kiss@citrix.com> wrote:
> The megaflow feature introduced per-CPU stats, and the new code did some
> refactoring as well [1]. However the new functions doesn't disable bottom halves
> when locking the stat, and as they can be called from userspace context, they
> can be interrupted by netif_receive_skb.
>
> [1] e298e50570: openvswitch: Per cpu flow stats.
>
This bug is fixed in openvswitch repo by commit "datapath: Fix
deadlock during stats update."
Thanks.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-02-27 23:10 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-27 22:10 [PATCH v2] openvswitch: Disable bottom half when grabbing stats lock in userspace context Zoltan Kiss
2014-02-27 22:10 ` Zoltan Kiss
2014-02-27 23:04 ` Pravin Shelar
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.