Commit 105e808c authored by Leslie Monis's avatar Leslie Monis Committed by David S. Miller

pie: remove pie_vars->accu_prob_overflows

The variable pie_vars->accu_prob is used as an accumulator for
probability values. Since probabilty values are scaled using the
MAX_PROB macro denoting (2^64 - 1), pie_vars->accu_prob is
likely to overflow as it is of type u64.

The variable pie_vars->accu_prob_overflows counts the number of
times the variable pie_vars->accu_prob overflows.

The MAX_PROB macro needs to be equal to at least (2^39 - 1) in
order to do precise calculations without any underflow. Thus
MAX_PROB can be reduced to (2^56 - 1) without affecting the
precision in calculations drastically. Doing so will eliminate
the need for the variable pie_vars->accu_prob_overflows as the
variable pie_vars->accu_prob will never overflow.

Removing the variable pie_vars->accu_prob_overflows also reduces
the size of the structure pie_vars to exactly 64 bytes.
Signed-off-by: default avatarMohit P. Tahiliani <tahiliani@nitk.edu.in>
Signed-off-by: default avatarGautam Ramakrishnan <gautamramk@gmail.com>
Signed-off-by: default avatarLeslie Monis <lesliemonis@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 220d4ac7
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
#include <net/inet_ecn.h> #include <net/inet_ecn.h>
#include <net/pkt_sched.h> #include <net/pkt_sched.h>
#define MAX_PROB U64_MAX #define MAX_PROB (U64_MAX >> BITS_PER_BYTE)
#define DTIME_INVALID U64_MAX #define DTIME_INVALID U64_MAX
#define QUEUE_THRESHOLD 16384 #define QUEUE_THRESHOLD 16384
#define DQCOUNT_INVALID -1 #define DQCOUNT_INVALID -1
...@@ -47,7 +47,6 @@ struct pie_params { ...@@ -47,7 +47,6 @@ struct pie_params {
* @dq_count: number of bytes dequeued in a measurement cycle * @dq_count: number of bytes dequeued in a measurement cycle
* @avg_dq_rate: calculated average dq rate * @avg_dq_rate: calculated average dq rate
* @backlog_old: queue backlog during previous qdelay calculation * @backlog_old: queue backlog during previous qdelay calculation
* @accu_prob_overflows: number of times accu_prob overflows
*/ */
struct pie_vars { struct pie_vars {
psched_time_t qdelay; psched_time_t qdelay;
...@@ -59,7 +58,6 @@ struct pie_vars { ...@@ -59,7 +58,6 @@ struct pie_vars {
u64 dq_count; u64 dq_count;
u32 avg_dq_rate; u32 avg_dq_rate;
u32 backlog_old; u32 backlog_old;
u8 accu_prob_overflows;
}; };
/** /**
...@@ -107,7 +105,6 @@ static inline void pie_vars_init(struct pie_vars *vars) ...@@ -107,7 +105,6 @@ static inline void pie_vars_init(struct pie_vars *vars)
vars->accu_prob = 0; vars->accu_prob = 0;
vars->dq_count = DQCOUNT_INVALID; vars->dq_count = DQCOUNT_INVALID;
vars->avg_dq_rate = 0; vars->avg_dq_rate = 0;
vars->accu_prob_overflows = 0;
} }
static inline struct pie_skb_cb *get_pie_cb(const struct sk_buff *skb) static inline struct pie_skb_cb *get_pie_cb(const struct sk_buff *skb)
......
...@@ -189,7 +189,6 @@ static int fq_pie_qdisc_enqueue(struct sk_buff *skb, struct Qdisc *sch, ...@@ -189,7 +189,6 @@ static int fq_pie_qdisc_enqueue(struct sk_buff *skb, struct Qdisc *sch,
out: out:
q->stats.dropped++; q->stats.dropped++;
sel_flow->vars.accu_prob = 0; sel_flow->vars.accu_prob = 0;
sel_flow->vars.accu_prob_overflows = 0;
__qdisc_drop(skb, to_free); __qdisc_drop(skb, to_free);
qdisc_qstats_drop(sch); qdisc_qstats_drop(sch);
return NET_XMIT_CN; return NET_XMIT_CN;
......
...@@ -62,27 +62,19 @@ bool pie_drop_early(struct Qdisc *sch, struct pie_params *params, ...@@ -62,27 +62,19 @@ bool pie_drop_early(struct Qdisc *sch, struct pie_params *params,
else else
local_prob = vars->prob; local_prob = vars->prob;
if (local_prob == 0) { if (local_prob == 0)
vars->accu_prob = 0; vars->accu_prob = 0;
vars->accu_prob_overflows = 0; else
}
if (local_prob > MAX_PROB - vars->accu_prob)
vars->accu_prob_overflows++;
vars->accu_prob += local_prob; vars->accu_prob += local_prob;
if (vars->accu_prob_overflows == 0 && if (vars->accu_prob < (MAX_PROB / 100) * 85)
vars->accu_prob < (MAX_PROB / 100) * 85)
return false; return false;
if (vars->accu_prob_overflows == 8 && if (vars->accu_prob >= (MAX_PROB / 2) * 17)
vars->accu_prob >= MAX_PROB / 2)
return true; return true;
prandom_bytes(&rnd, 8); prandom_bytes(&rnd, 8);
if (rnd < local_prob) { if ((rnd >> BITS_PER_BYTE) < local_prob) {
vars->accu_prob = 0; vars->accu_prob = 0;
vars->accu_prob_overflows = 0;
return true; return true;
} }
...@@ -129,7 +121,6 @@ static int pie_qdisc_enqueue(struct sk_buff *skb, struct Qdisc *sch, ...@@ -129,7 +121,6 @@ static int pie_qdisc_enqueue(struct sk_buff *skb, struct Qdisc *sch,
out: out:
q->stats.dropped++; q->stats.dropped++;
q->vars.accu_prob = 0; q->vars.accu_prob = 0;
q->vars.accu_prob_overflows = 0;
return qdisc_drop(skb, sch, to_free); return qdisc_drop(skb, sch, to_free);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment