Commit e560d2c3 authored by Stephen Hemminger's avatar Stephen Hemminger Committed by David S. Miller

[PKT_SCHED]: Eliminate guard from TDIFF_SAFE.

The last argument in the PSCHED_TDIFF_SAFE is no longer used;
only usage eliminated by previous patch. It gets rid of a bad macro
usage.

Also, can use the standard min_t macro which also eliminates the
macro problem of double evaluation of bound.
Signed-off-by: default avatarStephen Hemminger <shemminger@osdl.org>
Signed-off-by: default avatarDavid S. Miller <davem@redhat.com>
parent 4b53b3b7
...@@ -308,13 +308,13 @@ extern PSCHED_WATCHER psched_time_mark; ...@@ -308,13 +308,13 @@ extern PSCHED_WATCHER psched_time_mark;
extern int psched_tod_diff(int delta_sec, int bound); extern int psched_tod_diff(int delta_sec, int bound);
#define PSCHED_TDIFF_SAFE(tv1, tv2, bound, guard) \ #define PSCHED_TDIFF_SAFE(tv1, tv2, bound) \
({ \ ({ \
int __delta_sec = (tv1).tv_sec - (tv2).tv_sec; \ int __delta_sec = (tv1).tv_sec - (tv2).tv_sec; \
int __delta = (tv1).tv_usec - (tv2).tv_usec; \ int __delta = (tv1).tv_usec - (tv2).tv_usec; \
switch (__delta_sec) { \ switch (__delta_sec) { \
default: \ default: \
__delta = psched_tod_diff(__delta_sec, bound); guard; break; \ __delta = psched_tod_diff(__delta_sec, bound); break; \
case 2: \ case 2: \
__delta += 1000000; \ __delta += 1000000; \
case 1: \ case 1: \
...@@ -355,12 +355,8 @@ extern int psched_tod_diff(int delta_sec, int bound); ...@@ -355,12 +355,8 @@ extern int psched_tod_diff(int delta_sec, int bound);
#else #else
#define PSCHED_TDIFF(tv1, tv2) (long)((tv1) - (tv2)) #define PSCHED_TDIFF(tv1, tv2) (long)((tv1) - (tv2))
#define PSCHED_TDIFF_SAFE(tv1, tv2, bound, guard) \ #define PSCHED_TDIFF_SAFE(tv1, tv2, bound) \
({ \ min_t(long long, (tv1) - (tv2), bound)
long long __delta = (tv1) - (tv2); \
if ( __delta > (long long)(bound)) { __delta = (bound); guard; } \
__delta; \
})
#define PSCHED_TLESS(tv1, tv2) ((tv1) < (tv2)) #define PSCHED_TLESS(tv1, tv2) ((tv1) < (tv2))
......
...@@ -321,7 +321,7 @@ int tcf_act_police(struct sk_buff **pskb, struct tc_action *a) ...@@ -321,7 +321,7 @@ int tcf_act_police(struct sk_buff **pskb, struct tc_action *a)
PSCHED_GET_TIME(now); PSCHED_GET_TIME(now);
toks = PSCHED_TDIFF_SAFE(now, p->t_c, p->burst, (void)0); toks = PSCHED_TDIFF_SAFE(now, p->t_c, p->burst);
if (p->P_tab) { if (p->P_tab) {
ptoks = toks + p->ptoks; ptoks = toks + p->ptoks;
...@@ -523,7 +523,7 @@ int tcf_police(struct sk_buff *skb, struct tcf_police *p) ...@@ -523,7 +523,7 @@ int tcf_police(struct sk_buff *skb, struct tcf_police *p)
PSCHED_GET_TIME(now); PSCHED_GET_TIME(now);
toks = PSCHED_TDIFF_SAFE(now, p->t_c, p->burst, (void)0); toks = PSCHED_TDIFF_SAFE(now, p->t_c, p->burst);
if (p->P_tab) { if (p->P_tab) {
ptoks = toks + p->ptoks; ptoks = toks + p->ptoks;
......
...@@ -155,7 +155,7 @@ gred_enqueue(struct sk_buff *skb, struct Qdisc* sch) ...@@ -155,7 +155,7 @@ gred_enqueue(struct sk_buff *skb, struct Qdisc* sch)
if (!PSCHED_IS_PASTPERFECT(q->qidlestart)) { if (!PSCHED_IS_PASTPERFECT(q->qidlestart)) {
long us_idle; long us_idle;
PSCHED_GET_TIME(now); PSCHED_GET_TIME(now);
us_idle = PSCHED_TDIFF_SAFE(now, q->qidlestart, q->Scell_max, (void)0); us_idle = PSCHED_TDIFF_SAFE(now, q->qidlestart, q->Scell_max);
PSCHED_SET_PASTPERFECT(q->qidlestart); PSCHED_SET_PASTPERFECT(q->qidlestart);
q->qave >>= q->Stab[(us_idle>>q->Scell_log)&0xFF]; q->qave >>= q->Stab[(us_idle>>q->Scell_log)&0xFF];
...@@ -551,7 +551,7 @@ static int gred_dump(struct Qdisc *sch, struct sk_buff *skb) ...@@ -551,7 +551,7 @@ static int gred_dump(struct Qdisc *sch, struct sk_buff *skb)
long idle; long idle;
psched_time_t now; psched_time_t now;
PSCHED_GET_TIME(now); PSCHED_GET_TIME(now);
idle = PSCHED_TDIFF_SAFE(now, q->qidlestart, q->Scell_max, (void)0); idle = PSCHED_TDIFF_SAFE(now, q->qidlestart, q->Scell_max);
qave = q->qave >> q->Stab[(idle>>q->Scell_log)&0xFF]; qave = q->qave >> q->Stab[(idle>>q->Scell_log)&0xFF];
dst->qave = qave >> q->Wlog; dst->qave = qave >> q->Wlog;
......
...@@ -367,7 +367,7 @@ static void htb_debug_dump (struct htb_sched *q) ...@@ -367,7 +367,7 @@ static void htb_debug_dump (struct htb_sched *q)
struct list_head *l; struct list_head *l;
list_for_each (l,q->hash+i) { list_for_each (l,q->hash+i) {
struct htb_class *cl = list_entry(l,struct htb_class,hlist); struct htb_class *cl = list_entry(l,struct htb_class,hlist);
long diff = PSCHED_TDIFF_SAFE(q->now, cl->t_c, (u32)cl->mbuffer, (void)0); long diff = PSCHED_TDIFF_SAFE(q->now, cl->t_c, (u32)cl->mbuffer);
printk(KERN_DEBUG "htb*c%x m=%d t=%ld c=%ld pq=%lu df=%ld ql=%d " printk(KERN_DEBUG "htb*c%x m=%d t=%ld c=%ld pq=%lu df=%ld ql=%d "
"pa=%x f:", "pa=%x f:",
cl->classid,cl->cmode,cl->tokens,cl->ctokens, cl->classid,cl->cmode,cl->tokens,cl->ctokens,
...@@ -807,7 +807,7 @@ static void htb_charge_class(struct htb_sched *q,struct htb_class *cl, ...@@ -807,7 +807,7 @@ static void htb_charge_class(struct htb_sched *q,struct htb_class *cl,
while (cl) { while (cl) {
HTB_CHCL(cl); HTB_CHCL(cl);
diff = PSCHED_TDIFF_SAFE(q->now, cl->t_c, (u32)cl->mbuffer, (void)0); diff = PSCHED_TDIFF_SAFE(q->now, cl->t_c, (u32)cl->mbuffer);
#ifdef HTB_DEBUG #ifdef HTB_DEBUG
if (diff > cl->mbuffer || diff < 0 || PSCHED_TLESS(q->now, cl->t_c)) { if (diff > cl->mbuffer || diff < 0 || PSCHED_TLESS(q->now, cl->t_c)) {
if (net_ratelimit()) if (net_ratelimit())
...@@ -878,7 +878,7 @@ static long htb_do_events(struct htb_sched *q,int level) ...@@ -878,7 +878,7 @@ static long htb_do_events(struct htb_sched *q,int level)
return cl->pq_key - q->jiffies; return cl->pq_key - q->jiffies;
} }
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, (void)0); diff = PSCHED_TDIFF_SAFE(q->now, cl->t_c, (u32)cl->mbuffer);
#ifdef HTB_DEBUG #ifdef HTB_DEBUG
if (diff > cl->mbuffer || diff < 0 || PSCHED_TLESS(q->now, cl->t_c)) { if (diff > cl->mbuffer || diff < 0 || PSCHED_TLESS(q->now, cl->t_c)) {
if (net_ratelimit()) if (net_ratelimit())
......
...@@ -189,7 +189,7 @@ red_enqueue(struct sk_buff *skb, struct Qdisc* sch) ...@@ -189,7 +189,7 @@ red_enqueue(struct sk_buff *skb, struct Qdisc* sch)
int shift; int shift;
PSCHED_GET_TIME(now); PSCHED_GET_TIME(now);
us_idle = PSCHED_TDIFF_SAFE(now, q->qidlestart, q->Scell_max, (void)0); us_idle = PSCHED_TDIFF_SAFE(now, q->qidlestart, q->Scell_max);
PSCHED_SET_PASTPERFECT(q->qidlestart); PSCHED_SET_PASTPERFECT(q->qidlestart);
/* /*
......
...@@ -207,7 +207,7 @@ static struct sk_buff *tbf_dequeue(struct Qdisc* sch) ...@@ -207,7 +207,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, (void)0); toks = PSCHED_TDIFF_SAFE(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