Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

RDMA/counter: Query a counter before release

Query a dynamically-allocated counter before release it, to update it's
hwcounters and log all of them into history data. Otherwise all values of
these hwcounters will be lost.

Fixes: f34a55e497e8 ("RDMA/core: Get sum value of all counters when perform a sysfs stat read")
Link: https://lore.kernel.org/r/20200621110000.56059-1-leon@kernel.org
Signed-off-by: Mark Zhang <markz@mellanox.com>
Reviewed-by: Maor Gottlieb <maorg@mellanox.com>
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>

authored by

Mark Zhang and committed by
Jason Gunthorpe
c1d869d6 a17f4bed

+3 -1
+3 -1
drivers/infiniband/core/counters.c
··· 202 202 return ret; 203 203 } 204 204 205 - static void counter_history_stat_update(const struct rdma_counter *counter) 205 + static void counter_history_stat_update(struct rdma_counter *counter) 206 206 { 207 207 struct ib_device *dev = counter->device; 208 208 struct rdma_port_counter *port_counter; ··· 211 211 port_counter = &dev->port_data[counter->port].port_counter; 212 212 if (!port_counter->hstats) 213 213 return; 214 + 215 + rdma_counter_query_stats(counter); 214 216 215 217 for (i = 0; i < counter->stats->num_counters; i++) 216 218 port_counter->hstats->value[i] += counter->stats->value[i];