Skip to content

Commit e61a250

Browse files
author
Al Viro
committed
lift getrusage() from wait_noreap_copyout()
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
1 parent 67d7ddd commit e61a250

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

kernel/exit.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1062,9 +1062,6 @@ static int wait_noreap_copyout(struct wait_opts *wo, struct task_struct *p,
10621062
{
10631063
struct waitid_info *infop;
10641064

1065-
if (wo->wo_rusage)
1066-
getrusage(p, RUSAGE_BOTH, wo->wo_rusage);
1067-
10681065
put_task_struct(p);
10691066
infop = wo->wo_info;
10701067
if (infop) {
@@ -1099,6 +1096,8 @@ static int wait_task_zombie(struct wait_opts *wo, struct task_struct *p)
10991096
get_task_struct(p);
11001097
read_unlock(&tasklist_lock);
11011098
sched_annotate_sleep();
1099+
if (wo->wo_rusage)
1100+
getrusage(p, RUSAGE_BOTH, wo->wo_rusage);
11021101

11031102
if ((exit_code & 0x7f) == 0) {
11041103
why = CLD_EXITED;
@@ -1296,12 +1295,12 @@ static int wait_task_stopped(struct wait_opts *wo,
12961295
why = ptrace ? CLD_TRAPPED : CLD_STOPPED;
12971296
read_unlock(&tasklist_lock);
12981297
sched_annotate_sleep();
1298+
if (wo->wo_rusage)
1299+
getrusage(p, RUSAGE_BOTH, wo->wo_rusage);
12991300

13001301
if (unlikely(wo->wo_flags & WNOWAIT))
13011302
return wait_noreap_copyout(wo, p, pid, uid, why, exit_code);
13021303

1303-
if (wo->wo_rusage)
1304-
getrusage(p, RUSAGE_BOTH, wo->wo_rusage);
13051304
wo->wo_stat = (exit_code << 8) | 0x7f;
13061305

13071306
infop = wo->wo_info;
@@ -1350,10 +1349,10 @@ static int wait_task_continued(struct wait_opts *wo, struct task_struct *p)
13501349
get_task_struct(p);
13511350
read_unlock(&tasklist_lock);
13521351
sched_annotate_sleep();
1352+
if (wo->wo_rusage)
1353+
getrusage(p, RUSAGE_BOTH, wo->wo_rusage);
13531354

13541355
if (!wo->wo_info) {
1355-
if (wo->wo_rusage)
1356-
getrusage(p, RUSAGE_BOTH, wo->wo_rusage);
13571356
put_task_struct(p);
13581357
wo->wo_stat = 0xffff;
13591358
retval = pid;

0 commit comments

Comments
 (0)