* [PATCH net-next] gen_estimator: change the lock order for better perfermance
@ 2013-09-17 8:38 Hong Zhiguo
2013-09-17 11:11 ` Eric Dumazet
0 siblings, 1 reply; 3+ messages in thread
From: Hong Zhiguo @ 2013-09-17 8:38 UTC (permalink / raw)
To: netdev; +Cc: davem, stephen, Hong Zhiguo
From: Hong Zhiguo <zhiguohong@tencent.com>
e->stats_lock is usually taken by fast path to update stats.
In the old order, fast path should wait for write_lock(&est_lock).
Even though it's only one line inside the write_lock(&est_lock),
but if there's interrupt or page fault, a lot of spin on
e->stats_lock will be wasted in fast path.
Signed-off-by: Hong Zhiguo <zhiguohong@tencent.com>
---
net/core/gen_estimator.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/core/gen_estimator.c b/net/core/gen_estimator.c
index 6b5b6e7..bad7f5f 100644
--- a/net/core/gen_estimator.c
+++ b/net/core/gen_estimator.c
@@ -120,11 +120,11 @@ static void est_timer(unsigned long arg)
u32 npackets;
u32 rate;
- spin_lock(e->stats_lock);
read_lock(&est_lock);
if (e->bstats == NULL)
goto skip;
+ spin_lock(e->stats_lock);
nbytes = e->bstats->bytes;
npackets = e->bstats->packets;
brate = (nbytes - e->last_bytes)<<(7 - idx);
@@ -136,9 +136,9 @@ static void est_timer(unsigned long arg)
e->last_packets = npackets;
e->avpps += (rate >> e->ewma_log) - (e->avpps >> e->ewma_log);
e->rate_est->pps = (e->avpps+0x1FF)>>10;
+ spin_unlock(e->stats_lock);
skip:
read_unlock(&est_lock);
- spin_unlock(e->stats_lock);
}
if (!list_empty(&elist[idx].list))
--
1.8.1.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net-next] gen_estimator: change the lock order for better perfermance
2013-09-17 8:38 [PATCH net-next] gen_estimator: change the lock order for better perfermance Hong Zhiguo
@ 2013-09-17 11:11 ` Eric Dumazet
2013-09-18 5:41 ` 答复: [PATCH net-next] gen_estimator: change the lock order for better perfermance(Internet mail) zhiguohong(洪志国)
0 siblings, 1 reply; 3+ messages in thread
From: Eric Dumazet @ 2013-09-17 11:11 UTC (permalink / raw)
To: Hong Zhiguo; +Cc: netdev, davem, stephen, Hong Zhiguo
On Tue, 2013-09-17 at 16:38 +0800, Hong Zhiguo wrote:
> From: Hong Zhiguo <zhiguohong@tencent.com>
>
> e->stats_lock is usually taken by fast path to update stats.
> In the old order, fast path should wait for write_lock(&est_lock).
> Even though it's only one line inside the write_lock(&est_lock),
> but if there's interrupt or page fault, a lot of spin on
> e->stats_lock will be wasted in fast path.
1) net-next is not open
2) There is no way a page fault can happen in this path.
3) This patch is wrong.
Current order is there for good reasons.
Have you really tried LOCKDEP, before sending a patch changing lock
order ?
^ permalink raw reply [flat|nested] 3+ messages in thread
* 答复: [PATCH net-next] gen_estimator: change the lock order for better perfermance(Internet mail)
2013-09-17 11:11 ` Eric Dumazet
@ 2013-09-18 5:41 ` zhiguohong(洪志国)
0 siblings, 0 replies; 3+ messages in thread
From: zhiguohong(洪志国) @ 2013-09-18 5:41 UTC (permalink / raw)
To: Eric Dumazet, Hong Zhiguo
Cc: netdev@vger.kernel.org, davem@davemloft.net,
stephen@networkplumber.org
Actually I did try LOCKDEP and didn't get any warning.
Could you pointed out why it's wrong?
-----邮件原件-----
发件人: Eric Dumazet [mailto:eric.dumazet@gmail.com]
发送时间: 2013年9月17日 19:12
收件人: Hong Zhiguo
抄送: netdev@vger.kernel.org; davem@davemloft.net; stephen@networkplumber.org; zhiguohong(洪志国)
主题: Re: [PATCH net-next] gen_estimator: change the lock order for better perfermance(Internet mail)
On Tue, 2013-09-17 at 16:38 +0800, Hong Zhiguo wrote:
> From: Hong Zhiguo <zhiguohong@tencent.com>
>
> e->stats_lock is usually taken by fast path to update stats.
> In the old order, fast path should wait for write_lock(&est_lock).
> Even though it's only one line inside the write_lock(&est_lock), but
> if there's interrupt or page fault, a lot of spin on
> e->stats_lock will be wasted in fast path.
1) net-next is not open
2) There is no way a page fault can happen in this path.
3) This patch is wrong.
Current order is there for good reasons.
Have you really tried LOCKDEP, before sending a patch changing lock order ?
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-09-18 5:50 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-17 8:38 [PATCH net-next] gen_estimator: change the lock order for better perfermance Hong Zhiguo
2013-09-17 11:11 ` Eric Dumazet
2013-09-18 5:41 ` 答复: [PATCH net-next] gen_estimator: change the lock order for better perfermance(Internet mail) zhiguohong(洪志国)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox