Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'sch-action-tstamp'

Jamal Hadi Salim says:

====================
net sched action timestamp improvements

Various aggregations of duplicated code, fixes and introduction of firstused
timestamp

v2: add const for source time info per suggestion from Cong
====================

Signed-off-by: David S. Miller <davem@davemloft.net>

+46 -49
+10
include/net/act_api.h
··· 76 76 77 77 if (tm->lastuse != now) 78 78 tm->lastuse = now; 79 + if (unlikely(!tm->firstuse)) 80 + tm->firstuse = now; 81 + } 82 + 83 + static inline void tcf_tm_dump(struct tcf_t *dtm, const struct tcf_t *stm) 84 + { 85 + dtm->install = jiffies_to_clock_t(jiffies - stm->install); 86 + dtm->lastuse = jiffies_to_clock_t(jiffies - stm->lastuse); 87 + dtm->firstuse = jiffies_to_clock_t(jiffies - stm->firstuse); 88 + dtm->expires = jiffies_to_clock_t(stm->expires); 79 89 } 80 90 81 91 struct tc_action {
+1
include/uapi/linux/pkt_cls.h
··· 124 124 __u64 install; 125 125 __u64 lastuse; 126 126 __u64 expires; 127 + __u64 firstuse; 127 128 }; 128 129 129 130 struct tc_cnt {
+1
net/sched/act_api.c
··· 283 283 p->tcfc_index = index ? index : tcf_hash_new_index(tn); 284 284 p->tcfc_tm.install = jiffies; 285 285 p->tcfc_tm.lastuse = jiffies; 286 + p->tcfc_tm.firstuse = 0; 286 287 if (est) { 287 288 err = gen_new_estimator(&p->tcfc_bstats, p->cpu_bstats, 288 289 &p->tcfc_rate_est,
+1 -4
net/sched/act_bpf.c
··· 154 154 if (ret) 155 155 goto nla_put_failure; 156 156 157 - tm.install = jiffies_to_clock_t(jiffies - prog->tcf_tm.install); 158 - tm.lastuse = jiffies_to_clock_t(jiffies - prog->tcf_tm.lastuse); 159 - tm.expires = jiffies_to_clock_t(prog->tcf_tm.expires); 160 - 157 + tcf_tm_dump(&tm, &prog->tcf_tm); 161 158 if (nla_put_64bit(skb, TCA_ACT_BPF_TM, sizeof(tm), &tm, 162 159 TCA_ACT_BPF_PAD)) 163 160 goto nla_put_failure;
+2 -4
net/sched/act_connmark.c
··· 44 44 int proto; 45 45 46 46 spin_lock(&ca->tcf_lock); 47 - ca->tcf_tm.lastuse = jiffies; 47 + tcf_lastuse_update(&ca->tcf_tm); 48 48 bstats_update(&ca->tcf_bstats, skb); 49 49 50 50 if (skb->protocol == htons(ETH_P_IP)) { ··· 160 160 if (nla_put(skb, TCA_CONNMARK_PARMS, sizeof(opt), &opt)) 161 161 goto nla_put_failure; 162 162 163 - t.install = jiffies_to_clock_t(jiffies - ci->tcf_tm.install); 164 - t.lastuse = jiffies_to_clock_t(jiffies - ci->tcf_tm.lastuse); 165 - t.expires = jiffies_to_clock_t(ci->tcf_tm.expires); 163 + tcf_tm_dump(&t, &ci->tcf_tm); 166 164 if (nla_put_64bit(skb, TCA_CONNMARK_TM, sizeof(t), &t, 167 165 TCA_CONNMARK_PAD)) 168 166 goto nla_put_failure;
+3 -4
net/sched/act_csum.c
··· 501 501 u32 update_flags; 502 502 503 503 spin_lock(&p->tcf_lock); 504 - p->tcf_tm.lastuse = jiffies; 504 + tcf_lastuse_update(&p->tcf_tm); 505 505 bstats_update(&p->tcf_bstats, skb); 506 506 action = p->tcf_action; 507 507 update_flags = p->update_flags; ··· 546 546 547 547 if (nla_put(skb, TCA_CSUM_PARMS, sizeof(opt), &opt)) 548 548 goto nla_put_failure; 549 - t.install = jiffies_to_clock_t(jiffies - p->tcf_tm.install); 550 - t.lastuse = jiffies_to_clock_t(jiffies - p->tcf_tm.lastuse); 551 - t.expires = jiffies_to_clock_t(p->tcf_tm.expires); 549 + 550 + tcf_tm_dump(&t, &p->tcf_tm); 552 551 if (nla_put_64bit(skb, TCA_CSUM_TM, sizeof(t), &t, TCA_CSUM_PAD)) 553 552 goto nla_put_failure; 554 553
+1 -3
net/sched/act_gact.c
··· 188 188 goto nla_put_failure; 189 189 } 190 190 #endif 191 - t.install = jiffies_to_clock_t(jiffies - gact->tcf_tm.install); 192 - t.lastuse = jiffies_to_clock_t(jiffies - gact->tcf_tm.lastuse); 193 - t.expires = jiffies_to_clock_t(gact->tcf_tm.expires); 191 + tcf_tm_dump(&t, &gact->tcf_tm); 194 192 if (nla_put_64bit(skb, TCA_GACT_TM, sizeof(t), &t, TCA_GACT_PAD)) 195 193 goto nla_put_failure; 196 194 return skb->len;
+4 -6
net/sched/act_ife.c
··· 553 553 if (nla_put(skb, TCA_IFE_PARMS, sizeof(opt), &opt)) 554 554 goto nla_put_failure; 555 555 556 - t.install = jiffies_to_clock_t(jiffies - ife->tcf_tm.install); 557 - t.lastuse = jiffies_to_clock_t(jiffies - ife->tcf_tm.lastuse); 558 - t.expires = jiffies_to_clock_t(ife->tcf_tm.expires); 556 + tcf_tm_dump(&t, &ife->tcf_tm); 559 557 if (nla_put_64bit(skb, TCA_IFE_TM, sizeof(t), &t, TCA_IFE_PAD)) 560 558 goto nla_put_failure; 561 559 ··· 621 623 622 624 spin_lock(&ife->tcf_lock); 623 625 bstats_update(&ife->tcf_bstats, skb); 624 - ife->tcf_tm.lastuse = jiffies; 626 + tcf_lastuse_update(&ife->tcf_tm); 625 627 spin_unlock(&ife->tcf_lock); 626 628 627 629 ifehdrln = ntohs(ifehdrln); ··· 709 711 710 712 spin_lock(&ife->tcf_lock); 711 713 bstats_update(&ife->tcf_bstats, skb); 712 - ife->tcf_tm.lastuse = jiffies; 714 + tcf_lastuse_update(&ife->tcf_tm); 713 715 714 716 if (!metalen) { /* no metadata to send */ 715 717 /* abuse overlimits to count when we allow packet ··· 800 802 pr_info_ratelimited("unknown failure(policy neither de/encode\n"); 801 803 spin_lock(&ife->tcf_lock); 802 804 bstats_update(&ife->tcf_bstats, skb); 803 - ife->tcf_tm.lastuse = jiffies; 805 + tcf_lastuse_update(&ife->tcf_tm); 804 806 ife->tcf_qstats.drops++; 805 807 spin_unlock(&ife->tcf_lock); 806 808
+4 -4
net/sched/act_ipt.c
··· 212 212 213 213 spin_lock(&ipt->tcf_lock); 214 214 215 - ipt->tcf_tm.lastuse = jiffies; 215 + tcf_lastuse_update(&ipt->tcf_tm); 216 216 bstats_update(&ipt->tcf_bstats, skb); 217 217 218 218 /* yes, we have to worry about both in and out dev ··· 277 277 nla_put(skb, TCA_IPT_CNT, sizeof(struct tc_cnt), &c) || 278 278 nla_put_string(skb, TCA_IPT_TABLE, ipt->tcfi_tname)) 279 279 goto nla_put_failure; 280 - tm.install = jiffies_to_clock_t(jiffies - ipt->tcf_tm.install); 281 - tm.lastuse = jiffies_to_clock_t(jiffies - ipt->tcf_tm.lastuse); 282 - tm.expires = jiffies_to_clock_t(ipt->tcf_tm.expires); 280 + 281 + tcf_tm_dump(&tm, &ipt->tcf_tm); 283 282 if (nla_put_64bit(skb, TCA_IPT_TM, sizeof(tm), &tm, TCA_IPT_PAD)) 284 283 goto nla_put_failure; 284 + 285 285 kfree(t); 286 286 return skb->len; 287 287
+2 -4
net/sched/act_mirred.c
··· 157 157 u32 at; 158 158 159 159 tcf_lastuse_update(&m->tcf_tm); 160 - 161 160 bstats_cpu_update(this_cpu_ptr(m->common.cpu_bstats), skb); 162 161 163 162 rcu_read_lock(); ··· 218 219 219 220 if (nla_put(skb, TCA_MIRRED_PARMS, sizeof(opt), &opt)) 220 221 goto nla_put_failure; 221 - t.install = jiffies_to_clock_t(jiffies - m->tcf_tm.install); 222 - t.lastuse = jiffies_to_clock_t(jiffies - m->tcf_tm.lastuse); 223 - t.expires = jiffies_to_clock_t(m->tcf_tm.expires); 222 + 223 + tcf_tm_dump(&t, &m->tcf_tm); 224 224 if (nla_put_64bit(skb, TCA_MIRRED_TM, sizeof(t), &t, TCA_MIRRED_PAD)) 225 225 goto nla_put_failure; 226 226 return skb->len;
+3 -4
net/sched/act_nat.c
··· 103 103 104 104 spin_lock(&p->tcf_lock); 105 105 106 - p->tcf_tm.lastuse = jiffies; 106 + tcf_lastuse_update(&p->tcf_tm); 107 107 old_addr = p->old_addr; 108 108 new_addr = p->new_addr; 109 109 mask = p->mask; ··· 264 264 265 265 if (nla_put(skb, TCA_NAT_PARMS, sizeof(opt), &opt)) 266 266 goto nla_put_failure; 267 - t.install = jiffies_to_clock_t(jiffies - p->tcf_tm.install); 268 - t.lastuse = jiffies_to_clock_t(jiffies - p->tcf_tm.lastuse); 269 - t.expires = jiffies_to_clock_t(p->tcf_tm.expires); 267 + 268 + tcf_tm_dump(&t, &p->tcf_tm); 270 269 if (nla_put_64bit(skb, TCA_NAT_TM, sizeof(t), &t, TCA_NAT_PAD)) 271 270 goto nla_put_failure; 272 271
+4 -4
net/sched/act_pedit.c
··· 121 121 122 122 spin_lock(&p->tcf_lock); 123 123 124 - p->tcf_tm.lastuse = jiffies; 124 + tcf_lastuse_update(&p->tcf_tm); 125 125 126 126 if (p->tcfp_nkeys > 0) { 127 127 struct tc_pedit_key *tkey = p->tcfp_keys; ··· 200 200 201 201 if (nla_put(skb, TCA_PEDIT_PARMS, s, opt)) 202 202 goto nla_put_failure; 203 - t.install = jiffies_to_clock_t(jiffies - p->tcf_tm.install); 204 - t.lastuse = jiffies_to_clock_t(jiffies - p->tcf_tm.lastuse); 205 - t.expires = jiffies_to_clock_t(p->tcf_tm.expires); 203 + 204 + tcf_tm_dump(&t, &p->tcf_tm); 206 205 if (nla_put_64bit(skb, TCA_PEDIT_TM, sizeof(t), &t, TCA_PEDIT_PAD)) 207 206 goto nla_put_failure; 207 + 208 208 kfree(opt); 209 209 return skb->len; 210 210
+2
net/sched/act_police.c
··· 241 241 tcf_hash_new_index(tn); 242 242 police->tcf_tm.install = jiffies; 243 243 police->tcf_tm.lastuse = jiffies; 244 + police->tcf_tm.firstuse = 0; 244 245 h = tcf_hash(police->tcf_index, POL_TAB_MASK); 245 246 spin_lock_bh(&hinfo->lock); 246 247 hlist_add_head(&police->tcf_head, &hinfo->htab[h]); ··· 348 347 349 348 t.install = jiffies_to_clock_t(jiffies - police->tcf_tm.install); 350 349 t.lastuse = jiffies_to_clock_t(jiffies - police->tcf_tm.lastuse); 350 + t.firstuse = jiffies_to_clock_t(jiffies - police->tcf_tm.firstuse); 351 351 t.expires = jiffies_to_clock_t(police->tcf_tm.expires); 352 352 if (nla_put_64bit(skb, TCA_POLICE_TM, sizeof(t), &t, TCA_POLICE_PAD)) 353 353 goto nla_put_failure;
+3 -4
net/sched/act_simple.c
··· 35 35 struct tcf_defact *d = a->priv; 36 36 37 37 spin_lock(&d->tcf_lock); 38 - d->tcf_tm.lastuse = jiffies; 38 + tcf_lastuse_update(&d->tcf_tm); 39 39 bstats_update(&d->tcf_bstats, skb); 40 40 41 41 /* print policy string followed by _ then packet count ··· 158 158 if (nla_put(skb, TCA_DEF_PARMS, sizeof(opt), &opt) || 159 159 nla_put_string(skb, TCA_DEF_DATA, d->tcfd_defdata)) 160 160 goto nla_put_failure; 161 - t.install = jiffies_to_clock_t(jiffies - d->tcf_tm.install); 162 - t.lastuse = jiffies_to_clock_t(jiffies - d->tcf_tm.lastuse); 163 - t.expires = jiffies_to_clock_t(d->tcf_tm.expires); 161 + 162 + tcf_tm_dump(&t, &d->tcf_tm); 164 163 if (nla_put_64bit(skb, TCA_DEF_TM, sizeof(t), &t, TCA_DEF_PAD)) 165 164 goto nla_put_failure; 166 165 return skb->len;
+3 -4
net/sched/act_skbedit.c
··· 37 37 struct tcf_skbedit *d = a->priv; 38 38 39 39 spin_lock(&d->tcf_lock); 40 - d->tcf_tm.lastuse = jiffies; 40 + tcf_lastuse_update(&d->tcf_tm); 41 41 bstats_update(&d->tcf_bstats, skb); 42 42 43 43 if (d->flags & SKBEDIT_F_PRIORITY) ··· 168 168 nla_put(skb, TCA_SKBEDIT_MARK, sizeof(d->mark), 169 169 &d->mark)) 170 170 goto nla_put_failure; 171 - t.install = jiffies_to_clock_t(jiffies - d->tcf_tm.install); 172 - t.lastuse = jiffies_to_clock_t(jiffies - d->tcf_tm.lastuse); 173 - t.expires = jiffies_to_clock_t(d->tcf_tm.expires); 171 + 172 + tcf_tm_dump(&t, &d->tcf_tm); 174 173 if (nla_put_64bit(skb, TCA_SKBEDIT_TM, sizeof(t), &t, TCA_SKBEDIT_PAD)) 175 174 goto nla_put_failure; 176 175 return skb->len;
+2 -4
net/sched/act_vlan.c
··· 31 31 int err; 32 32 33 33 spin_lock(&v->tcf_lock); 34 - v->tcf_tm.lastuse = jiffies; 34 + tcf_lastuse_update(&v->tcf_tm); 35 35 bstats_update(&v->tcf_bstats, skb); 36 36 action = v->tcf_action; 37 37 ··· 182 182 nla_put_be16(skb, TCA_VLAN_PUSH_VLAN_PROTOCOL, v->tcfv_push_proto))) 183 183 goto nla_put_failure; 184 184 185 - t.install = jiffies_to_clock_t(jiffies - v->tcf_tm.install); 186 - t.lastuse = jiffies_to_clock_t(jiffies - v->tcf_tm.lastuse); 187 - t.expires = jiffies_to_clock_t(v->tcf_tm.expires); 185 + tcf_tm_dump(&t, &v->tcf_tm); 188 186 if (nla_put_64bit(skb, TCA_VLAN_TM, sizeof(t), &t, TCA_VLAN_PAD)) 189 187 goto nla_put_failure; 190 188 return skb->len;