When handling data, much of the time, the key is to keep only data that's relevant to your particular set of tasks, and nothing more. Much of the data that's exposed under /proc
is done so for a singular purpose, i.e. a tool that needs to have visibility to it etc.
Given the comments I would assume 3 things about /proc/[number]/stat
:
- The data being displayed here is what's relevant to functions and data objects within
/usr/src/linux/fs/proc/array.c
.
- That data is also what's relevant to
ps
.
- Looking through the data that's here you'll notice that there is nothing here that's user specific. It's all geared towards processes.
NOTE: for #2. this is the process data that's relevant to ps
. The processes owned by a user are kept in a different data structure within the Kernel elsewhere.
On the otherhand, with /proc/[number]/status
, the comment pretty much tells you what this data is geared towards, a human reading it. So it's likely that this node within the Kernel serves no other purpose, from a tools perspective, then to collate data from other sources into a single place for the user to consume it.
Additional evidence
If you need more proof of this, look to this question I answered a while ago, titled: /proc/meminfo MemTotal =?. This question covered /proc/meminfo
and it was a similar issue here too. Some of the data is exposed during the Kernel boot-up under dmesg
log output. However that data, though memory related and perceived as relevant to /proc/meminfo
was absent, again because it wasn't useful to:
- the target audience of tools that would be using
/proc/meminfo
- Not relevant to the Kernel internal functions, methods, and data structures that made use of the data in
/proc/meminfo
.
References
/proc/net/dev
contains statistics about network interfaces, while /proc/<pid>/net/dev
contains statistics about network interfaces from the process' point of view.
I suppose that if a process runs on a network namespace (see man ip-netns
) where it has access only to a limited set of interfaces, only these will show up in /proc/<pid>/net/dev
.
Best Answer
From the man page:
From the kernel source (
.../kernel/sched/cputime.c
) we see that when guest time is being accounted for, all guest time is also added to user time (and similarly for nice).The user time and guest time that will be displayed via
/proc/[pid]/stat
are retrieved in.../fs/proc/array.c
indo_task_stat()
with calls totask_cputime_adjusted()
andtask_gtime()
which return theutime
andgtime
fields ofstruct task_struct
, respectively, although gtime may be tweaked:[code quoted in this post is from commit
29b4817 2016-08-07 Linus Torvalds Linux 4.8-rc1
]