From c1dde86c38c0bb19d53b910915b968e6640f39fb Mon Sep 17 00:00:00 2001
From: Morris Jette <jette@schedmd.com>
Date: Fri, 25 Mar 2016 16:03:55 -0700
Subject: [PATCH] Revert commit efa83a021

The previous commit obviously fixed a problem, but introduced a different
set of problems. This will be pursued later, perhaps in version 16.05.
---
 NEWS                                         |  1 -
 src/plugins/task/cgroup/task_cgroup_cpuset.c | 36 +++-----------------
 2 files changed, 4 insertions(+), 33 deletions(-)

diff --git a/NEWS b/NEWS
index 1d30bacefbc..4d71eb924d9 100644
--- a/NEWS
+++ b/NEWS
@@ -68,7 +68,6 @@ documents those changes that are of interest to users and administrators.
     than at job submission time to reflect persistent buffers created or
     modified while the job is pending.
  -- Fix check of per-user qos limits on the initial run by a user.
- -- task/cgroup: Fix for task binding anomaly.
  -- Fix gang scheduling resource selection bug which could prevent multiple jobs
     from being allocated the same resources. Bug was introduced in 15.08.6.
  -- Don't print the Rgt value of an association from the cache as it isn't
diff --git a/src/plugins/task/cgroup/task_cgroup_cpuset.c b/src/plugins/task/cgroup/task_cgroup_cpuset.c
index ab86d0a812c..1f203d823ca 100644
--- a/src/plugins/task/cgroup/task_cgroup_cpuset.c
+++ b/src/plugins/task/cgroup/task_cgroup_cpuset.c
@@ -636,24 +636,6 @@ static void _add_hwloc_cpuset(
 	}
 }
 
-static int _hwloc_bit_count(hwloc_bitmap_t cpuset)
-{
-	int i_first, i_last, i, cnt = 0;
-
-	if (!cpuset)
-		return cnt;
-	i_first = hwloc_bitmap_first(cpuset);
-	if (i_first < 0)
-		return cnt;
-	cnt = 1;	/* For bit set at i_first */
-	i_last = hwloc_bitmap_last(cpuset);
-	for (i = i_first + 1; i <= i_last; i++) {
-		if (hwloc_bitmap_isset(cpuset, i))
-			cnt++;
-	}
-	return cnt;
-}
-
 static int _task_cgroup_cpuset_dist_cyclic(
 	hwloc_topology_t topology, hwloc_obj_type_t hwtype,
 	hwloc_obj_type_t req_hwtype, stepd_step_rec_t *job, int bind_verbose,
@@ -666,7 +648,7 @@ static int _task_cgroup_cpuset_dist_cyclic(
 	uint32_t *t_ix;		/* thread index by core by socket */
 	uint32_t npus, ncores, nsockets;
 	uint32_t taskid = job->envtp->localid;
-	int spec_thread_cnt = 0, pu_cnt;
+	int spec_thread_cnt = 0;
 	bitstr_t *spec_threads = NULL;
 
 	uint32_t obj_idxs[3], nthreads, cps,
@@ -754,7 +736,6 @@ static int _task_cgroup_cpuset_dist_cyclic(
 				topology, HWLOC_OBJ_SOCKET, s_ix,
 				hwtype, c_ixc[s_ix]);
 			if (obj != NULL) {
-				pu_cnt = _hwloc_bit_count(obj->allowed_cpuset);
 				if (hwloc_compare_types(hwtype, HWLOC_OBJ_PU)
 									>= 0) {
 					/* granularity is thread */
@@ -787,15 +768,10 @@ static int _task_cgroup_cpuset_dist_cyclic(
 						if (c_ixc[s_ix] == cps)
 							s_ix++;
 					}
-				} else if (pu_cnt < 1) {
-					/* No CPUs available on this core */
-					c_ixc[s_ix]++;
-					if (c_ixc[s_ix] == cps)
-						s_ix++;
 				} else {
 					/* granularity is core or larger */
 					c_ixc[s_ix]++;
-					j += pu_cnt;
+					j++;
 					if (i == ntskip)
 						_add_hwloc_cpuset(hwtype,
 							req_hwtype, obj, taskid,
@@ -809,7 +785,7 @@ static int _task_cgroup_cpuset_dist_cyclic(
 		/* if it succeeds, switch to the next task, starting
 		 * with the next available socket, otherwise, loop back
 		 * from the first socket trying to find available slots. */
-		if (j >= npdist) {
+		if (j == npdist) {
 			i++;
 			j = 0;
 			s_ix++; // no validity check, handled by the while
@@ -853,7 +829,7 @@ static int _task_cgroup_cpuset_dist_block(
 	uint32_t taskid = job->envtp->localid;
 	int hwdepth;
 	uint32_t npus, ncores, nsockets;
-	int spec_thread_cnt = 0, pu_cnt;
+	int spec_thread_cnt = 0;
 	bitstr_t *spec_threads = NULL;
 
 	uint32_t core_idx;
@@ -891,10 +867,6 @@ static int _task_cgroup_cpuset_dist_block(
 					hwtype, thread_idx[core_idx]);
 				if (obj != NULL) {
 					thread_idx[core_idx]++;
-					pu_cnt = _hwloc_bit_count(
-							obj->allowed_cpuset);
-					if (pu_cnt < 1)     /* No avail CPUs */
-						continue;
 					j++;
 					if (i == ntskip)
 						_add_hwloc_cpuset(hwtype,
-- 
GitLab