Skip to content

Commit 4077396

Browse files
Thadeu Lima de Souza Cascardodavem330
authored andcommitted
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>
1 parent 829ff34 commit 4077396

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

‎net/openvswitch/flow.c‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,8 @@ void ovs_flow_stats_get(const struct sw_flow *flow,
142142
*tcp_flags = 0;
143143
memset(ovs_stats, 0, sizeof(*ovs_stats));
144144

145-
for_each_node(node) {
145+
/* We open code this to make sure node 0 is always considered */
146+
for (node = 0; node < MAX_NUMNODES; node = next_node(node, node_possible_map)) {
146147
struct flow_stats *stats = rcu_dereference_ovsl(flow->stats[node]);
147148

148149
if (stats) {
@@ -165,7 +166,8 @@ void ovs_flow_stats_clear(struct sw_flow *flow)
165166
{
166167
int node;
167168

168-
for_each_node(node) {
169+
/* We open code this to make sure node 0 is always considered */
170+
for (node = 0; node < MAX_NUMNODES; node = next_node(node, node_possible_map)) {
169171
struct flow_stats *stats = ovsl_dereference(flow->stats[node]);
170172

171173
if (stats) {

‎net/openvswitch/flow_table.c‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,9 @@ static void flow_free(struct sw_flow *flow)
148148
kfree(flow->id.unmasked_key);
149149
if (flow->sf_acts)
150150
ovs_nla_free_flow_actions((struct sw_flow_actions __force *)flow->sf_acts);
151-
for_each_node(node)
152-
if (flow->stats[node])
151+
/* We open code this to make sure node 0 is always considered */
152+
for (node = 0; node < MAX_NUMNODES; node = next_node(node, node_possible_map))
153+
if (node != 0 && flow->stats[node])
153154
kmem_cache_free(flow_stats_cache,
154155
(struct flow_stats __force *)flow->stats[node]);
155156
kmem_cache_free(flow_cache, flow);

0 commit comments

Comments
 (0)