Closed GoogleCodeExporter closed 9 years ago
Please try this and tell me if it helps:
diff --git a/psutil/_psutil_linux.c b/psutil/_psutil_linux.c
--- a/psutil/_psutil_linux.c
+++ b/psutil/_psutil_linux.c
@@ -278,7 +278,7 @@
unsigned int len = sizeof(mask);
long pid;
- if (!PyArg_ParseTuple(args, "ll", &pid, &mask)) {
+ if (!PyArg_ParseTuple(args, "lk", &pid, &mask)) {
return NULL;
}
if (sched_setaffinity(pid, len, (cpu_set_t *)&mask)) {
I'm also attaching a modified version of your patch fixing a couple of issues
but I would prefer to keep calculating the bitmask in Python (as opposed to
using macros in C) as it's easier to read/maintain.
Original comment by g.rodola
on 8 Nov 2013 at 2:24
Attachments:
Up?
Original comment by g.rodola
on 13 Nov 2013 at 8:54
I'll try to look into it end of next week. I'm pretty busy at the moment, but
there should be some slack by then.
Original comment by andr...@sandberg.pp.se
on 13 Nov 2013 at 12:29
Thanks.
Original comment by g.rodola
on 13 Nov 2013 at 12:48
I committed this change as of revision af898681e7be.
I'm going to consider this closed for now. Let me know if I'm mistaken.
Original comment by g.rodola
on 22 Nov 2013 at 9:30
Closing.
Original comment by g.rodola
on 26 Nov 2013 at 8:52
Original comment by g.rodola
on 26 Nov 2013 at 8:52
I just got around to test it and it seems to work fine on our machine. But,
isn't your fix going to break as soon as someone runs this on a machine with
more than 64 threads? Besides, CPU_SET(3) is pretty clear on how cpu_set_t
structures should be constructed: "...the data structure treated as considered
opaque: all manipulation of CPU sets should be done via the macros described in
this page.".
Original comment by andr...@sandberg.pp.se
on 26 Nov 2013 at 3:33
> But, isn't your fix going to break as soon as someone runs this on a machine
with more than 64 threads?
Mmm... Why do you think so?
Original comment by g.rodola
on 26 Nov 2013 at 4:50
If I understand things correctly, the bitmask from Python is going to be
converted to a 64-bit unsigned long, hence the 64 threads limit.
IIRC, the by default the recent Linux implementations use a 1024-bit cpu_set_t,
but this can be extended to arbitrarily sizes by using CPU_ALLOC.
Original comment by andr...@sandberg.pp.se
on 26 Nov 2013 at 4:59
I think you may be right. Committed the C version in revision e0df8ab562a6.
Original comment by g.rodola
on 3 Dec 2013 at 8:51
Original issue reported on code.google.com by
andr...@sandberg.pp.se
on 31 Oct 2013 at 6:24Attachments: