Commit 03cc45c0 authored by Patrick McHardy's avatar Patrick McHardy Committed by David S. Miller

[NET_SCHED]: turn PSCHED_TDIFF_SAFE into inline function

Also rename to psched_tdiff_bounded.
Signed-off-by: default avatarPatrick McHardy <kaber@trash.net>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 8edc0c31
...@@ -51,10 +51,14 @@ typedef long psched_tdiff_t; ...@@ -51,10 +51,14 @@ typedef long psched_tdiff_t;
#define PSCHED_GET_TIME(stamp) \ #define PSCHED_GET_TIME(stamp) \
((stamp) = PSCHED_NS2US(ktime_to_ns(ktime_get()))) ((stamp) = PSCHED_NS2US(ktime_to_ns(ktime_get())))
#define PSCHED_TDIFF_SAFE(tv1, tv2, bound) \
min_t(long long, (tv1) - (tv2), bound)
#define PSCHED_PASTPERFECT 0 #define PSCHED_PASTPERFECT 0
static inline psched_tdiff_t
psched_tdiff_bounded(psched_time_t tv1, psched_time_t tv2, psched_time_t bound)
{
return min(tv1 - tv2, bound);
}
struct qdisc_watchdog { struct qdisc_watchdog {
struct hrtimer timer; struct hrtimer timer;
struct Qdisc *qdisc; struct Qdisc *qdisc;
......
...@@ -178,7 +178,7 @@ static inline unsigned long red_calc_qavg_from_idle_time(struct red_parms *p) ...@@ -178,7 +178,7 @@ static inline unsigned long red_calc_qavg_from_idle_time(struct red_parms *p)
int shift; int shift;
PSCHED_GET_TIME(now); PSCHED_GET_TIME(now);
us_idle = PSCHED_TDIFF_SAFE(now, p->qidlestart, p->Scell_max); us_idle = psched_tdiff_bounded(now, p->qidlestart, p->Scell_max);
/* /*
* The problem: ideally, average length queue recalcultion should * The problem: ideally, average length queue recalcultion should
......
...@@ -298,8 +298,8 @@ static int tcf_act_police(struct sk_buff *skb, struct tc_action *a, ...@@ -298,8 +298,8 @@ static int tcf_act_police(struct sk_buff *skb, struct tc_action *a,
PSCHED_GET_TIME(now); PSCHED_GET_TIME(now);
toks = PSCHED_TDIFF_SAFE(now, police->tcfp_t_c, toks = psched_tdiff_bounded(now, police->tcfp_t_c,
police->tcfp_burst); police->tcfp_burst);
if (police->tcfp_P_tab) { if (police->tcfp_P_tab) {
ptoks = toks + police->tcfp_ptoks; ptoks = toks + police->tcfp_ptoks;
if (ptoks > (long)L2T_P(police, police->tcfp_mtu)) if (ptoks > (long)L2T_P(police, police->tcfp_mtu))
...@@ -544,8 +544,8 @@ int tcf_police(struct sk_buff *skb, struct tcf_police *police) ...@@ -544,8 +544,8 @@ int tcf_police(struct sk_buff *skb, struct tcf_police *police)
} }
PSCHED_GET_TIME(now); PSCHED_GET_TIME(now);
toks = PSCHED_TDIFF_SAFE(now, police->tcfp_t_c, toks = psched_tdiff_bounded(now, police->tcfp_t_c,
police->tcfp_burst); police->tcfp_burst);
if (police->tcfp_P_tab) { if (police->tcfp_P_tab) {
ptoks = toks + police->tcfp_ptoks; ptoks = toks + police->tcfp_ptoks;
if (ptoks > (long)L2T_P(police, police->tcfp_mtu)) if (ptoks > (long)L2T_P(police, police->tcfp_mtu))
......
...@@ -729,7 +729,7 @@ static void htb_charge_class(struct htb_sched *q, struct htb_class *cl, ...@@ -729,7 +729,7 @@ static void htb_charge_class(struct htb_sched *q, struct htb_class *cl,
cl->T = toks cl->T = toks
while (cl) { while (cl) {
diff = PSCHED_TDIFF_SAFE(q->now, cl->t_c, (u32) cl->mbuffer); diff = psched_tdiff_bounded(q->now, cl->t_c, cl->mbuffer);
if (cl->level >= level) { if (cl->level >= level) {
if (cl->level == level) if (cl->level == level)
cl->xstats.lends++; cl->xstats.lends++;
...@@ -789,7 +789,7 @@ static psched_time_t htb_do_events(struct htb_sched *q, int level) ...@@ -789,7 +789,7 @@ static psched_time_t htb_do_events(struct htb_sched *q, int level)
return cl->pq_key; return cl->pq_key;
htb_safe_rb_erase(p, q->wait_pq + level); htb_safe_rb_erase(p, q->wait_pq + level);
diff = PSCHED_TDIFF_SAFE(q->now, cl->t_c, (u32) cl->mbuffer); diff = psched_tdiff_bounded(q->now, cl->t_c, cl->mbuffer);
htb_change_class_mode(q, cl, &diff); htb_change_class_mode(q, cl, &diff);
if (cl->cmode != HTB_CAN_SEND) if (cl->cmode != HTB_CAN_SEND)
htb_add_to_wait_tree(q, cl, diff); htb_add_to_wait_tree(q, cl, diff);
......
...@@ -201,7 +201,7 @@ static struct sk_buff *tbf_dequeue(struct Qdisc* sch) ...@@ -201,7 +201,7 @@ static struct sk_buff *tbf_dequeue(struct Qdisc* sch)
PSCHED_GET_TIME(now); PSCHED_GET_TIME(now);
toks = PSCHED_TDIFF_SAFE(now, q->t_c, q->buffer); toks = psched_tdiff_bounded(now, q->t_c, q->buffer);
if (q->P_tab) { if (q->P_tab) {
ptoks = toks + q->ptokens; ptoks = toks + q->ptokens;
......
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