To iterate over each thread that's alive and well on the system, we could use the do_each_thread() { ... } while_each_thread() pair of macros; we write a sample kernel module to do just this (here: ch6/foreach/thrd_showall/).
Before diving into the code, let's build it, insmod it (on our x86_64 Ubuntu 18.04 LTS guest), and see the bottom part of the output it emits via dmesg(1). As displaying the complete output isn't really possible here – it's far too large – I've shown only the lower part of the output in the following screenshot. Also, we've reproduced the header (Figure 6.9) so that you can make sense of what each column represents:
Figure 6.10 – Output from our thrd_showall.ko kernel module
In Figure 6.9, notice how all the (kernel-mode) stack start addresses (the fifth column) end in zeroes:
0xffff .... .... .000, implying...
0xffff .... .... .000, implying...