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: Ziye Yang <ziye.yang@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/471000
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: JinYu <jin.yu@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
This commit is contained in:
Ziye Yang 2019-10-11 12:53:10 +08:00 committed by Tomasz Zawadzki
parent 912ddafe94
commit d9561c444f

View File

@ -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);
}