This patch adds L7 traffic accounting in taskstats API, so
the iotop like applications can receive these statistics data.
In fact, I also have an iotop patch for this change.
It ignores any protocol header overhead, so results of this
patch should be saw as the application-aware data statistics
instead of traffic statistics on wire. And it also ignores any
IPC traffic on local host.
This patch only records TCP/UDP/Raw-IP traffic so far, and adding
other protocol support is easy.
Signed-off-by: Li Yu <redacted>
include/linux/sched.h | 2 ++
include/linux/taskstats.h | 7 ++++++-
include/net/sock.h | 10 ++++++++++
kernel/fork.c | 1 +
kernel/taskstats.c | 6 ++++++
net/ipv4/raw.c | 3 +++
net/ipv4/tcp.c | 8 +++++++-
net/ipv4/udp.c | 10 ++++++++--
From: David Miller <davem@davemloft.net> Date: 2012-02-23 08:34:39
From: Li Yu <redacted>
Date: Thu, 23 Feb 2012 16:22:23 +0800
This patch only records TCP/UDP/Raw-IP traffic so far, and adding
other protocol support is easy.
It shouldn't even be necessary to put any code into specific
protocols, it should instead be done at some generic location
so that all protocols are supported transparently.
This patch adds L7 traffic accounting in taskstats API, so
the iotop like applications can receive these statistics data.
In fact, I also have an iotop patch for this change.
It ignores any protocol header overhead, so results of this
patch should be saw as the applications-aware data statistics
instead of traffic statistics on wire.
The changes of v2 are:
1. Move up accounting source code, so they are not protocol-aware now.
2. Skipping interrupt context accounting.
That is all, thanks
Signed-off-by: Li Yu <redacted>
include/linux/sched.h | 2 ++
include/linux/taskstats.h | 7 ++++++-
include/net/sock.h | 12 ++++++++++++
kernel/fork.c | 1 +
kernel/taskstats.c | 6 ++++++
net/socket.c | 27 ++++++++++++++++++++++-----
6 files changed, 49 insertions(+), 6 deletions(-)
From: Ben Hutchings <hidden> Date: 2012-02-24 03:05:14
On Fri, 2012-02-24 at 10:43 +0800, Li Yu wrote:
This patch adds L7 traffic accounting in taskstats API, so
the iotop like applications can receive these statistics data.
In fact, I also have an iotop patch for this change.
It ignores any protocol header overhead, so results of this
patch should be saw as the applications-aware data statistics
instead of traffic statistics on wire.
The changes of v2 are:
1. Move up accounting source code, so they are not protocol-aware now.
2. Skipping interrupt context accounting.
[...]
quoted hunk
--- a/include/net/sock.h+++ b/include/net/sock.h
@@ -1735,6 +1735,18 @@ static inline int skb_copy_to_page(struct sock
*sk, char __user *from,
return 0;
}
+static inline void task_net_accounting_rx(unsigned int len)
+{
+ if (!in_irq() && len > 0)
+ current->rx_bytes += len;
+}
+
+static inline void task_net_accounting_tx(unsigned int len)
+{
+ if (!in_irq() && len > 0)
+ current->tx_bytes += len;
+}
[...]
These are only called from system calls, so why are you checking for IRQ
context?
quoted hunk
@@ -558,7 +559,10 @@ static inline int __sock_sendmsg_nosec(struct kiocb
[...]
So what happens to the totals when sendmsg() returns an error?
It seems to me that the parameter type for the accounting functions
should be ssize_t.
Ben.
--
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
This patch adds L7 traffic accounting in taskstats API, so
the iotop like applications can receive these statistics data.
In fact, I also have an iotop patch for this change.
It ignores any protocol header overhead, so results of this
patch should be saw as the applications-aware data statistics
instead of traffic statistics on wire.
The changes of v2 are:
1. Move up accounting source code, so they are not protocol-aware now.
2. Skipping interrupt context accounting.
[...]
quoted
--- a/include/net/sock.h+++ b/include/net/sock.h
@@ -1735,6 +1735,18 @@ static inline int skb_copy_to_page(struct sock
[...]
These are only called from system calls, so why are you checking for IRQ
context?
Some caller are exported symbols or in exported symbols path, so
I think that we'd best that do not assume that such symbols only
work at process context, it may be used by some kernel modules in
softirq context.
However, faint, the 'len' should be signed int type.
quoted
@@ -558,7 +559,10 @@ static inline int __sock_sendmsg_nosec(struct kiocb
[...]
So what happens to the totals when sendmsg() returns an error?
It seems to me that the parameter type for the accounting functions
should be ssize_t.
En, I think that "int" is enough here at least, the return type of
__sock_sendmsg_nosec() also is int ...
Thanks
Yu
This patch adds L7 traffic accounting in taskstats API, so
the iotop like applications can receive these statistics data.
In fact, I also have an iotop patch for this change.
It ignores any protocol header overhead, so results of this
patch should be saw as the applications-aware data statistics
instead of traffic statistics on wire.
The changes of v3 are:
1. Fix unsigned type of parameter of task_net_accounting_tx/rx()
That is all, hope this is ready to merge.
Thanks.
Signed-off-by: Li Yu <redacted>
include/linux/sched.h | 2 ++
include/linux/taskstats.h | 7 ++++++-
include/net/sock.h | 12 ++++++++++++
kernel/fork.c | 1 +
kernel/taskstats.c | 6 ++++++
net/socket.c | 27 ++++++++++++++++++++++-----
6 files changed, 49 insertions(+), 6 deletions(-)
From: David Miller <davem@davemloft.net> Date: 2012-02-26 19:14:12
Your patch was severely corrupted by your email client,
making it unusable for us.
Test email the patch to youself, and do not resubmit this patch to us
until the patch you receive you can actually apply cleanly.