diff options
| author | Qiuwen Lu <[email protected]> | 2016-12-08 21:13:04 +0800 |
|---|---|---|
| committer | Qiuwen Lu <[email protected]> | 2016-12-08 21:13:04 +0800 |
| commit | 7ea9ff387d4266042e6469f678a7828b211ae590 (patch) | |
| tree | b60339d3e62b0d7d87545ff230cdd03a67a81604 /runtime/src | |
| parent | e7312311de94cc2c99ea44631d73dcd87ba1adbf (diff) | |
修正大于32核心服务器上的线程绑定问题,增加了每个应用的统计详情输出
Diffstat (limited to 'runtime/src')
| -rw-r--r-- | runtime/src/app.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/runtime/src/app.c b/runtime/src/app.c index e598966..f7e2ac3 100644 --- a/runtime/src/app.c +++ b/runtime/src/app.c @@ -279,10 +279,14 @@ struct thread_info * __thread_lookup_unsafe(struct appinfo * pinfo, thread_id_t return NULL; } -int __set_affinity(cpu_mask_t mask) +int __set_affinity(unsigned int cpu_id) { + cpu_set_t _cpu_set; + CPU_ZERO(&_cpu_set); + CPU_SET(cpu_id, &_cpu_set); + pthread_t ppid = pthread_self(); - int ret = pthread_setaffinity_np(ppid, sizeof(cpu_mask_t), (cpu_set_t *)&mask); + int ret = pthread_setaffinity_np(ppid, sizeof(cpu_mask_t), &_cpu_set); return ret; } @@ -312,8 +316,7 @@ int __thread_set_affinity(struct appinfo * pinfo, socket_id_t socket_id = mr_hwinfo_socket_id(cpu_id); assert(socket_id >= 0 && socket_id < mr_hwinfo_nr_sockets()); - cpu_mask_t thread_cpu_mask = 1L << cpu_id; - if(__set_affinity(thread_cpu_mask) < 0) + if(__set_affinity(cpu_id) != 0) { MR_LOG(INFO, BASE, "AppInfo, ThreadSetAffinity, " "Thread %d in Process %s, Call Pthread Error : %s\n", |
