From: Li Yu <raise.sail@gmail.com>
To: Ben Hutchings <bhutchings@solarflare.com>
Cc: netdev@vger.kernel.org, David Miller <davem@davemloft.net>
Subject: Re: [PATCH net-next v2] extend taskstats API to support networking accounts
Date: Fri, 24 Feb 2012 11:15:45 +0800 [thread overview]
Message-ID: <4F4700E1.3010407@gmail.com> (raw)
In-Reply-To: <1330052710.2511.37.camel@bwh-desktop>
于 2012年02月24日 11:05, Ben Hutchings 写道:
> 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.
> [...]
>> --- 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?
>
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.
>> @@ -558,7 +559,10 @@ static inline int __sock_sendmsg_nosec(struct kiocb
>> *iocb, struct socket *sock,
>> si->msg = msg;
>> si->size = size;
>>
>> - return sock->ops->sendmsg(iocb, sock, msg, size);
>> + ret = sock->ops->sendmsg(iocb, sock, msg, size);
>> + task_net_accounting_tx(ret);
>> +
>> + return ret;
>> }
> [...]
>
> 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
> Ben.
>
next prev parent reply other threads:[~2012-02-24 3:15 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-23 8:22 [PATCH] extend taskstats API to support networking accounts Li Yu
2012-02-23 8:34 ` David Miller
2012-02-24 2:43 ` [PATCH net-next v2] " Li Yu
2012-02-24 3:05 ` Ben Hutchings
2012-02-24 3:15 ` Li Yu [this message]
2012-02-24 10:21 ` [PATCH net-next v3] " Li Yu
2012-02-26 19:14 ` David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4F4700E1.3010407@gmail.com \
--to=raise.sail@gmail.com \
--cc=bhutchings@solarflare.com \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).