author | Andrew Balfour <Andrew.Balfour@Oracle.COM> |
Fri, 15 Apr 2016 14:44:19 -0700 | |
changeset 5793 | baf73b0669ce |
permissions | -rw-r--r-- |
5793
baf73b0669ce
23038981 psutil needs to not linearly enumerate cpuids
Andrew Balfour <Andrew.Balfour@Oracle.COM>
parents:
diff
changeset
|
1 |
Upstream patch to fix issue #496. https://github.com/giampaolo/psutil/issues/496 |
baf73b0669ce
23038981 psutil needs to not linearly enumerate cpuids
Andrew Balfour <Andrew.Balfour@Oracle.COM>
parents:
diff
changeset
|
2 |
Pulled from https://github.com/giampaolo/psutil/commit/f1275c19ac9e77b9169ca84dfb7d7701a8a2f9d7 |
baf73b0669ce
23038981 psutil needs to not linearly enumerate cpuids
Andrew Balfour <Andrew.Balfour@Oracle.COM>
parents:
diff
changeset
|
3 |
|
baf73b0669ce
23038981 psutil needs to not linearly enumerate cpuids
Andrew Balfour <Andrew.Balfour@Oracle.COM>
parents:
diff
changeset
|
4 |
Issue is fixed in psutil 2.2.0, but the module is pinned to >= 1.1.1, < 2.0.0 |
baf73b0669ce
23038981 psutil needs to not linearly enumerate cpuids
Andrew Balfour <Andrew.Balfour@Oracle.COM>
parents:
diff
changeset
|
5 |
by OpenStack requirements. |
baf73b0669ce
23038981 psutil needs to not linearly enumerate cpuids
Andrew Balfour <Andrew.Balfour@Oracle.COM>
parents:
diff
changeset
|
6 |
|
baf73b0669ce
23038981 psutil needs to not linearly enumerate cpuids
Andrew Balfour <Andrew.Balfour@Oracle.COM>
parents:
diff
changeset
|
7 |
Should psutil be updated to or past 2.2.0, this patch can be removed. |
baf73b0669ce
23038981 psutil needs to not linearly enumerate cpuids
Andrew Balfour <Andrew.Balfour@Oracle.COM>
parents:
diff
changeset
|
8 |
|
baf73b0669ce
23038981 psutil needs to not linearly enumerate cpuids
Andrew Balfour <Andrew.Balfour@Oracle.COM>
parents:
diff
changeset
|
9 |
--- psutil-1.2.1/psutil/_psutil_sunos.c.orig 2016-04-15 12:57:05.971196362 -0700 |
baf73b0669ce
23038981 psutil needs to not linearly enumerate cpuids
Andrew Balfour <Andrew.Balfour@Oracle.COM>
parents:
diff
changeset
|
10 |
+++ psutil-1.2.1/psutil/_psutil_sunos.c 2016-04-15 12:58:51.079231642 -0700 |
baf73b0669ce
23038981 psutil needs to not linearly enumerate cpuids
Andrew Balfour <Andrew.Balfour@Oracle.COM>
parents:
diff
changeset
|
11 |
@@ -445,29 +445,24 @@ |
baf73b0669ce
23038981 psutil needs to not linearly enumerate cpuids
Andrew Balfour <Andrew.Balfour@Oracle.COM>
parents:
diff
changeset
|
12 |
goto error; |
baf73b0669ce
23038981 psutil needs to not linearly enumerate cpuids
Andrew Balfour <Andrew.Balfour@Oracle.COM>
parents:
diff
changeset
|
13 |
} |
baf73b0669ce
23038981 psutil needs to not linearly enumerate cpuids
Andrew Balfour <Andrew.Balfour@Oracle.COM>
parents:
diff
changeset
|
14 |
|
baf73b0669ce
23038981 psutil needs to not linearly enumerate cpuids
Andrew Balfour <Andrew.Balfour@Oracle.COM>
parents:
diff
changeset
|
15 |
- numcpus = sysconf(_SC_NPROCESSORS_ONLN) - 1; |
baf73b0669ce
23038981 psutil needs to not linearly enumerate cpuids
Andrew Balfour <Andrew.Balfour@Oracle.COM>
parents:
diff
changeset
|
16 |
- for (i=0; i<=numcpus; i++) { |
baf73b0669ce
23038981 psutil needs to not linearly enumerate cpuids
Andrew Balfour <Andrew.Balfour@Oracle.COM>
parents:
diff
changeset
|
17 |
- ksp = kstat_lookup(kc, "cpu_stat", i, NULL); |
baf73b0669ce
23038981 psutil needs to not linearly enumerate cpuids
Andrew Balfour <Andrew.Balfour@Oracle.COM>
parents:
diff
changeset
|
18 |
- if (ksp == NULL) { |
baf73b0669ce
23038981 psutil needs to not linearly enumerate cpuids
Andrew Balfour <Andrew.Balfour@Oracle.COM>
parents:
diff
changeset
|
19 |
- PyErr_SetFromErrno(PyExc_OSError); |
baf73b0669ce
23038981 psutil needs to not linearly enumerate cpuids
Andrew Balfour <Andrew.Balfour@Oracle.COM>
parents:
diff
changeset
|
20 |
- goto error; |
baf73b0669ce
23038981 psutil needs to not linearly enumerate cpuids
Andrew Balfour <Andrew.Balfour@Oracle.COM>
parents:
diff
changeset
|
21 |
- } |
baf73b0669ce
23038981 psutil needs to not linearly enumerate cpuids
Andrew Balfour <Andrew.Balfour@Oracle.COM>
parents:
diff
changeset
|
22 |
- if (kstat_read(kc, ksp, &cs) == -1) { |
baf73b0669ce
23038981 psutil needs to not linearly enumerate cpuids
Andrew Balfour <Andrew.Balfour@Oracle.COM>
parents:
diff
changeset
|
23 |
- PyErr_SetFromErrno(PyExc_OSError); |
baf73b0669ce
23038981 psutil needs to not linearly enumerate cpuids
Andrew Balfour <Andrew.Balfour@Oracle.COM>
parents:
diff
changeset
|
24 |
- goto error; |
baf73b0669ce
23038981 psutil needs to not linearly enumerate cpuids
Andrew Balfour <Andrew.Balfour@Oracle.COM>
parents:
diff
changeset
|
25 |
- } |
baf73b0669ce
23038981 psutil needs to not linearly enumerate cpuids
Andrew Balfour <Andrew.Balfour@Oracle.COM>
parents:
diff
changeset
|
26 |
- |
baf73b0669ce
23038981 psutil needs to not linearly enumerate cpuids
Andrew Balfour <Andrew.Balfour@Oracle.COM>
parents:
diff
changeset
|
27 |
- py_cputime = Py_BuildValue("ffff", |
baf73b0669ce
23038981 psutil needs to not linearly enumerate cpuids
Andrew Balfour <Andrew.Balfour@Oracle.COM>
parents:
diff
changeset
|
28 |
- (float)cs.cpu_sysinfo.cpu[CPU_USER], |
baf73b0669ce
23038981 psutil needs to not linearly enumerate cpuids
Andrew Balfour <Andrew.Balfour@Oracle.COM>
parents:
diff
changeset
|
29 |
- (float)cs.cpu_sysinfo.cpu[CPU_KERNEL], |
baf73b0669ce
23038981 psutil needs to not linearly enumerate cpuids
Andrew Balfour <Andrew.Balfour@Oracle.COM>
parents:
diff
changeset
|
30 |
- (float)cs.cpu_sysinfo.cpu[CPU_IDLE], |
baf73b0669ce
23038981 psutil needs to not linearly enumerate cpuids
Andrew Balfour <Andrew.Balfour@Oracle.COM>
parents:
diff
changeset
|
31 |
- (float)cs.cpu_sysinfo.cpu[CPU_WAIT]); |
baf73b0669ce
23038981 psutil needs to not linearly enumerate cpuids
Andrew Balfour <Andrew.Balfour@Oracle.COM>
parents:
diff
changeset
|
32 |
- if (py_cputime == NULL) |
baf73b0669ce
23038981 psutil needs to not linearly enumerate cpuids
Andrew Balfour <Andrew.Balfour@Oracle.COM>
parents:
diff
changeset
|
33 |
- goto error; |
baf73b0669ce
23038981 psutil needs to not linearly enumerate cpuids
Andrew Balfour <Andrew.Balfour@Oracle.COM>
parents:
diff
changeset
|
34 |
- if (PyList_Append(py_retlist, py_cputime)) |
baf73b0669ce
23038981 psutil needs to not linearly enumerate cpuids
Andrew Balfour <Andrew.Balfour@Oracle.COM>
parents:
diff
changeset
|
35 |
- goto error; |
baf73b0669ce
23038981 psutil needs to not linearly enumerate cpuids
Andrew Balfour <Andrew.Balfour@Oracle.COM>
parents:
diff
changeset
|
36 |
- Py_DECREF(py_cputime); |
baf73b0669ce
23038981 psutil needs to not linearly enumerate cpuids
Andrew Balfour <Andrew.Balfour@Oracle.COM>
parents:
diff
changeset
|
37 |
- |
baf73b0669ce
23038981 psutil needs to not linearly enumerate cpuids
Andrew Balfour <Andrew.Balfour@Oracle.COM>
parents:
diff
changeset
|
38 |
+ for (ksp = kc->kc_chain; ksp != NULL; ksp = ksp->ks_next) { |
baf73b0669ce
23038981 psutil needs to not linearly enumerate cpuids
Andrew Balfour <Andrew.Balfour@Oracle.COM>
parents:
diff
changeset
|
39 |
+ if (strcmp(ksp->ks_module, "cpu_stat") == 0) { |
baf73b0669ce
23038981 psutil needs to not linearly enumerate cpuids
Andrew Balfour <Andrew.Balfour@Oracle.COM>
parents:
diff
changeset
|
40 |
+ if (kstat_read(kc, ksp, &cs) == -1) { |
baf73b0669ce
23038981 psutil needs to not linearly enumerate cpuids
Andrew Balfour <Andrew.Balfour@Oracle.COM>
parents:
diff
changeset
|
41 |
+ PyErr_SetFromErrno(PyExc_OSError); |
baf73b0669ce
23038981 psutil needs to not linearly enumerate cpuids
Andrew Balfour <Andrew.Balfour@Oracle.COM>
parents:
diff
changeset
|
42 |
+ goto error; |
baf73b0669ce
23038981 psutil needs to not linearly enumerate cpuids
Andrew Balfour <Andrew.Balfour@Oracle.COM>
parents:
diff
changeset
|
43 |
+ } |
baf73b0669ce
23038981 psutil needs to not linearly enumerate cpuids
Andrew Balfour <Andrew.Balfour@Oracle.COM>
parents:
diff
changeset
|
44 |
+ py_cputime = Py_BuildValue("ffff", |
baf73b0669ce
23038981 psutil needs to not linearly enumerate cpuids
Andrew Balfour <Andrew.Balfour@Oracle.COM>
parents:
diff
changeset
|
45 |
+ (float)cs.cpu_sysinfo.cpu[CPU_USER], |
baf73b0669ce
23038981 psutil needs to not linearly enumerate cpuids
Andrew Balfour <Andrew.Balfour@Oracle.COM>
parents:
diff
changeset
|
46 |
+ (float)cs.cpu_sysinfo.cpu[CPU_KERNEL], |
baf73b0669ce
23038981 psutil needs to not linearly enumerate cpuids
Andrew Balfour <Andrew.Balfour@Oracle.COM>
parents:
diff
changeset
|
47 |
+ (float)cs.cpu_sysinfo.cpu[CPU_IDLE], |
baf73b0669ce
23038981 psutil needs to not linearly enumerate cpuids
Andrew Balfour <Andrew.Balfour@Oracle.COM>
parents:
diff
changeset
|
48 |
+ (float)cs.cpu_sysinfo.cpu[CPU_WAIT]); |
baf73b0669ce
23038981 psutil needs to not linearly enumerate cpuids
Andrew Balfour <Andrew.Balfour@Oracle.COM>
parents:
diff
changeset
|
49 |
+ if (py_cputime == NULL) |
baf73b0669ce
23038981 psutil needs to not linearly enumerate cpuids
Andrew Balfour <Andrew.Balfour@Oracle.COM>
parents:
diff
changeset
|
50 |
+ goto error; |
baf73b0669ce
23038981 psutil needs to not linearly enumerate cpuids
Andrew Balfour <Andrew.Balfour@Oracle.COM>
parents:
diff
changeset
|
51 |
+ if (PyList_Append(py_retlist, py_cputime)) |
baf73b0669ce
23038981 psutil needs to not linearly enumerate cpuids
Andrew Balfour <Andrew.Balfour@Oracle.COM>
parents:
diff
changeset
|
52 |
+ goto error; |
baf73b0669ce
23038981 psutil needs to not linearly enumerate cpuids
Andrew Balfour <Andrew.Balfour@Oracle.COM>
parents:
diff
changeset
|
53 |
+ Py_DECREF(py_cputime); |
baf73b0669ce
23038981 psutil needs to not linearly enumerate cpuids
Andrew Balfour <Andrew.Balfour@Oracle.COM>
parents:
diff
changeset
|
54 |
+ py_cputime = NULL; |
baf73b0669ce
23038981 psutil needs to not linearly enumerate cpuids
Andrew Balfour <Andrew.Balfour@Oracle.COM>
parents:
diff
changeset
|
55 |
+ } |
baf73b0669ce
23038981 psutil needs to not linearly enumerate cpuids
Andrew Balfour <Andrew.Balfour@Oracle.COM>
parents:
diff
changeset
|
56 |
} |
baf73b0669ce
23038981 psutil needs to not linearly enumerate cpuids
Andrew Balfour <Andrew.Balfour@Oracle.COM>
parents:
diff
changeset
|
57 |
|
baf73b0669ce
23038981 psutil needs to not linearly enumerate cpuids
Andrew Balfour <Andrew.Balfour@Oracle.COM>
parents:
diff
changeset
|
58 |
kstat_close(kc); |