Skip to content

Commit 9a1015b

Browse files
Alexey Dobriyantorvalds
authored andcommitted
proc: fix /proc/loadavg regression
Commit 95846ec ("pid: replace pid bitmap implementation with IDR API") changed last field of /proc/loadavg (last pid allocated) to be off by one: # unshare -p -f --mount-proc cat /proc/loadavg 0.00 0.00 0.00 1/60 2 <=== It should be 1 after first fork into pid namespace. This is formally a regression but given how useless this field is I don't think anyone is affected. Bug was found by /proc testsuite! Link: http://lkml.kernel.org/r/20180413175408.GA27246@avx2 Fixes: 95846ec ("pid: replace pid bitmap implementation with IDR API") Signed-off-by: Alexey Dobriyan <[email protected]> Cc: "Eric W. Biederman" <[email protected]> Cc: Gargi Sharma <[email protected]> Cc: Oleg Nesterov <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 2e0ad55 commit 9a1015b

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

arch/powerpc/platforms/cell/spufs/sched.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1093,7 +1093,7 @@ static int show_spu_loadavg(struct seq_file *s, void *private)
10931093
LOAD_INT(c), LOAD_FRAC(c),
10941094
count_active_contexts(),
10951095
atomic_read(&nr_spu_contexts),
1096-
idr_get_cursor(&task_active_pid_ns(current)->idr));
1096+
idr_get_cursor(&task_active_pid_ns(current)->idr) - 1);
10971097
return 0;
10981098
}
10991099

fs/proc/loadavg.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ static int loadavg_proc_show(struct seq_file *m, void *v)
2424
LOAD_INT(avnrun[1]), LOAD_FRAC(avnrun[1]),
2525
LOAD_INT(avnrun[2]), LOAD_FRAC(avnrun[2]),
2626
nr_running(), nr_threads,
27-
idr_get_cursor(&task_active_pid_ns(current)->idr));
27+
idr_get_cursor(&task_active_pid_ns(current)->idr) - 1);
2828
return 0;
2929
}
3030

0 commit comments

Comments
 (0)