From: Hong Zhiguo <honkiko@gmail.com>
To: netdev@vger.kernel.org
Cc: davem@davemloft.net, stephen@networkplumber.org,
Hong Zhiguo <zhiguohong@tencent.com>
Subject: [PATCH net-next] gen_estimator: change the lock order for better perfermance
Date: Tue, 17 Sep 2013 16:38:21 +0800 [thread overview]
Message-ID: <1379407101-18933-1-git-send-email-zhiguohong@tencent.com> (raw)
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
next reply other threads:[~2013-09-17 8:40 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-17 8:38 Hong Zhiguo [this message]
2013-09-17 11:11 ` [PATCH net-next] gen_estimator: change the lock order for better perfermance Eric Dumazet
2013-09-18 5:41 ` 答复: [PATCH net-next] gen_estimator: change the lock order for better perfermance(Internet mail) zhiguohong(洪志国)
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=1379407101-18933-1-git-send-email-zhiguohong@tencent.com \
--to=honkiko@gmail.com \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
--cc=stephen@networkplumber.org \
--cc=zhiguohong@tencent.com \
/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