* [PATCH] get rid of read/write lock in gen_estimator
@ 2009-09-28 18:38 Stephen Hemminger
2009-09-28 18:50 ` Eric Dumazet
0 siblings, 1 reply; 3+ messages in thread
From: Stephen Hemminger @ 2009-09-28 18:38 UTC (permalink / raw)
To: David Miller, netdev
Don't need a read/write lock here sinc there already is a spin lock that
is being acquired.
Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
--- a/net/core/gen_estimator.c 2009-09-24 16:27:01.239755070 -0700
+++ b/net/core/gen_estimator.c 2009-09-24 16:41:09.290751273 -0700
@@ -101,9 +101,6 @@ struct gen_estimator_head
static struct gen_estimator_head elist[EST_MAX_INTERVAL+1];
-/* Protects against NULL dereference */
-static DEFINE_RWLOCK(est_lock);
-
/* Protects against soft lockup during large deletion */
static struct rb_root est_root = RB_ROOT;
@@ -118,9 +115,8 @@ static void est_timer(unsigned long arg)
u64 brate;
u32 npackets;
u32 rate;
-
+
spin_lock(e->stats_lock);
- read_lock(&est_lock);
if (e->bstats == NULL)
goto skip;
@@ -136,7 +132,6 @@ static void est_timer(unsigned long arg)
e->avpps += (rate >> e->ewma_log) - (e->avpps >> e->ewma_log);
e->rate_est->pps = (e->avpps+0x1FF)>>10;
skip:
- read_unlock(&est_lock);
spin_unlock(e->stats_lock);
}
@@ -270,9 +265,9 @@ void gen_kill_estimator(struct gnet_stat
while ((e = gen_find_node(bstats, rate_est))) {
rb_erase(&e->node, &est_root);
- write_lock_bh(&est_lock);
+ spin_lock(e->stats_lock);
e->bstats = NULL;
- write_unlock_bh(&est_lock);
+ spin_unlock(e->stats_lock);
list_del_rcu(&e->list);
call_rcu(&e->e_rcu, __gen_kill_estimator);
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] get rid of read/write lock in gen_estimator
2009-09-28 18:38 [PATCH] get rid of read/write lock in gen_estimator Stephen Hemminger
@ 2009-09-28 18:50 ` Eric Dumazet
2009-09-28 19:42 ` David Miller
0 siblings, 1 reply; 3+ messages in thread
From: Eric Dumazet @ 2009-09-28 18:50 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: David Miller, netdev
Stephen Hemminger a écrit :
> Don't need a read/write lock here sinc there already is a spin lock that
> is being acquired.
>
> Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
>
> --- a/net/core/gen_estimator.c 2009-09-24 16:27:01.239755070 -0700
> +++ b/net/core/gen_estimator.c 2009-09-24 16:41:09.290751273 -0700
> @@ -101,9 +101,6 @@ struct gen_estimator_head
>
> static struct gen_estimator_head elist[EST_MAX_INTERVAL+1];
>
> -/* Protects against NULL dereference */
> -static DEFINE_RWLOCK(est_lock);
> -
> /* Protects against soft lockup during large deletion */
> static struct rb_root est_root = RB_ROOT;
>
> @@ -118,9 +115,8 @@ static void est_timer(unsigned long arg)
> u64 brate;
> u32 npackets;
> u32 rate;
> -
> +
> spin_lock(e->stats_lock);
> - read_lock(&est_lock);
> if (e->bstats == NULL)
> goto skip;
>
> @@ -136,7 +132,6 @@ static void est_timer(unsigned long arg)
> e->avpps += (rate >> e->ewma_log) - (e->avpps >> e->ewma_log);
> e->rate_est->pps = (e->avpps+0x1FF)>>10;
> skip:
> - read_unlock(&est_lock);
> spin_unlock(e->stats_lock);
> }
>
> @@ -270,9 +265,9 @@ void gen_kill_estimator(struct gnet_stat
> while ((e = gen_find_node(bstats, rate_est))) {
> rb_erase(&e->node, &est_root);
>
> - write_lock_bh(&est_lock);
> + spin_lock(e->stats_lock);
Are you sure _bh() variant is not needed here ?
> e->bstats = NULL;
> - write_unlock_bh(&est_lock);
> + spin_unlock(e->stats_lock);
>
> list_del_rcu(&e->list);
> call_rcu(&e->e_rcu, __gen_kill_estimator);
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] get rid of read/write lock in gen_estimator
2009-09-28 18:50 ` Eric Dumazet
@ 2009-09-28 19:42 ` David Miller
0 siblings, 0 replies; 3+ messages in thread
From: David Miller @ 2009-09-28 19:42 UTC (permalink / raw)
To: eric.dumazet; +Cc: shemminger, netdev
From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Mon, 28 Sep 2009 20:50:28 +0200
> Stephen Hemminger a écrit :
>> Don't need a read/write lock here sinc there already is a spin lock that
>> is being acquired.
>>
>> Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
...
>> @@ -270,9 +265,9 @@ void gen_kill_estimator(struct gnet_stat
>> while ((e = gen_find_node(bstats, rate_est))) {
>> rb_erase(&e->node, &est_root);
>>
>> - write_lock_bh(&est_lock);
>> + spin_lock(e->stats_lock);
>
> Are you sure _bh() variant is not needed here ?
Right, that need to be fixed to be spin_lock_bh() and spin_unlock_bh()
in the next hunk.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2009-09-28 19:42 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-09-28 18:38 [PATCH] get rid of read/write lock in gen_estimator Stephen Hemminger
2009-09-28 18:50 ` Eric Dumazet
2009-09-28 19:42 ` David Miller
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.