Skip to content

Commit d2de875

Browse files
edumazetdavem330
authored andcommitted
net: use ktime_get_ns() and ktime_get_real_ns() helpers
ktime_get_ns() replaces ktime_to_ns(ktime_get()) ktime_get_real_ns() replaces ktime_to_ns(ktime_get_real()) Signed-off-by: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 3f8a2b7 commit d2de875

10 files changed

Lines changed: 18 additions & 18 deletions

File tree

‎include/net/codel.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ typedef s32 codel_tdiff_t;
6666

6767
static inline codel_time_t codel_get_time(void)
6868
{
69-
u64 ns = ktime_to_ns(ktime_get());
69+
u64 ns = ktime_get_ns();
7070

7171
return ns >> CODEL_SHIFT;
7272
}

‎include/net/pkt_sched.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ typedef long psched_tdiff_t;
5050

5151
static inline psched_time_t psched_get_time(void)
5252
{
53-
return PSCHED_NS2TICKS(ktime_to_ns(ktime_get()));
53+
return PSCHED_NS2TICKS(ktime_get_ns());
5454
}
5555

5656
static inline psched_tdiff_t

‎net/core/secure_seq.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ static u32 seq_scale(u32 seq)
3535
* overlaps less than one time per MSL (2 minutes).
3636
* Choosing a clock of 64 ns period is OK. (period of 274 s)
3737
*/
38-
return seq + (ktime_to_ns(ktime_get_real()) >> 6);
38+
return seq + (ktime_get_real_ns() >> 6);
3939
}
4040
#endif
4141

@@ -135,7 +135,7 @@ u64 secure_dccp_sequence_number(__be32 saddr, __be32 daddr,
135135
md5_transform(hash, net_secret);
136136

137137
seq = hash[0] | (((u64)hash[1]) << 32);
138-
seq += ktime_to_ns(ktime_get_real());
138+
seq += ktime_get_real_ns();
139139
seq &= (1ull << 48) - 1;
140140

141141
return seq;
@@ -163,7 +163,7 @@ u64 secure_dccpv6_sequence_number(__be32 *saddr, __be32 *daddr,
163163
md5_transform(hash, secret);
164164

165165
seq = hash[0] | (((u64)hash[1]) << 32);
166-
seq += ktime_to_ns(ktime_get_real());
166+
seq += ktime_get_real_ns();
167167
seq &= (1ull << 48) - 1;
168168

169169
return seq;

‎net/netfilter/nf_conntrack_core.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ bool nf_ct_delete(struct nf_conn *ct, u32 portid, int report)
358358

359359
tstamp = nf_conn_tstamp_find(ct);
360360
if (tstamp && tstamp->stop == 0)
361-
tstamp->stop = ktime_to_ns(ktime_get_real());
361+
tstamp->stop = ktime_get_real_ns();
362362

363363
if (nf_ct_is_dying(ct))
364364
goto delete;

‎net/netfilter/nf_conntrack_netlink.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1737,7 +1737,7 @@ ctnetlink_create_conntrack(struct net *net, u16 zone,
17371737
}
17381738
tstamp = nf_conn_tstamp_find(ct);
17391739
if (tstamp)
1740-
tstamp->start = ktime_to_ns(ktime_get_real());
1740+
tstamp->start = ktime_get_real_ns();
17411741

17421742
err = nf_conntrack_hash_check_insert(ct);
17431743
if (err < 0)

‎net/netfilter/nf_conntrack_standalone.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ static void *ct_seq_start(struct seq_file *seq, loff_t *pos)
101101
{
102102
struct ct_iter_state *st = seq->private;
103103

104-
st->time_now = ktime_to_ns(ktime_get_real());
104+
st->time_now = ktime_get_real_ns();
105105
rcu_read_lock();
106106
return ct_get_idx(seq, *pos);
107107
}

‎net/sched/act_police.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ static int tcf_act_police_locate(struct net *net, struct nlattr *nla,
231231
if (ret != ACT_P_CREATED)
232232
return ret;
233233

234-
police->tcfp_t_c = ktime_to_ns(ktime_get());
234+
police->tcfp_t_c = ktime_get_ns();
235235
police->tcf_index = parm->index ? parm->index :
236236
tcf_hash_new_index(hinfo);
237237
h = tcf_hash(police->tcf_index, POL_TAB_MASK);
@@ -279,7 +279,7 @@ static int tcf_act_police(struct sk_buff *skb, const struct tc_action *a,
279279
return police->tcfp_result;
280280
}
281281

282-
now = ktime_to_ns(ktime_get());
282+
now = ktime_get_ns();
283283
toks = min_t(s64, now - police->tcfp_t_c,
284284
police->tcfp_burst);
285285
if (police->peak_present) {

‎net/sched/sch_fq.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ static void fq_check_throttled(struct fq_sched_data *q, u64 now)
416416
static struct sk_buff *fq_dequeue(struct Qdisc *sch)
417417
{
418418
struct fq_sched_data *q = qdisc_priv(sch);
419-
u64 now = ktime_to_ns(ktime_get());
419+
u64 now = ktime_get_ns();
420420
struct fq_flow_head *head;
421421
struct sk_buff *skb;
422422
struct fq_flow *f;
@@ -787,7 +787,7 @@ static int fq_dump(struct Qdisc *sch, struct sk_buff *skb)
787787
static int fq_dump_stats(struct Qdisc *sch, struct gnet_dump *d)
788788
{
789789
struct fq_sched_data *q = qdisc_priv(sch);
790-
u64 now = ktime_to_ns(ktime_get());
790+
u64 now = ktime_get_ns();
791791
struct tc_fq_qd_stats st = {
792792
.gc_flows = q->stat_gc_flows,
793793
.highprio_packets = q->stat_internal_packets,

‎net/sched/sch_htb.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -895,7 +895,7 @@ static struct sk_buff *htb_dequeue(struct Qdisc *sch)
895895

896896
if (!sch->q.qlen)
897897
goto fin;
898-
q->now = ktime_to_ns(ktime_get());
898+
q->now = ktime_get_ns();
899899
start_at = jiffies;
900900

901901
next_event = q->now + 5LLU * NSEC_PER_SEC;
@@ -1225,7 +1225,7 @@ static void htb_parent_to_leaf(struct htb_sched *q, struct htb_class *cl,
12251225
parent->un.leaf.q = new_q ? new_q : &noop_qdisc;
12261226
parent->tokens = parent->buffer;
12271227
parent->ctokens = parent->cbuffer;
1228-
parent->t_c = ktime_to_ns(ktime_get());
1228+
parent->t_c = ktime_get_ns();
12291229
parent->cmode = HTB_CAN_SEND;
12301230
}
12311231

@@ -1455,7 +1455,7 @@ static int htb_change_class(struct Qdisc *sch, u32 classid,
14551455
cl->tokens = PSCHED_TICKS2NS(hopt->buffer);
14561456
cl->ctokens = PSCHED_TICKS2NS(hopt->cbuffer);
14571457
cl->mbuffer = 60ULL * NSEC_PER_SEC; /* 1min */
1458-
cl->t_c = ktime_to_ns(ktime_get());
1458+
cl->t_c = ktime_get_ns();
14591459
cl->cmode = HTB_CAN_SEND;
14601460

14611461
/* attach to the hash list and parent's family */

‎net/sched/sch_tbf.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ static struct sk_buff *tbf_dequeue(struct Qdisc *sch)
239239
s64 ptoks = 0;
240240
unsigned int len = qdisc_pkt_len(skb);
241241

242-
now = ktime_to_ns(ktime_get());
242+
now = ktime_get_ns();
243243
toks = min_t(s64, now - q->t_c, q->buffer);
244244

245245
if (tbf_peak_present(q)) {
@@ -292,7 +292,7 @@ static void tbf_reset(struct Qdisc *sch)
292292

293293
qdisc_reset(q->qdisc);
294294
sch->q.qlen = 0;
295-
q->t_c = ktime_to_ns(ktime_get());
295+
q->t_c = ktime_get_ns();
296296
q->tokens = q->buffer;
297297
q->ptokens = q->mtu;
298298
qdisc_watchdog_cancel(&q->watchdog);
@@ -431,7 +431,7 @@ static int tbf_init(struct Qdisc *sch, struct nlattr *opt)
431431
if (opt == NULL)
432432
return -EINVAL;
433433

434-
q->t_c = ktime_to_ns(ktime_get());
434+
q->t_c = ktime_get_ns();
435435
qdisc_watchdog_init(&q->watchdog, sch);
436436
q->qdisc = &noop_qdisc;
437437

0 commit comments

Comments
 (0)