diff options
-rw-r--r-- | meta/recipes-extended/procps/procps-3.2.8/procps-3.2.7-top-remcpu.patch | 111 | ||||
-rw-r--r-- | meta/recipes-extended/procps/procps_3.2.8.bb | 1 |
2 files changed, 112 insertions, 0 deletions
diff --git a/meta/recipes-extended/procps/procps-3.2.8/procps-3.2.7-top-remcpu.patch b/meta/recipes-extended/procps/procps-3.2.8/procps-3.2.7-top-remcpu.patch new file mode 100644 index 0000000000..0306c8d639 --- /dev/null +++ b/meta/recipes-extended/procps/procps-3.2.8/procps-3.2.7-top-remcpu.patch | |||
@@ -0,0 +1,111 @@ | |||
1 | Upstream-Status: Pending | ||
2 | |||
3 | fix that top will quit after cpu offline | ||
4 | |||
5 | top utiliy fails to read /proc/stat after cpu offline, because Cpu_tot | ||
6 | is still the original cpu numbers when calling cpus_refresh, in which | ||
7 | it is trying to read and sscanf Cpu_tot times /proc/stat. | ||
8 | |||
9 | The patch is from procps-3.2.8-2.fc12.src.rpm | ||
10 | |||
11 | Signed-off-by: Wenzong Fan <wenzong.fan@windriver.com> | ||
12 | |||
13 | --- | ||
14 | --- procps-3.2.7/top.c.remcpu 2006-07-10 10:41:11.000000000 +0200 | ||
15 | +++ procps-3.2.7/top.c 2006-07-10 10:41:35.000000000 +0200 | ||
16 | @@ -912,6 +912,7 @@ | ||
17 | static CPU_t *cpus_refresh (CPU_t *cpus) | ||
18 | { | ||
19 | static FILE *fp = NULL; | ||
20 | + static int cpu_max; | ||
21 | int i; | ||
22 | int num; | ||
23 | // enough for a /proc/stat CPU line (not the intr line) | ||
24 | @@ -926,24 +927,29 @@ | ||
25 | can hold tics representing the /proc/stat cpu summary (the first | ||
26 | line read) -- that slot supports our View_CPUSUM toggle */ | ||
27 | cpus = alloc_c((1 + Cpu_tot) * sizeof(CPU_t)); | ||
28 | + cpu_max = Cpu_tot; | ||
29 | } | ||
30 | + else if (cpu_max > Cpu_tot) | ||
31 | + /* move saved CUPs summary to cpu_max possition */ | ||
32 | + memcpy(&cpus[cpu_max], &cpus[Cpu_tot], sizeof(CPU_t)); | ||
33 | + | ||
34 | rewind(fp); | ||
35 | fflush(fp); | ||
36 | |||
37 | // first value the last slot with the cpu summary line | ||
38 | if (!fgets(buf, sizeof(buf), fp)) std_err("failed /proc/stat read"); | ||
39 | - cpus[Cpu_tot].x = 0; // FIXME: can't tell by kernel version number | ||
40 | - cpus[Cpu_tot].y = 0; // FIXME: can't tell by kernel version number | ||
41 | - cpus[Cpu_tot].z = 0; // FIXME: can't tell by kernel version number | ||
42 | + cpus[cpu_max].x = 0; // FIXME: can't tell by kernel version number | ||
43 | + cpus[cpu_max].y = 0; // FIXME: can't tell by kernel version number | ||
44 | + cpus[cpu_max].z = 0; // FIXME: can't tell by kernel version number | ||
45 | num = sscanf(buf, "cpu %Lu %Lu %Lu %Lu %Lu %Lu %Lu %Lu", | ||
46 | - &cpus[Cpu_tot].u, | ||
47 | - &cpus[Cpu_tot].n, | ||
48 | - &cpus[Cpu_tot].s, | ||
49 | - &cpus[Cpu_tot].i, | ||
50 | - &cpus[Cpu_tot].w, | ||
51 | - &cpus[Cpu_tot].x, | ||
52 | - &cpus[Cpu_tot].y, | ||
53 | - &cpus[Cpu_tot].z | ||
54 | + &cpus[cpu_max].u, | ||
55 | + &cpus[cpu_max].n, | ||
56 | + &cpus[cpu_max].s, | ||
57 | + &cpus[cpu_max].i, | ||
58 | + &cpus[cpu_max].w, | ||
59 | + &cpus[cpu_max].x, | ||
60 | + &cpus[cpu_max].y, | ||
61 | + &cpus[cpu_max].z | ||
62 | ); | ||
63 | if (num < 4) | ||
64 | std_err("failed /proc/stat read"); | ||
65 | @@ -955,7 +961,7 @@ | ||
66 | } | ||
67 | |||
68 | // now value each separate cpu's tics | ||
69 | - for (i = 0; 1 < Cpu_tot && i < Cpu_tot; i++) { | ||
70 | + for (i = 0; ; i++) { | ||
71 | if (!fgets(buf, sizeof(buf), fp)) std_err("failed /proc/stat read"); | ||
72 | cpus[i].x = 0; // FIXME: can't tell by kernel version number | ||
73 | cpus[i].y = 0; // FIXME: can't tell by kernel version number | ||
74 | @@ -964,9 +970,35 @@ | ||
75 | &cpus[i].id, | ||
76 | &cpus[i].u, &cpus[i].n, &cpus[i].s, &cpus[i].i, &cpus[i].w, &cpus[i].x, &cpus[i].y, &cpus[i].z | ||
77 | ); | ||
78 | - if (num < 4) | ||
79 | - std_err("failed /proc/stat read"); | ||
80 | + if (num < 4) { | ||
81 | + Cpu_tot = i; | ||
82 | + break; | ||
83 | + } | ||
84 | + if (i == cpu_max - 1) { | ||
85 | + // Bump cpu_max and extend cpus | ||
86 | + cpu_max++; | ||
87 | + cpus = realloc(cpus, (1 + cpu_max) * sizeof(CPU_t)); | ||
88 | + if (!cpus) std_err("realloc failed"); | ||
89 | + memcpy(&cpus[cpu_max], &cpus[cpu_max-1], sizeof(CPU_t)); | ||
90 | + } | ||
91 | + } | ||
92 | + | ||
93 | + if (cpu_max > Cpu_tot) | ||
94 | + memcpy(&cpus[Cpu_tot], &cpus[cpu_max], sizeof(CPU_t)); | ||
95 | + | ||
96 | + // and just in case we're 2.2.xx compiled without SMP support... | ||
97 | + if (Cpu_tot == 1) { | ||
98 | + cpus[0].id = cpus[1].id = 0; | ||
99 | + cpus[0].u = cpus[1].u; | ||
100 | + cpus[0].n = cpus[1].n; | ||
101 | + cpus[0].s = cpus[1].s; | ||
102 | + cpus[0].i = cpus[1].i; | ||
103 | + cpus[0].w = cpus[1].w; | ||
104 | + cpus[0].x = cpus[1].x; | ||
105 | + cpus[0].y = cpus[1].y; | ||
106 | + cpus[0].z = cpus[1].z; | ||
107 | } | ||
108 | + | ||
109 | return cpus; | ||
110 | } | ||
111 | |||
diff --git a/meta/recipes-extended/procps/procps_3.2.8.bb b/meta/recipes-extended/procps/procps_3.2.8.bb index 7533859518..8436d4ace4 100644 --- a/meta/recipes-extended/procps/procps_3.2.8.bb +++ b/meta/recipes-extended/procps/procps_3.2.8.bb | |||
@@ -9,6 +9,7 @@ SRC_URI += "file://procmodule.patch \ | |||
9 | file://procps-3.2.8+gmake-3.82.patch \ | 9 | file://procps-3.2.8+gmake-3.82.patch \ |
10 | file://gnu-kbsd-version.patch \ | 10 | file://gnu-kbsd-version.patch \ |
11 | file://60_linux_version_init.patch \ | 11 | file://60_linux_version_init.patch \ |
12 | file://procps-3.2.7-top-remcpu.patch \ | ||
12 | " | 13 | " |
13 | 14 | ||
14 | SRC_URI[md5sum] = "9532714b6846013ca9898984ba4cd7e0" | 15 | SRC_URI[md5sum] = "9532714b6846013ca9898984ba4cd7e0" |