Skip to contentSkip to conversation

proc: fix /proc/loadavg regression

PATCH New Alexey Dobriyan 1 participant 1 message Apr 13, 2018

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 proc: fix /proc/loadavg regression

commit 95846ecf9dac5089aed4b144d912225f8ef86ae4 "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!

---

 arch/powerpc/platforms/cell/spufs/sched.c |    2 +-
 fs/proc/loadavg.c                         |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
arch/powerpc/platforms/cell/spufs/sched.c +1 -1
@@ -1093,7 +1093,7 @@ static int show_spu_loadavg(struct seq_file *s, void *private)
 		LOAD_INT(c), LOAD_FRAC(c),
 		count_active_contexts(),
 		atomic_read(&nr_spu_contexts),
-		idr_get_cursor(&task_active_pid_ns(current)->idr));
+		idr_get_cursor(&task_active_pid_ns(current)->idr) - 1);
 	return 0;
 }
 
fs/proc/loadavg.c +1 -1
@@ -24,7 +24,7 @@ static int loadavg_proc_show(struct seq_file *m, void *v)
 		LOAD_INT(avnrun[1]), LOAD_FRAC(avnrun[1]),
 		LOAD_INT(avnrun[2]), LOAD_FRAC(avnrun[2]),
 		nr_running(), nr_threads,
-		idr_get_cursor(&task_active_pid_ns(current)->idr));
+		idr_get_cursor(&task_active_pid_ns(current)->idr) - 1);
 	return 0;
 }