gen_estimator: change the lock order for better perfermance
Subsystems (2)
PATCH 1/1 gen_estimator: change the lock order for better perfermance
From: Hong Zhiguo <[email protected]>
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.
--- net/core/gen_estimator.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/core/gen_estimator.c +2 -2
@@ -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))
Signature · 1 line
1.8.1.2
Quoted 7 lines · Hong Zhiguo
From: Hong Zhiguo <[email protected]>
e->stats_lockis usually taken by fast path to update stats. In the old order, fast path should wait forwrite_lock(&est_lock). Even though it's only one line inside thewrite_lock(&est_lock), but if there's interrupt or page fault, a lot of spin one->stats_lockwill 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 ?
答复: [PATCH net-next] gen_estimator: change the lock order for better perfermance(Internet mail)
Actually I did try LOCKDEP and didn't get any warning.
Could you pointed out why it's wrong?
-----邮件原件-----
发件人: Eric Dumazet [mailto:[email protected]]
发送时间: 2013年9月17日 19:12
收件人: Hong Zhiguo
抄送: [email protected]; [email protected]; [email protected]; zhiguohong(洪志国) 主题: Re: [PATCH net-next] gen_estimator: change the lock order for better perfermance(Internet mail)
Quoted 7 lines · Hong Zhiguo
From: Hong Zhiguo <[email protected]>
e->stats_lockis usually taken by fast path to update stats. In the old order, fast path should wait forwrite_lock(&est_lock). Even though it's only one line inside thewrite_lock(&est_lock), but if there's interrupt or page fault, a lot of spin one->stats_lockwill 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 ?