* [PATCH] sched: Fix sched_getaffinity
@ 2010-04-06 7:02 Anton Blanchard
2010-04-06 7:20 ` KOSAKI Motohiro
2010-04-06 8:32 ` [tip:sched/urgent] sched: Fix sched_getaffinity() tip-bot for Anton Blanchard
0 siblings, 2 replies; 3+ messages in thread
From: Anton Blanchard @ 2010-04-06 7:02 UTC (permalink / raw)
To: KOSAKI Motohiro, Sharyathi Nagesh, Ulrich Drepper,
Peter Zijlstra, Linus Torvalds, Andrew Morton, Jack Steiner,
Russ Anderson, Mike Travis, Ingo Molnar
Cc: linux-kernel
taskset on 2.6.34-rc3 fails on one of my ppc64 test boxes with the following
error:
sched_getaffinity(0, 16, 0x10029650030) = -1 EINVAL (Invalid argument)
This box has 128 threads and 16 bytes is enough to cover it. Commit
cd3d8031eb4311e516329aee03c79a08333141f1 (sched: sched_getaffinity(): Allow
less than NR_CPUS length) is comparing this 16 bytes agains nr_cpu_ids.
Fix it by comparing nr_cpu_ids to the number of bits in the cpumask we pass in.
Signed-off-by: Anton Blanchard <anton@samba.org>
---
diff --git a/kernel/sched.c b/kernel/sched.c
index 49d2fa7..0c1ec87 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -4902,7 +4902,7 @@ SYSCALL_DEFINE3(sched_getaffinity, pid_t, pid, unsigned int, len,
int ret;
cpumask_var_t mask;
- if (len < nr_cpu_ids)
+ if ((len * BITS_PER_BYTE) < nr_cpu_ids)
return -EINVAL;
if (len & (sizeof(unsigned long)-1))
return -EINVAL;
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] sched: Fix sched_getaffinity
2010-04-06 7:02 [PATCH] sched: Fix sched_getaffinity Anton Blanchard
@ 2010-04-06 7:20 ` KOSAKI Motohiro
2010-04-06 8:32 ` [tip:sched/urgent] sched: Fix sched_getaffinity() tip-bot for Anton Blanchard
1 sibling, 0 replies; 3+ messages in thread
From: KOSAKI Motohiro @ 2010-04-06 7:20 UTC (permalink / raw)
To: Anton Blanchard
Cc: kosaki.motohiro, Sharyathi Nagesh, Ulrich Drepper,
Peter Zijlstra, Linus Torvalds, Andrew Morton, Jack Steiner,
Russ Anderson, Mike Travis, Ingo Molnar, linux-kernel
>
> taskset on 2.6.34-rc3 fails on one of my ppc64 test boxes with the following
> error:
>
> sched_getaffinity(0, 16, 0x10029650030) = -1 EINVAL (Invalid argument)
>
> This box has 128 threads and 16 bytes is enough to cover it. Commit
> cd3d8031eb4311e516329aee03c79a08333141f1 (sched: sched_getaffinity(): Allow
> less than NR_CPUS length) is comparing this 16 bytes agains nr_cpu_ids.
>
> Fix it by comparing nr_cpu_ids to the number of bits in the cpumask we pass in.
>
> Signed-off-by: Anton Blanchard <anton@samba.org>
Oops, yes yes, thanks to correct my moron ;-)
I'll stop all todays job and will get sleeping soon.
Reviewed-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
> ---
>
> diff --git a/kernel/sched.c b/kernel/sched.c
> index 49d2fa7..0c1ec87 100644
> --- a/kernel/sched.c
> +++ b/kernel/sched.c
> @@ -4902,7 +4902,7 @@ SYSCALL_DEFINE3(sched_getaffinity, pid_t, pid, unsigned int, len,
> int ret;
> cpumask_var_t mask;
>
> - if (len < nr_cpu_ids)
> + if ((len * BITS_PER_BYTE) < nr_cpu_ids)
> return -EINVAL;
> if (len & (sizeof(unsigned long)-1))
> return -EINVAL;
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
^ permalink raw reply [flat|nested] 3+ messages in thread
* [tip:sched/urgent] sched: Fix sched_getaffinity()
2010-04-06 7:02 [PATCH] sched: Fix sched_getaffinity Anton Blanchard
2010-04-06 7:20 ` KOSAKI Motohiro
@ 2010-04-06 8:32 ` tip-bot for Anton Blanchard
1 sibling, 0 replies; 3+ messages in thread
From: tip-bot for Anton Blanchard @ 2010-04-06 8:32 UTC (permalink / raw)
To: linux-tip-commits
Cc: linux-kernel, anton, hpa, mingo, travis, torvalds, peterz, rja,
sharyath, drepper, steiner, tglx, kosaki.motohiro, mingo
Commit-ID: 84fba5ec91f11c0efb27d0ed6098f7447491f0df
Gitweb: http://git.kernel.org/tip/84fba5ec91f11c0efb27d0ed6098f7447491f0df
Author: Anton Blanchard <anton@samba.org>
AuthorDate: Tue, 6 Apr 2010 17:02:19 +1000
Committer: Ingo Molnar <mingo@elte.hu>
CommitDate: Tue, 6 Apr 2010 10:01:35 +0200
sched: Fix sched_getaffinity()
taskset on 2.6.34-rc3 fails on one of my ppc64 test boxes with
the following error:
sched_getaffinity(0, 16, 0x10029650030) = -1 EINVAL (Invalid argument)
This box has 128 threads and 16 bytes is enough to cover it.
Commit cd3d8031eb4311e516329aee03c79a08333141f1 (sched:
sched_getaffinity(): Allow less than NR_CPUS length) is
comparing this 16 bytes agains nr_cpu_ids.
Fix it by comparing nr_cpu_ids to the number of bits in the
cpumask we pass in.
Signed-off-by: Anton Blanchard <anton@samba.org>
Reviewed-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Cc: Sharyathi Nagesh <sharyath@in.ibm.com>
Cc: Ulrich Drepper <drepper@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Jack Steiner <steiner@sgi.com>
Cc: Russ Anderson <rja@sgi.com>
Cc: Mike Travis <travis@sgi.com>
LKML-Reference: <20100406070218.GM5594@kryten>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
kernel/sched.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/kernel/sched.c b/kernel/sched.c
index 528a105..eaf5c73 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -4902,7 +4902,7 @@ SYSCALL_DEFINE3(sched_getaffinity, pid_t, pid, unsigned int, len,
int ret;
cpumask_var_t mask;
- if (len < nr_cpu_ids)
+ if ((len * BITS_PER_BYTE) < nr_cpu_ids)
return -EINVAL;
if (len & (sizeof(unsigned long)-1))
return -EINVAL;
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-04-06 8:32 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-04-06 7:02 [PATCH] sched: Fix sched_getaffinity Anton Blanchard
2010-04-06 7:20 ` KOSAKI Motohiro
2010-04-06 8:32 ` [tip:sched/urgent] sched: Fix sched_getaffinity() tip-bot for Anton Blanchard
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome