From 7da4b8b8dc6fc219af5abad1cd4bf0f91c3eb9b3 Mon Sep 17 00:00:00 2001 From: Tomoki Shirasawa Date: Wed, 3 Sep 2014 18:22:27 +0900 Subject: [PATCH] fix sched_[sg]etaffinity(tid==0, ...) (LTP sched_getaffinity01) --- kernel/syscall.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/kernel/syscall.c b/kernel/syscall.c index 5cdf9234..29b0a5d5 100644 --- a/kernel/syscall.c +++ b/kernel/syscall.c @@ -2009,6 +2009,7 @@ SYSCALL_DECLARE(sched_setaffinity) struct process *thread; int cpu_id; unsigned long irqstate; + extern int num_processors; if (sizeof(k_cpu_set) > len) { kprintf("%s:%d\n Too small buffer.", __FILE__, __LINE__); @@ -2023,11 +2024,13 @@ SYSCALL_DECLARE(sched_setaffinity) // XXX: We should build something like cpu_available_mask in advance CPU_ZERO(&cpu_set); - extern int num_processors; for (cpu_id = 0; cpu_id < num_processors; cpu_id++) if (CPU_ISSET(cpu_id, &k_cpu_set)) CPU_SET(cpu_id, &cpu_set); + if(tid == 0) + tid = cpu_local_var(current)->tid; + for (cpu_id = 0; cpu_id < num_processors; cpu_id++) { irqstate = ihk_mc_spinlock_lock(&get_cpu_local_var(cpu_id)->runq_lock); list_for_each_entry(thread, &get_cpu_local_var(cpu_id)->runq, sched_list) @@ -2064,6 +2067,7 @@ SYSCALL_DECLARE(sched_getaffinity) int found = 0; int i; unsigned long irqstate; + extern int num_processors; if (sizeof(k_cpu_set) > len) { kprintf("%s:%d Too small buffer.\n", __FILE__, __LINE__); @@ -2071,7 +2075,9 @@ SYSCALL_DECLARE(sched_getaffinity) } len = MIN2(len, sizeof(k_cpu_set)); - extern int num_processors; + if(tid == 0) + tid = cpu_local_var(current)->tid; + for (i = 0; i < num_processors && !found; i++) { struct process *thread; irqstate = ihk_mc_spinlock_lock(&get_cpu_local_var(i)->runq_lock);