aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/infiniband/hw/hfi1/file_ops.c
diff options
context:
space:
mode:
authorSebastian Sanchez <sebastian.sanchez@intel.com>2016-07-25 10:54:57 -0400
committerDoug Ledford <dledford@redhat.com>2016-08-02 15:47:33 -0400
commitb094a36f90975373c3a241839869217a65f17d81 (patch)
tree4bc2b3fb7b19f69a7ff7786c5bbca58b83cd6762 /drivers/infiniband/hw/hfi1/file_ops.c
parentd63730192f5914c0f6feec3d45116486be1d36e3 (diff)
IB/hfi1: Refine user process affinity algorithm
When performing process affinity recommendations for MPI ranks, the current algorithm doesn't take into account multiple HFI units. Also, real cores and HT cores are not distinguished from one another. Therefore, all HT cores are recommended to be assigned first within the local NUMA node before recommending the assignments of cores in other NUMA nodes. It's ideal to assign all real cores across all NUMA nodes first, then all HT 1 cores, then all HT 2 cores, and so on to balance CPU workload. CPU cores in other NUMA nodes could be running interrupt handlers, and this is not taken into account. To balance the CPU workload for user processes, the following recommendation algorithm is used: For each user process that is opening a context on HFI Y: a) If all cores are assigned to user processes, start assignments all over from the first core b) Assign real cores first, then HT cores (First set of HT cores on all physical cores, then second set of HT cores, and, so on) in the following order: 1. Same NUMA node as HFI Y and not running an IRQ handler 2. Same NUMA node as HFI Y and running an IRQ handler 3. Different NUMA node to HFI Y and not running an IRQ handler 4. Different NUMA node to HFI Y and running an IRQ handler c) Mark core as assigned in the global affinity structure. As user processes are done, remove core assignments from global affinity structure. This implementation allows an arbitrary number of HT cores and provides support for multiple HFIs. This is being included in the kernel rather than user space due to the fact that user space has no way of knowing the CPU recommendations for contexts running as part of other jobs. Reviewed-by: Ira Weiny <ira.weiny@intel.com> Reviewed-by: Mitko Haralanov <mitko.haralanov@intel.com> Reviewed-by: Dennis Dalessandro <dennis.dalessandro@intel.com> Signed-off-by: Sebastian Sanchez <sebastian.sanchez@intel.com> Signed-off-by: Doug Ledford <dledford@redhat.com>
Diffstat (limited to 'drivers/infiniband/hw/hfi1/file_ops.c')
-rw-r--r--drivers/infiniband/hw/hfi1/file_ops.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/drivers/infiniband/hw/hfi1/file_ops.c b/drivers/infiniband/hw/hfi1/file_ops.c
index 2f097d942f9c..d7c07bc7bd14 100644
--- a/drivers/infiniband/hw/hfi1/file_ops.c
+++ b/drivers/infiniband/hw/hfi1/file_ops.c
@@ -715,7 +715,7 @@ static int hfi1_file_close(struct inode *inode, struct file *fp)
715 hfi1_user_sdma_free_queues(fdata); 715 hfi1_user_sdma_free_queues(fdata);
716 716
717 /* release the cpu */ 717 /* release the cpu */
718 hfi1_put_proc_affinity(dd, fdata->rec_cpu_num); 718 hfi1_put_proc_affinity(fdata->rec_cpu_num);
719 719
720 /* 720 /*
721 * Clear any left over, unhandled events so the next process that 721 * Clear any left over, unhandled events so the next process that
@@ -815,9 +815,10 @@ static int assign_ctxt(struct file *fp, struct hfi1_user_info *uinfo)
815 ret = find_shared_ctxt(fp, uinfo); 815 ret = find_shared_ctxt(fp, uinfo);
816 if (ret < 0) 816 if (ret < 0)
817 goto done_unlock; 817 goto done_unlock;
818 if (ret) 818 if (ret) {
819 fd->rec_cpu_num = hfi1_get_proc_affinity( 819 fd->rec_cpu_num =
820 fd->uctxt->dd, fd->uctxt->numa_id); 820 hfi1_get_proc_affinity(fd->uctxt->numa_id);
821 }
821 } 822 }
822 823
823 /* 824 /*
@@ -929,7 +930,11 @@ static int allocate_ctxt(struct file *fp, struct hfi1_devdata *dd,
929 if (ctxt == dd->num_rcv_contexts) 930 if (ctxt == dd->num_rcv_contexts)
930 return -EBUSY; 931 return -EBUSY;
931 932
932 fd->rec_cpu_num = hfi1_get_proc_affinity(dd, -1); 933 /*
934 * If we don't have a NUMA node requested, preference is towards
935 * device NUMA node.
936 */
937 fd->rec_cpu_num = hfi1_get_proc_affinity(dd->node);
933 if (fd->rec_cpu_num != -1) 938 if (fd->rec_cpu_num != -1)
934 numa = cpu_to_node(fd->rec_cpu_num); 939 numa = cpu_to_node(fd->rec_cpu_num);
935 else 940 else