aboutsummaryrefslogtreecommitdiffstats
path: root/include/rdma/ib_verbs.h
diff options
context:
space:
mode:
authorMark Bloch <markb@mellanox.com>2018-03-27 15:51:05 +0300
committerJason Gunthorpe <jgg@mellanox.com>2018-03-27 15:07:21 -0600
commite945130b52bea65d15f9bdf54949d4cb7a88db7f (patch)
treef6ec3278b190b01473e4aedee559bccc2ef5c4bc /include/rdma/ib_verbs.h
parentIB/mlx5: Respect new UMR capabilities (diff)
downloadlinux-dev-e945130b52bea65d15f9bdf54949d4cb7a88db7f.tar.xz
linux-dev-e945130b52bea65d15f9bdf54949d4cb7a88db7f.zip
IB/core: Protect against concurrent access to hardware stats
Currently access to hardware stats buffer isn't protected, this can result in multiple writes and reads at the same time to the same memory location. This can lead to providing an incorrect value to the user. Add a mutex to protect against it. Fixes: b40f4757daa1 ("IB/core: Make device counter infrastructure dynamic") Signed-off-by: Mark Bloch <markb@mellanox.com> Signed-off-by: Leon Romanovsky <leonro@mellanox.com> Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
Diffstat (limited to 'include/rdma/ib_verbs.h')
-rw-r--r--include/rdma/ib_verbs.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
index e9288d0f627e..48f416fabe0c 100644
--- a/include/rdma/ib_verbs.h
+++ b/include/rdma/ib_verbs.h
@@ -470,6 +470,9 @@ enum ib_port_speed {
/**
* struct rdma_hw_stats
+ * @lock - Mutex to protect parallel write access to lifespan and values
+ * of counters, which are 64bits and not guaranteeed to be written
+ * atomicaly on 32bits systems.
* @timestamp - Used by the core code to track when the last update was
* @lifespan - Used by the core code to determine how old the counters
* should be before being updated again. Stored in jiffies, defaults
@@ -485,6 +488,7 @@ enum ib_port_speed {
* filled in by the drivers get_stats routine
*/
struct rdma_hw_stats {
+ struct mutex lock; /* Protect lifespan and values[] */
unsigned long timestamp;
unsigned long lifespan;
const char * const *names;