Re: [PATCH][NET_SCHED] Update htb rate when stats are polled.
From: Patrick McHardy <hidden>
Date: 2007-05-26 07:58:49
From: Patrick McHardy <hidden>
Date: 2007-05-26 07:58:49
Ranjit Manomohan wrote:
Currently the HTB rate for a class is update very slowly (once
every 16 seconds). This patch updates the rate whenever the stats
are requested from user space. This enables more accurate rate
monitoring.
+/* Update packet/byte rate for a class. */
+static void calc_rate(struct htb_class *cl)
+{
+ unsigned long now = jiffies;
+ if (time_after(now, (cl->rate_est_when + HZ))) {
+ unsigned int elapsed_secs =
+ (now - cl->rate_est_when)/HZ;
+ cl->sum_bytes /= elapsed_secs;
+ cl->sum_packets /= elapsed_secs;
+ RT_GEN (cl->sum_bytes,cl->rate_bytes);
+ RT_GEN (cl->sum_packets,cl->rate_packets);
+ cl->rate_est_when = now;
+ } else if time_before(now, cl->rate_est_when)
+ cl->rate_est_when = now; /* Wraparound */
+}We have a generic rate estimator, I think we should convert HTB over to use it and then maybe add this feature to the generic estimator.