All of lore.kernel.org
 help / color / mirror / Atom feed
* seq_file calls stop() after show()
@ 2016-10-05  9:25 Gaurav Kalra
  0 siblings, 0 replies; only message in thread
From: Gaurav Kalra @ 2016-10-05  9:25 UTC (permalink / raw)
  To: kernelnewbies

Hi,

I am trying to duplicate the purpose of /proc/pid/io for a homework to
understand how procfs / seq_file works. Although there is no mandate to use
seq_file but it seems very interesting to me.

The aim is to print an output similar to /proc/pid/io but for all processes
at once using a custom proc file name "/proc/proc_io".

The project is organized as follows:
main.c -> It is responsible for kernel module init / deinit
sequence.c -> This is where I have put in the processing logic
utils.h -> bunch of macros for debugging

The debugging logs come as follows:
=========
[  +4.814129] <pl_open:15>
[  +0.000017] <pl_seq_start:53>
[  +0.000003] <pl_seq_start:55> init_task: [ffffffff81e11500] pos: [0]
[  +0.000001] <pl_seq_show:103>
[  +0.000004] <pl_seq_next:72>
[  +0.000001] <pl_seq_next:79> n_tsk: [ffff880225a28000]
[  +0.000002] <pl_seq_show:103>
[  +0.000003] <pl_seq_next:72>
[  +0.000002] <pl_seq_next:79> n_tsk: [ffff880225a28dc0]
[  +0.000001] <pl_seq_show:103>
[  +0.000003] <pl_seq_next:72>
[  +0.000001] <pl_seq_next:79> n_tsk: [ffff880225a29b80]
[  +0.000002] <pl_seq_show:103>
[  +0.000002] <pl_seq_next:72>
[  +0.000002] <pl_seq_next:79> n_tsk: [ffff880225a2b700]
[  +0.000001] <pl_seq_show:103>
[  +0.000003] <pl_seq_next:72>
[  +0.000001] <pl_seq_next:79> n_tsk: [ffff880225a2d280]
[  +0.000002] <pl_seq_show:103>
[  +0.000002] <pl_seq_next:72>
[  +0.000001] <pl_seq_next:79> n_tsk: [ffff880225a2e040]
[  +0.000002] <pl_seq_show:103>
[  +0.000002] <pl_seq_next:72>
[  +0.000002] <pl_seq_next:79> n_tsk: [ffff880225a2ee00]
[  +0.000001] <pl_seq_show:103>
[  +0.000003] <pl_seq_next:72>
[  +0.000001] <pl_seq_next:79> n_tsk: [ffff880225a78000]
[  +0.000002] <pl_seq_show:103>
[  +0.000002] <pl_seq_next:72>
[  +0.000002] <pl_seq_next:79> n_tsk: [ffff880225a7ee00]
[  +0.000001] <pl_seq_show:103>
[  +0.000003] <pl_seq_next:72>
[  +0.000001] <pl_seq_next:79> n_tsk: [ffff880225aa8000]
[  +0.000001] <pl_seq_show:103>
[  +0.000003] <pl_seq_next:72>
[  +0.000002] <pl_seq_next:79> n_tsk: [ffff880225aa8dc0]
[  +0.000001] <pl_seq_show:103>
[  +0.000002] <pl_seq_next:72>
[  +0.000002] <pl_seq_next:79> n_tsk: [ffff880225aaa940]
[  +0.000001] <pl_seq_show:103>
[  +0.000003] <pl_seq_next:72>
[  +0.000001] <pl_seq_next:79> n_tsk: [ffff880225aab700]
[  +0.000002] <pl_seq_show:103>
[  +0.000002] <pl_seq_next:72>
[  +0.000002] <pl_seq_next:79> n_tsk: [ffff880225aac4c0]
[  +0.000001] <pl_seq_show:103>
[  +0.000003] <pl_seq_next:72>
[  +0.000001] <pl_seq_next:79> n_tsk: [ffff880225aad280]
[  +0.000001] <pl_seq_show:103>
[  +0.000003] <pl_seq_next:72>
[  +0.000001] <pl_seq_next:79> n_tsk: [ffff880225aaee00]
[  +0.000002] <pl_seq_show:103>
[  +0.000002] <pl_seq_next:72>
[  +0.000002] <pl_seq_next:79> n_tsk: [ffff880225048000]
[  +0.000001] <pl_seq_show:103>
[  +0.000003] <pl_seq_next:72>
[  +0.000001] <pl_seq_next:79> n_tsk: [ffff880225048dc0]
[  +0.000002] <pl_seq_show:103>
[  +0.000002] <pl_seq_next:72>
[  +0.000002] <pl_seq_next:79> n_tsk: [ffff880225049b80]
[  +0.000001] <pl_seq_show:103>
[  +0.000003] <pl_seq_next:72>
[  +0.000001] <pl_seq_next:79> n_tsk: [ffff88022504b700]
[  +0.000001] <pl_seq_show:103>
[  +0.000003] <pl_seq_next:72>
[  +0.000002] <pl_seq_next:79> n_tsk: [ffff88022504c4c0]
[  +0.000001] <pl_seq_show:103>
[  +0.000002] <pl_seq_next:72>
[  +0.000002] <pl_seq_next:79> n_tsk: [ffff88022504d280]
[  +0.000001] <pl_seq_show:103>
[  +0.000003] <pl_seq_next:72>
[  +0.000001] <pl_seq_next:79> n_tsk: [ffff88022504e040]
[  +0.000002] <pl_seq_show:103>
[  +0.000002] <pl_seq_next:72>
[  +0.000001] <pl_seq_next:79> n_tsk: [ffff8802250f0000]
[  +0.000002] <pl_seq_show:103>
[  +0.000002] <pl_seq_next:72>
[  +0.000002] <pl_seq_next:79> n_tsk: [ffff8802250f0dc0]
[  +0.000001] <pl_seq_show:103>
[  +0.000003] <pl_seq_next:72>
[  +0.000001] <pl_seq_next:79> n_tsk: [ffff8802250f1b80]
[  +0.000002] <pl_seq_show:103>
[  +0.000002] <pl_seq_next:72>
[  +0.000002] <pl_seq_next:79> n_tsk: [ffff8802250f2940]
[  +0.000001] <pl_seq_show:103>
[  +0.000002] <pl_seq_next:72>
[  +0.000002] <pl_seq_next:79> n_tsk: [ffff8802250f44c0]
[  +0.000001] <pl_seq_show:103>
[  +0.000003] <pl_seq_next:72>
[  +0.000001] <pl_seq_next:79> n_tsk: [ffff8802250f5280]
[  +0.000002] <pl_seq_show:103>
[  +0.000002] <pl_seq_next:72>
[  +0.000002] <pl_seq_next:79> n_tsk: [ffff8802250f6040]
[  +0.000001] <pl_seq_show:103>
[  +0.000003] <pl_seq_next:72>
[  +0.000001] <pl_seq_next:79> n_tsk: [ffff8802250f6e00]
[  +0.000001] <pl_seq_show:103>
[  +0.000003] <pl_seq_next:72>
[  +0.000001] <pl_seq_next:79> n_tsk: [ffff8802251a0dc0]
[  +0.000002] <pl_seq_show:103>
[  +0.000002] <pl_seq_next:72>
[  +0.000002] <pl_seq_next:79> n_tsk: [ffff8802251a1b80]
[  +0.000001] <pl_seq_show:103>
[  +0.000003] <pl_seq_stop:92>
[  +0.000276] <pl_seq_start:53>
[  +0.000002] <pl_seq_start:55> init_task: [ffffffff81e11500] pos: [1]
[  +0.000001] <pl_seq_stop:92>
=========

Towards the end, the sequence is as follows:
[  +0.000001] <pl_seq_show:103>
[  +0.000003] <pl_seq_stop:92>

i.e. stop() is called after show().
This is making my output truncated to only first few processes.

Although I always return 0 from show(), I fail to understand why stop() is
being invoked just after show().

Can you please help me or redirect me somewhere to understand why this is
happening?

Thank You.
Gaurav
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20161005/92704631/attachment-0001.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: utils.h
Type: text/x-chdr
Size: 526 bytes
Desc: not available
Url : http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20161005/92704631/attachment-0004.bin 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: sequence.h
Type: text/x-chdr
Size: 130 bytes
Desc: not available
Url : http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20161005/92704631/attachment-0005.bin 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: main.c
Type: text/x-csrc
Size: 1334 bytes
Desc: not available
Url : http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20161005/92704631/attachment-0006.bin 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Makefile
Type: application/octet-stream
Size: 209 bytes
Desc: not available
Url : http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20161005/92704631/attachment-0001.obj 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: sequence.c
Type: text/x-csrc
Size: 3433 bytes
Desc: not available
Url : http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20161005/92704631/attachment-0007.bin 

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2016-10-05  9:25 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-05  9:25 seq_file calls stop() after show() Gaurav Kalra

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.