aboutsummaryrefslogtreecommitdiffstats
path: root/net/core
diff options
context:
space:
mode:
authorJarek Poplawski <jarkao2@gmail.com>2008-11-26 18:24:32 -0500
committerDavid S. Miller <davem@davemloft.net>2008-11-26 18:24:32 -0500
commit244e6c2d0724bc4908a1995804704bdee3b31528 (patch)
treee208a765607733401302bf8582b37d1adab63c08 /net/core
parent3d4cd60ed0533d3b33832e298530c7b021da982b (diff)
pkt_sched: gen_estimator: Optimize gen_estimator_active()
Since all other gen_estimator functions use bstats and rate_est params together, and searching for them is optimized now, let's use this also in gen_estimator_active(). The return type of gen_estimator_active() is changed to bool, and gen_find_node() parameters to const, btw. In tcf_act_police_locate() a check for ACT_P_CREATED is added before calling gen_estimator_active(). Signed-off-by: Jarek Poplawski <jarkao2@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core')
-rw-r--r--net/core/gen_estimator.c25
1 files changed, 8 insertions, 17 deletions
diff --git a/net/core/gen_estimator.c b/net/core/gen_estimator.c
index 3885550f0187..9cc9f95b109e 100644
--- a/net/core/gen_estimator.c
+++ b/net/core/gen_estimator.c
@@ -163,8 +163,9 @@ static void gen_add_node(struct gen_estimator *est)
163 rb_insert_color(&est->node, &est_root); 163 rb_insert_color(&est->node, &est_root);
164} 164}
165 165
166static struct gen_estimator *gen_find_node(struct gnet_stats_basic *bstats, 166static
167 struct gnet_stats_rate_est *rate_est) 167struct gen_estimator *gen_find_node(const struct gnet_stats_basic *bstats,
168 const struct gnet_stats_rate_est *rate_est)
168{ 169{
169 struct rb_node *p = est_root.rb_node; 170 struct rb_node *p = est_root.rb_node;
170 171
@@ -301,26 +302,16 @@ EXPORT_SYMBOL(gen_replace_estimator);
301 302
302/** 303/**
303 * gen_estimator_active - test if estimator is currently in use 304 * gen_estimator_active - test if estimator is currently in use
305 * @bstats: basic statistics
304 * @rate_est: rate estimator statistics 306 * @rate_est: rate estimator statistics
305 * 307 *
306 * Returns 1 if estimator is active, and 0 if not. 308 * Returns true if estimator is active, and false if not.
307 */ 309 */
308int gen_estimator_active(const struct gnet_stats_rate_est *rate_est) 310bool gen_estimator_active(const struct gnet_stats_basic *bstats,
311 const struct gnet_stats_rate_est *rate_est)
309{ 312{
310 int idx;
311 struct gen_estimator *e;
312
313 ASSERT_RTNL(); 313 ASSERT_RTNL();
314 314
315 for (idx=0; idx <= EST_MAX_INTERVAL; idx++) { 315 return gen_find_node(bstats, rate_est) != NULL;
316 if (!elist[idx].timer.function)
317 continue;
318
319 list_for_each_entry(e, &elist[idx].list, list) {
320 if (e->rate_est == rate_est)
321 return 1;
322 }
323 }
324 return 0;
325} 316}
326EXPORT_SYMBOL(gen_estimator_active); 317EXPORT_SYMBOL(gen_estimator_active);