summaryrefslogtreecommitdiff
path: root/drivers/infiniband/hw/hfi1/affinity.h
diff options
context:
space:
mode:
authorTadeusz Struk <tadeusz.struk@intel.com>2016-09-06 04:36:18 -0700
committerDoug Ledford <dledford@redhat.com>2016-10-02 08:42:08 -0400
commit584d9577ffecdb411f1fd0d160e76a1e141554c8 (patch)
tree9955f1acf9e6749f6d07eba487be930f8f86ae16 /drivers/infiniband/hw/hfi1/affinity.h
parent60368186fd853899c1819bcefa47f85fe8d5e5ad (diff)
IB/hfi1: Fix locking scheme for affinity settings
Existing locking scheme in affinity.c file using the &node_affinity.lock spinlock is not very elegant. We acquire the lock to get hfi1_affinity_node entry, unlock, and then use the entry without the lock held. With more functions being added, which access and modify the entries, this can lead to race conditions. This patch makes this locking scheme more consistent. It changes the spinlock to mutex. Since all the code is executed in a user process context there is no need for a spinlock. This also allows to keep the lock not only while we look up for the node affinity entry, but over the whole section where the entry is being used. Reviewed-by: Ira Weiny <ira.weiny@intel.com> Reviewed-by: Sebastian Sanchez <sebastian.sanchez@intel.com> Reviewed-by: Jianxin Xiong <jianxin.xiong@intel.com> Signed-off-by: Tadeusz Struk <tadeusz.struk@intel.com> Signed-off-by: Dennis Dalessandro <dennis.dalessandro@intel.com> Signed-off-by: Doug Ledford <dledford@redhat.com>
Diffstat (limited to 'drivers/infiniband/hw/hfi1/affinity.h')
-rw-r--r--drivers/infiniband/hw/hfi1/affinity.h3
1 files changed, 1 insertions, 2 deletions
diff --git a/drivers/infiniband/hw/hfi1/affinity.h b/drivers/infiniband/hw/hfi1/affinity.h
index 8879cf7a8cac..b89ea3c0ee1a 100644
--- a/drivers/infiniband/hw/hfi1/affinity.h
+++ b/drivers/infiniband/hw/hfi1/affinity.h
@@ -121,8 +121,7 @@ struct hfi1_affinity_node_list {
int num_core_siblings;
int num_online_nodes;
int num_online_cpus;
- /* protect affinity node list */
- spinlock_t lock;
+ struct mutex lock; /* protects affinity nodes */
};
int node_affinity_init(void);