diff mbox

[ovs-dev,v2,1/2] openvswitch: fix flow stats accounting when node 0 is not possible

Message ID 1473977513-7617-1-git-send-email-cascardo@redhat.com
State Not Applicable
Headers show

Commit Message

Thadeu Lima de Souza Cascardo Sept. 15, 2016, 10:11 p.m. UTC
On a system with only node 1 as possible, all statistics is going to be
accounted on node 0 as it will have a single writer.

However, when getting and clearing the statistics, node 0 is not going
to be considered, as it's not a possible node.

Tested that statistics are not zero on a system with only node 1
possible. Also compile-tested with CONFIG_NUMA off.

Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@redhat.com>
---
 net/openvswitch/flow.c       | 6 ++++--
 net/openvswitch/flow_table.c | 5 +++--
 2 files changed, 7 insertions(+), 4 deletions(-)

Comments

Pravin Shelar Sept. 18, 2016, 2:06 a.m. UTC | #1
On Thu, Sep 15, 2016 at 3:11 PM, Thadeu Lima de Souza Cascardo
<cascardo@redhat.com> wrote:
> On a system with only node 1 as possible, all statistics is going to be
> accounted on node 0 as it will have a single writer.
>
> However, when getting and clearing the statistics, node 0 is not going
> to be considered, as it's not a possible node.
>
> Tested that statistics are not zero on a system with only node 1
> possible. Also compile-tested with CONFIG_NUMA off.
>
> Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@redhat.com>

Acked-by: Pravin B Shelar <pshelar@ovn.org>
David Miller Sept. 19, 2016, 2:14 a.m. UTC | #2
From: Thadeu Lima de Souza Cascardo <cascardo@redhat.com>
Date: Thu, 15 Sep 2016 19:11:52 -0300

> On a system with only node 1 as possible, all statistics is going to be
> accounted on node 0 as it will have a single writer.
> 
> However, when getting and clearing the statistics, node 0 is not going
> to be considered, as it's not a possible node.
> 
> Tested that statistics are not zero on a system with only node 1
> possible. Also compile-tested with CONFIG_NUMA off.
> 
> Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@redhat.com>

Applied to net-next.
diff mbox

Patch

diff --git a/net/openvswitch/flow.c b/net/openvswitch/flow.c
index 1240ae3..5b80612 100644
--- a/net/openvswitch/flow.c
+++ b/net/openvswitch/flow.c
@@ -142,7 +142,8 @@  void ovs_flow_stats_get(const struct sw_flow *flow,
 	*tcp_flags = 0;
 	memset(ovs_stats, 0, sizeof(*ovs_stats));
 
-	for_each_node(node) {
+	/* We open code this to make sure node 0 is always considered */
+	for (node = 0; node < MAX_NUMNODES; node = next_node(node, node_possible_map)) {
 		struct flow_stats *stats = rcu_dereference_ovsl(flow->stats[node]);
 
 		if (stats) {
@@ -165,7 +166,8 @@  void ovs_flow_stats_clear(struct sw_flow *flow)
 {
 	int node;
 
-	for_each_node(node) {
+	/* We open code this to make sure node 0 is always considered */
+	for (node = 0; node < MAX_NUMNODES; node = next_node(node, node_possible_map)) {
 		struct flow_stats *stats = ovsl_dereference(flow->stats[node]);
 
 		if (stats) {
diff --git a/net/openvswitch/flow_table.c b/net/openvswitch/flow_table.c
index d073fff..957a3c3 100644
--- a/net/openvswitch/flow_table.c
+++ b/net/openvswitch/flow_table.c
@@ -148,8 +148,9 @@  static void flow_free(struct sw_flow *flow)
 		kfree(flow->id.unmasked_key);
 	if (flow->sf_acts)
 		ovs_nla_free_flow_actions((struct sw_flow_actions __force *)flow->sf_acts);
-	for_each_node(node)
-		if (flow->stats[node])
+	/* We open code this to make sure node 0 is always considered */
+	for (node = 0; node < MAX_NUMNODES; node = next_node(node, node_possible_map))
+		if (node != 0 && flow->stats[node])
 			kmem_cache_free(flow_stats_cache,
 					(struct flow_stats __force *)flow->stats[node]);
 	kmem_cache_free(flow_cache, flow);