can we measure the traffic between user and kernel mode
Dear all: Is there any directory under proc/sys or tools that can help us to measure the traffic between user and kernel mode? (such as ioctl, open, close, etc.) -- Regards, miloody
Is there any directory under proc/sys or tools that can help us to measure the traffic between user and kernel mode? (such as ioctl, open, close, etc.)
Not that I know of, but you can use strace in order to monitor system calls performed by a particular application. Alex.
On Thu, Jan 27, 2011 at 10:42, loody <miloody@gmail.com> wrote:
Dear all: Is there any directory under proc/sys or tools that can help us to measure the traffic between user and kernel mode? (such as ioctl, open, close, etc.)
By "traffic", you mean context switch latency? Perhaps you mean a tool like lmbench? -- regards, Mulyadi Santosa Freelance Linux trainer and consultant blog: the-hydra.blogspot.com training: mulyaditraining.blogspot.com
hi all: thanks for your kind reply :-) 2011/1/27 Mulyadi Santosa <mulyadi.santosa@gmail.com>:
On Thu, Jan 27, 2011 at 10:42, loody <miloody@gmail.com> wrote:
Dear all: Is there any directory under proc/sys or tools that can help us to measure the traffic between user and kernel mode? (such as ioctl, open, close, etc.)
By "traffic", you mean context switch latency? Perhaps you mean a tool like lmbench? I got a user-mode application without symbol and source, and it keeps console no response about 2 mins. I just want to know whether it is busy on processing itself or do the context switch frequently for calling kernel drivers at that time. thanks a lot, miloody
-- regards,
Mulyadi Santosa Freelance Linux trainer and consultant
blog: the-hydra.blogspot.com training: mulyaditraining.blogspot.com
-- Regards,
On Thu, Jan 27, 2011 at 12:56, loody <miloody@gmail.com> wrote:
I got a user-mode application without symbol and source, and it keeps console no response about 2 mins. I just want to know whether it is busy on processing itself or do the context switch frequently for calling kernel drivers at that time.
well then, strace/ltrace is probably the right tool to do the job :) or just use /proc/<pid>/stack :) -- regards, Mulyadi Santosa Freelance Linux trainer and consultant blog: the-hydra.blogspot.com training: mulyaditraining.blogspot.com
Hi, You can use *top* command to know traffic of processes in your cpu. another if you want to debug that running application then you can also try gdb # gdb --pid <pid_of_application> Thanks & Regards, -------PraviN------- On Thu, Jan 27, 2011 at 11:50 AM, Mulyadi Santosa <mulyadi.santosa@gmail.com
wrote:
On Thu, Jan 27, 2011 at 12:56, loody <miloody@gmail.com> wrote:
I got a user-mode application without symbol and source, and it keeps console no response about 2 mins. I just want to know whether it is busy on processing itself or do the context switch frequently for calling kernel drivers at that time.
well then, strace/ltrace is probably the right tool to do the job :) or just use /proc/<pid>/stack :)
-- regards,
Mulyadi Santosa Freelance Linux trainer and consultant
blog: the-hydra.blogspot.com training: mulyaditraining.blogspot.com
_______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
-- Thanks & Regards, ---------PraviN---------
hi all: 2011/1/27 Mulyadi Santosa <mulyadi.santosa@gmail.com>:
On Thu, Jan 27, 2011 at 12:56, loody <miloody@gmail.com> wrote:
I got a user-mode application without symbol and source, and it keeps console no response about 2 mins. I just want to know whether it is busy on processing itself or do the context switch frequently for calling kernel drivers at that time.
well then, strace/ltrace is probably the right tool to do the job :) or just use /proc/<pid>/stack :) I have tried the suggestions you gave. :)
Can I combine all the message together? Supposedly, my console shows: A begins A finish B begins B finish and I measure 2mins from '#A finish' to "#B begins". I can "strace -o -tt 123 a.out" before "A begin" but how could I combine console output with the content of strace? such as A begins strace content ...... A finish strace content ...... B begins strace content ...... B finish appreciate your kind help :-) miloody
Hi :) On Thu, Jan 27, 2011 at 20:48, loody <miloody@gmail.com> wrote:
I can "strace -o -tt 123 a.out" before "A begin" but how could I combine console output with the content of strace? such as A begins strace content ...... A finish strace content ...... B begins strace content ...... B finish
Not sure if I understand you correctly...what are A and B here? function calls? -- regards, Mulyadi Santosa Freelance Linux trainer and consultant blog: the-hydra.blogspot.com training: mulyaditraining.blogspot.com
hi: 2011/1/28 Mulyadi Santosa <mulyadi.santosa@gmail.com>:
Hi :)
On Thu, Jan 27, 2011 at 20:48, loody <miloody@gmail.com> wrote:
I can "strace -o -tt 123 a.out" before "A begin" but how could I combine console output with the content of strace? such as A begins strace content ...... A finish strace content ...... B begins strace content ...... B finish
Not sure if I understand you correctly...what are A and B here? function calls? Yes, the A and B here I mean is the function call I wrote in C, such as the "open("/home/miloody", O_RDONLY) " etc. Thank you ~ miloody
I can "strace -o -tt 123 a.out" before "A begin" but how could I combine console output with the content of strace?
strace does output to stderr unless you specify the -o option. So by using something like $ strace -tt your_program or $ strace -tt your_program &> log.txt you will have both outputs intermingled. Note that the console output of your program will appear in the middle of the corresponding write() system call. Alex.
hi: 2011/1/28 Alexandre Courbot <gnurou@gmail.com>:
I can "strace -o -tt 123 a.out" before "A begin" but how could I combine console output with the content of strace?
strace does output to stderr unless you specify the -o option. So by using something like
$ strace -tt your_program
or
$ strace -tt your_program &> log.txt
you will have both outputs intermingled. Note that the console output of your program will appear in the middle of the corresponding write() system call. I have tried both ways you mentioned. in case 1: it did interleave the output of standard output with standard error. in case 2: the standard output seems will be collect for flush at later, combine.strace.txt. (I attach the testing result for your reference.) theoretically, file re-direction should not be effect the content of output, right? appreciate your help :-) miloody.
I have tried both ways you mentioned. in case 1: it did interleave the output of standard output with standard error. in case 2: the standard output seems will be collect for flush at later, combine.strace.txt. (I attach the testing result for your reference.) theoretically, file re-direction should not be effect the content of output, right?
That's what I thought too, but it turns out the libc is smarter than we expected. File redirection *does* affect the order of output, as testified by your logs. See the non-redirected behavior: 15:55:35.205409 write(1, "\n", 1) = 1 15:55:35.205517 write(1, "open fail\n", 10) = 10 15:55:35.205628 open("/home/miloody", O_RDONLY) = -1 ENOENT (No such file or directory) 15:55:35.205745 write(1, "\n", 1) = 1 15:55:35.205847 write(1, "open fail\n", 10) = 10 15:55:35.205957 open("/home/miloody", O_RDONLY) = -1 ENOENT (No such file or directory) 15:55:35.206073 write(1, "\n", 1) = 1 15:55:35.206174 write(1, "open fail\n", 10) = 10 15:55:35.206284 open("/home/miloody", O_RDONLY) = -1 ENOENT (No such file or directory) ... and compare it to what happens when we use redirection: ... 15:56:21.105236 open("/home/miloody", O_RDONLY) = -1 ENOENT (No such file or directory) 15:56:21.105294 open("/home/miloody", O_RDONLY) = -1 ENOENT (No such file or directory) 15:56:21.105353 open("/home/miloody", O_RDONLY) = -1 ENOENT (No such file or directory) 15:56:21.105417 write(1, "\nopen fail\n\nopen fail\n\nopen fail"..., 110 Here the libc has grouped all your printfs into one single system call because of user-space buffering. Fortunately you can prevent this behavior using unbuffer: http://linuxcommand.org/man_pages/unbuffer1.html So your strace invokation would be like: $ strace -tt stdbuf -o0 -e0 ./foo &>output Which produces the expected output on my system. Alex.
Here the libc has grouped all your printfs into one single system call because of user-space buffering. Fortunately you can prevent this behavior using unbuffer:
Sorry, that should have read stdbuf, and the correct man page is here: http://www.pixelbeat.org/programming/stdio_buffering/stdbuf-man.html Alex.
Hi! On 11:42 Thu 27 Jan , loody wrote:
Dear all: Is there any directory under proc/sys or tools that can help us to measure the traffic between user and kernel mode? (such as ioctl, open, close, etc.)
If you are interested in number of system calls per second, you can run dstat. However I do not know a way to measure the traffic in bytes/sec. -Michi -- programing a layer 3+4 network protocol for mesh networks see http://michaelblizek.twilightparadox.com
participants (5)
-
Alexandre Courbot -
loody -
Michael Blizek -
Mulyadi Santosa -
Pravin Shedage