3

This code is from the file /fs/proc/array.c in the Linux headers. What does the int whole parameter mean? I want to know why sometimes you need to accumulate min_flt and maj_flts from the sig_struct and other times it's ok to just read their values straight out of the task_struct

346 static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
347       struct pid *pid, struct task_struct *task, int whole)
...
406     /* add up live thread stats at the group level */
407     if (whole) {
408       struct task_struct *t = task;
409       do {
410         min_flt += t->min_flt;
411         maj_flt += t->maj_flt;
412         gtime = cputime_add(gtime, t->gtime);
413         t = next_thread(t);
414       } while (t != task);
415 
416       min_flt += sig->min_flt;
417       maj_flt += sig->maj_flt;
418       thread_group_times(task, &utime, &stime);
419       gtime = cputime_add(gtime, sig->gtime);
420     }
...
431   if (!whole) {
432     min_flt = task->min_flt;
433     maj_flt = task->maj_flt;
434     task_times(task, &utime, &stime);
435     gtime = task->gtime;
436   }
Mantosh Kumar
  • 5,659
  • 3
  • 24
  • 48
Jefferson Hudson
  • 728
  • 1
  • 10
  • 22

1 Answers1

0

"whole" is just an argument name and in this context it seems to indicate "do_task_stat for the whole thread group".

do_task_stat is a static function only used within /fs/proc/array.c It is used in two places: proc_tid_stat (TID is "thread ID") and proc_tgid_stat (TGID is "thread group ID").

See Linux - Threads and Process for good explaination of thread groups.

Community
  • 1
  • 1
austinmarton
  • 2,278
  • 3
  • 20
  • 23