Commit d9561c44 authored by Ziye Yang's avatar Ziye Yang Committed by Tomasz Zawadzki
Browse files

env/dpdk: Exclude the orig cpuset in spdk_unaffinitize_thread



The patch of this purpose is to exclude the CPU cores
occupied by the DPDK thread. To mitigate the corner
case, we only do it when the number of online CPU cores
is larger than then DPDK thread occupied cpu cores.

The purpose is uset to improve the performance and avoid the
contention between DPDK thread and user's own thread.

Change-Id: I1a4a28074df97c55ac531440aea41059a75543f6
Signed-off-by: default avatarZiye Yang <ziye.yang@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/471000


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarJinYu <jin.yu@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
parent 912ddafe
Loading
Loading
Loading
Loading
+12 −2
Original line number Diff line number Diff line
@@ -339,8 +339,8 @@ void spdk_pause(void)
void
spdk_unaffinitize_thread(void)
{
	rte_cpuset_t new_cpuset;
	long num_cores, i;
	rte_cpuset_t new_cpuset, orig_cpuset;
	long num_cores, i, orig_num_cores;

	CPU_ZERO(&new_cpuset);

@@ -351,6 +351,16 @@ spdk_unaffinitize_thread(void)
		CPU_SET(i, &new_cpuset);
	}

	rte_thread_get_affinity(&orig_cpuset);
	orig_num_cores = CPU_COUNT(&orig_cpuset);
	if (orig_num_cores < num_cores) {
		for (i = 0; i < orig_num_cores; i++) {
			if (CPU_ISSET(i, &orig_cpuset)) {
				CPU_CLR(i, &new_cpuset);
			}
		}
	}

	rte_thread_set_affinity(&new_cpuset);
}