]> git.proxmox.com Git - mirror_ovs.git/commitdiff
datapath: fix flow stats accounting when node 0 is not possible
authorThadeu Lima de Souza Cascardo <cascardo@redhat.com>
Thu, 16 Feb 2017 01:34:13 +0000 (17:34 -0800)
committerJoe Stringer <joe@ovn.org>
Thu, 2 Mar 2017 23:51:38 +0000 (15:51 -0800)
Upstream commit:
    commit 40773966ccf1985a1b2bb570a03cbeaf1cbd4e00
    Author: Thadeu Lima de Souza Cascardo <cascardo@redhat.com>
    Date:   Thu Sep 15 19:11:52 2016 -0300

    openvswitch: fix flow stats accounting when node 0 is not possible

    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>
Signed-off-by: David S. Miller <davem@davemloft.net>
This patch contained a memory leak that is fixed in this backport.
The next patch silently fixed that in upstream, too.

Signed-off-by: Jarno Rajahalme <jarno@ovn.org>
Signed-off-by: Joe Stringer <joe@ovn.org>
datapath/flow.c
datapath/flow_table.c

index 1a930a4c0b9baffe7ef40e20570165f181240a07..ef3eba0dbb07f7e6aa1ef47cdf79a01b95513bfe 100644 (file)
@@ -141,7 +141,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) {
@@ -164,7 +165,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) {
index d4204e5038d268aa67f120f1089d741fa223f54c..3829b920b057a080f221acea90dd1309c0a55b63 100644 (file)
@@ -154,7 +154,8 @@ 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)
+       /* 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 (flow->stats[node])
                        kmem_cache_free(flow_stats_cache,
                                        rcu_dereference_raw(flow->stats[node]));