Trying to export per process network bandwidth stats under /proc/[pid]/

2018-07-13 Thread Amos Bird

Hello!

I'm trying to add a proc entry under /proc/[pid] in order to get 
per process network bandwidth stats. I suppose it's similar to 
/proc/[pid]/io . However I couldn't find a modular way to add 
entries under /proc/[pid]. This thread 
https://lists.kernelnewbies.org/pipermail/kernelnewbies/2011-January/000475.html 
suggests modifying the kernel which isn't practical to me. Here is 
what I've found by going through a bit of the related kernel code.


1. I need to find a way to override or hooking 
`sock_sendmsg`/`sock_recvmsg` functions with accounting variables 
like `task_io_accounting`
2. a way to add proc entries under /proc/[pid] with readops 
printing `current` netio accounting variables.


Am I on the right path of implementing this? Thanks!

--
Amos Bird
amosb...@gmail.com

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: Question about memcpy

2018-07-13 Thread valdis . kletnieks
On Fri, 13 Jul 2018 11:02:13 +0800, bing zhu said:

> I‘m trying to write a simple fs in user space,if memcpy is slower than
> kernel , i think it's unfair,as for only cpu for my task,
> it's a bit of arbitrary ,i just want my task not interrupted during a
> specific time is that possible ?

Not getting interrupted is an *entirely* different issue than making memcpy 
fast.

Note that in general, systems code should be able to deal with interruptions
during most parts of the code, and locking used and disabling pre-emption for
sections of code that can't deal with being interrupted.  Remember that if your
filesystem code turns off interrupts for long enough, you can start losing
things like I/O completions.  Fortunately for those who write systems code,
the vast majority of interrupts are totally transparent to the vast majority
of the kernel code.

And if you're doing a file system in userspace, you're going to fail to notice
hundreds or even thousands of interrupts happening. If you don't believe me,
'cat /proc/interrupts', and realize that userspace didn't notice *any* of them
happening.



pgpKxTF7O0vLQ.pgp
Description: PGP signature
___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies