Skip to contentSkip to conversation

exit,stats: /* obey this comment */

PATCH In review Rik van Riel 2 participants 3 messages Apr 23, 2015 – Apr 24, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 exit,stats: /* obey this comment */

There is a helpful comment in do_exit() that states we sync the mm's RSS info before statistics gathering.

The function that does the statistics gathering is called right above that comment.

Change the code to obey the comment.

---
 kernel/exit.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/exit.c +1 -1
index 22fcc05dec40..8a87bb43dbd0 100644
@@ -711,10 +711,10 @@ void do_exit(long code)
 			current->comm, task_pid_nr(current),
 			preempt_count());
 
-	acct_update_integrals(tsk);
 	/* sync mm's RSS info before statistics gathering */
 	if (tsk->mm)
 		sync_mm_rss(tsk->mm);
+	acct_update_integrals(tsk);
 	group_dead = atomic_dec_and_test(&tsk->signal->live);
 	if (group_dead) {
 		hrtimer_cancel(&tsk->signal->real_timer);
#1 lore raw
Quoted 14 lines · On Thu, 23 Apr 2015 17:17:59 -0400 Rik van Riel <[email protected]> wrote:

There is a helpful comment in do_exit() that states we sync the mm's RSS info before statistics gathering.

The function that does the statistics gathering is called right above that comment.

Change the code to obey the comment.

...

kernel/exit.c +0 -0
@@ -711,10 +711,10 @@ void do_exit(long code)
 			current->comm, task_pid_nr(current),

kernel/exit.c void do_exit(long code) · line 720

Quoted 10 lines
kernel/exit.c +1 -1
 			preempt_count());
 
-	acct_update_integrals(tsk);
 	/* sync mm's RSS info before statistics gathering */
 	if (tsk->mm)
 		sync_mm_rss(tsk->mm);
+	acct_update_integrals(tsk);
 	group_dead = atomic_dec_and_test(&tsk->signal->live);
 	if (group_dead) {
 		hrtimer_cancel(&tsk->signal->real_timer);

I can't actually find anywhere where these counters are used in the accounting code.

In fact the rss_stat counters don't get used for much at all, really - non-essential stuff in the oom killer and a bit of procfs eyecandy. What have I missed.

The patch makes sense from a defensive POV, but perhaps that comment is misleading.

#2 lore raw
Quoted 18 lines · Andrew Morton
Quoted 16 lines · On Thu, 23 Apr 2015 17:17:59 -0400 Rik van Riel <[email protected]> wrote:

There is a helpful comment in do_exit() that states we sync the mm's RSS info before statistics gathering.

The function that does the statistics gathering is called right above that comment.

Change the code to obey the comment.

...

kernel/exit.c +0 -0
@@ -711,10 +711,10 @@ void do_exit(long code)
 			current->comm, task_pid_nr(current),
 			preempt_count());
 
Quoted 11 lines

kernel/exit.c void do_exit(long code) · line 720

Quoted 8 lines
kernel/exit.c +1 -1
-	acct_update_integrals(tsk);
 	/* sync mm's RSS info before statistics gathering */
 	if (tsk->mm)
 		sync_mm_rss(tsk->mm);
+	acct_update_integrals(tsk);
 	group_dead = atomic_dec_and_test(&tsk->signal->live);
 	if (group_dead) {
 		hrtimer_cancel(&tsk->signal->real_timer);

I can't actually find anywhere where these counters are used in the accounting code.

Don't the get reported to userspace in things like this?

$ /usr/bin/time ls /dev
...
0.00user 0.00system 0:00.00elapsed 33%CPU (0avgtext+0avgdata
2652maxresident)k
0inputs+0outputs (0major+135minor)pagefaults 0swaps

Though admittedly this thing only reports maxresident...

I think there is some tool that reports the avg resident rss, but I cannot remember what it is.

Signature · 1 line
All rights reversed