On Mon, Sep 11, 2023 at 12:10:17PM +0200, Claudio Jeker wrote: > On Mon, Sep 11, 2023 at 11:02:00AM +0200, Marc Espie wrote: > > I was reading through ps.1, which has two slightly different options > > -H Also display information about kernel visible threads. > > -k Also display information about kernel threads. > > > > It's not at all obvious what the difference between these options might be. > > > > kernel threads == kthread(9) created threads > > Those should have K in STAT and the name is in () like: > 3141 ?? RK/1 4057:57.90 (idle1) > > kernel visible threads == __tfork_thread(3) created threads for userland > applications. For example: > > 43838 556612 ?? IpU 0:01.58 firefox (firefox/Cache2 I/O) > 43838 415551 ?? IpU 0:00.01 firefox (firefox/Cookie) > 43838 377915 ?? IpU 0:00.01 firefox (firefox/Worker Launcher) > > These threads all share the same PID but have different TID. > > I think the "kernel visible" is there to tell that pure userland threads > can not be reported by ps. I think go routines are such an example. > > > From the log: > > -------------------- > > revision 1.77 > > date: 2011/09/25 00:29:59; author: guenther; state: Exp; lines: +5 -3; > > Add -H option to show rthreads, hiding them by default > > > > Diff from uwe@ > > -------------------- > > so slightly more info. > > > > Looking at the code, now this is KERN_PROC_KTHREAD vs KERN_PROC_SHOW_THREADS > > in kvm_getprocs(3). > > > > Now KERN_PROC_KTHREAD is documented, but there is nothing about > > KERN_PROC_SHOW_THREADS. > > > > The code around (dothreads) in kvm* doesn't make things really obvious.
So far I have two explanations, but it's far away from my comfort zone that I don't know how to make the documentation less crappy. Any of you guys willing to provide a patch to ps(1) and kvm_getprocs(3) ?