aboutsummaryrefslogtreecommitdiffstats
path: root/net/sched
diff options
context:
space:
mode:
authorHiroaki SHIMODA <shimoda.hiroaki@gmail.com>2014-03-02 03:30:26 -0500
committerDavid S. Miller <davem@davemloft.net>2014-03-03 15:43:47 -0500
commita135e598c463baf9497b84e1e92f9a8f96d3521c (patch)
tree4debda792d5839b458ad562553616ce73b9f860f /net/sched
parent677676cd584033a47974c3634c6c9235e14db1a4 (diff)
sch_tbf: Remove holes in struct tbf_sched_data.
On x86_64 we have 3 holes in struct tbf_sched_data. The member peak_present can be replaced with peak.rate_bytes_ps, because peak.rate_bytes_ps is set only when peak is specified in tbf_change(). tbf_peak_present() is introduced to test peak.rate_bytes_ps. The member max_size is moved to fill 32bit hole. Signed-off-by: Hiroaki SHIMODA <shimoda.hiroaki@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/sched')
-rw-r--r--net/sched/sch_tbf.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/net/sched/sch_tbf.c b/net/sched/sch_tbf.c
index 1cb413fead89..0893161b0262 100644
--- a/net/sched/sch_tbf.c
+++ b/net/sched/sch_tbf.c
@@ -101,12 +101,11 @@
101struct tbf_sched_data { 101struct tbf_sched_data {
102/* Parameters */ 102/* Parameters */
103 u32 limit; /* Maximal length of backlog: bytes */ 103 u32 limit; /* Maximal length of backlog: bytes */
104 u32 max_size;
104 s64 buffer; /* Token bucket depth/rate: MUST BE >= MTU/B */ 105 s64 buffer; /* Token bucket depth/rate: MUST BE >= MTU/B */
105 s64 mtu; 106 s64 mtu;
106 u32 max_size;
107 struct psched_ratecfg rate; 107 struct psched_ratecfg rate;
108 struct psched_ratecfg peak; 108 struct psched_ratecfg peak;
109 bool peak_present;
110 109
111/* Variables */ 110/* Variables */
112 s64 tokens; /* Current number of B tokens */ 111 s64 tokens; /* Current number of B tokens */
@@ -222,6 +221,11 @@ static unsigned int tbf_drop(struct Qdisc *sch)
222 return len; 221 return len;
223} 222}
224 223
224static bool tbf_peak_present(const struct tbf_sched_data *q)
225{
226 return q->peak.rate_bytes_ps;
227}
228
225static struct sk_buff *tbf_dequeue(struct Qdisc *sch) 229static struct sk_buff *tbf_dequeue(struct Qdisc *sch)
226{ 230{
227 struct tbf_sched_data *q = qdisc_priv(sch); 231 struct tbf_sched_data *q = qdisc_priv(sch);
@@ -238,7 +242,7 @@ static struct sk_buff *tbf_dequeue(struct Qdisc *sch)
238 now = ktime_to_ns(ktime_get()); 242 now = ktime_to_ns(ktime_get());
239 toks = min_t(s64, now - q->t_c, q->buffer); 243 toks = min_t(s64, now - q->t_c, q->buffer);
240 244
241 if (q->peak_present) { 245 if (tbf_peak_present(q)) {
242 ptoks = toks + q->ptokens; 246 ptoks = toks + q->ptokens;
243 if (ptoks > q->mtu) 247 if (ptoks > q->mtu)
244 ptoks = q->mtu; 248 ptoks = q->mtu;
@@ -378,6 +382,8 @@ static int tbf_change(struct Qdisc *sch, struct nlattr *opt)
378 } else { 382 } else {
379 max_size = min_t(u64, max_size, psched_ns_t2l(&peak, mtu)); 383 max_size = min_t(u64, max_size, psched_ns_t2l(&peak, mtu));
380 } 384 }
385 } else {
386 memset(&peak, 0, sizeof(peak));
381 } 387 }
382 388
383 if (max_size < psched_mtu(qdisc_dev(sch))) 389 if (max_size < psched_mtu(qdisc_dev(sch)))
@@ -410,12 +416,7 @@ static int tbf_change(struct Qdisc *sch, struct nlattr *opt)
410 q->ptokens = q->mtu; 416 q->ptokens = q->mtu;
411 417
412 memcpy(&q->rate, &rate, sizeof(struct psched_ratecfg)); 418 memcpy(&q->rate, &rate, sizeof(struct psched_ratecfg));
413 if (qopt->peakrate.rate) { 419 memcpy(&q->peak, &peak, sizeof(struct psched_ratecfg));
414 memcpy(&q->peak, &peak, sizeof(struct psched_ratecfg));
415 q->peak_present = true;
416 } else {
417 q->peak_present = false;
418 }
419 420
420 sch_tree_unlock(sch); 421 sch_tree_unlock(sch);
421 err = 0; 422 err = 0;
@@ -458,7 +459,7 @@ static int tbf_dump(struct Qdisc *sch, struct sk_buff *skb)
458 459
459 opt.limit = q->limit; 460 opt.limit = q->limit;
460 psched_ratecfg_getrate(&opt.rate, &q->rate); 461 psched_ratecfg_getrate(&opt.rate, &q->rate);
461 if (q->peak_present) 462 if (tbf_peak_present(q))
462 psched_ratecfg_getrate(&opt.peakrate, &q->peak); 463 psched_ratecfg_getrate(&opt.peakrate, &q->peak);
463 else 464 else
464 memset(&opt.peakrate, 0, sizeof(opt.peakrate)); 465 memset(&opt.peakrate, 0, sizeof(opt.peakrate));
@@ -469,7 +470,7 @@ static int tbf_dump(struct Qdisc *sch, struct sk_buff *skb)
469 if (q->rate.rate_bytes_ps >= (1ULL << 32) && 470 if (q->rate.rate_bytes_ps >= (1ULL << 32) &&
470 nla_put_u64(skb, TCA_TBF_RATE64, q->rate.rate_bytes_ps)) 471 nla_put_u64(skb, TCA_TBF_RATE64, q->rate.rate_bytes_ps))
471 goto nla_put_failure; 472 goto nla_put_failure;
472 if (q->peak_present && 473 if (tbf_peak_present(q) &&
473 q->peak.rate_bytes_ps >= (1ULL << 32) && 474 q->peak.rate_bytes_ps >= (1ULL << 32) &&
474 nla_put_u64(skb, TCA_TBF_PRATE64, q->peak.rate_bytes_ps)) 475 nla_put_u64(skb, TCA_TBF_PRATE64, q->peak.rate_bytes_ps))
475 goto nla_put_failure; 476 goto nla_put_failure;