diff options
author | Aruna-Hewapathirane <aruna.hewapathirane@gmail.com> | 2014-01-11 07:15:59 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-01-14 18:15:25 -0500 |
commit | 63862b5bef7349dd1137e4c70702c67d77565785 (patch) | |
tree | ad50ec4a9d67fd025a29093dc5a4b493fe02e8a5 /net/sched | |
parent | 825edac4e78ded9e621c167a4f47a2392bd9e082 (diff) |
net: replace macros net_random and net_srandom with direct calls to prandom
This patch removes the net_random and net_srandom macros and replaces
them with direct calls to the prandom ones. As new commits only seem to
use prandom_u32 there is no use to keep them around.
This change makes it easier to grep for users of prandom_u32.
Signed-off-by: Aruna-Hewapathirane <aruna.hewapathirane@gmail.com>
Suggested-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
Acked-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/sched')
-rw-r--r-- | net/sched/act_gact.c | 2 | ||||
-rw-r--r-- | net/sched/sch_fq_codel.c | 2 | ||||
-rw-r--r-- | net/sched/sch_hhf.c | 2 | ||||
-rw-r--r-- | net/sched/sch_netem.c | 19 | ||||
-rw-r--r-- | net/sched/sch_pie.c | 2 | ||||
-rw-r--r-- | net/sched/sch_sfb.c | 4 | ||||
-rw-r--r-- | net/sched/sch_sfq.c | 6 |
7 files changed, 19 insertions, 18 deletions
diff --git a/net/sched/act_gact.c b/net/sched/act_gact.c index f26e6b890cc7..31333073cd80 100644 --- a/net/sched/act_gact.c +++ b/net/sched/act_gact.c | |||
@@ -29,7 +29,7 @@ static struct tcf_hashinfo gact_hash_info; | |||
29 | #ifdef CONFIG_GACT_PROB | 29 | #ifdef CONFIG_GACT_PROB |
30 | static int gact_net_rand(struct tcf_gact *gact) | 30 | static int gact_net_rand(struct tcf_gact *gact) |
31 | { | 31 | { |
32 | if (!gact->tcfg_pval || net_random() % gact->tcfg_pval) | 32 | if (!gact->tcfg_pval || prandom_u32() % gact->tcfg_pval) |
33 | return gact->tcf_action; | 33 | return gact->tcf_action; |
34 | return gact->tcfg_paction; | 34 | return gact->tcfg_paction; |
35 | } | 35 | } |
diff --git a/net/sched/sch_fq_codel.c b/net/sched/sch_fq_codel.c index 55786283a3df..ba5bc929eac7 100644 --- a/net/sched/sch_fq_codel.c +++ b/net/sched/sch_fq_codel.c | |||
@@ -390,7 +390,7 @@ static int fq_codel_init(struct Qdisc *sch, struct nlattr *opt) | |||
390 | sch->limit = 10*1024; | 390 | sch->limit = 10*1024; |
391 | q->flows_cnt = 1024; | 391 | q->flows_cnt = 1024; |
392 | q->quantum = psched_mtu(qdisc_dev(sch)); | 392 | q->quantum = psched_mtu(qdisc_dev(sch)); |
393 | q->perturbation = net_random(); | 393 | q->perturbation = prandom_u32(); |
394 | INIT_LIST_HEAD(&q->new_flows); | 394 | INIT_LIST_HEAD(&q->new_flows); |
395 | INIT_LIST_HEAD(&q->old_flows); | 395 | INIT_LIST_HEAD(&q->old_flows); |
396 | codel_params_init(&q->cparams); | 396 | codel_params_init(&q->cparams); |
diff --git a/net/sched/sch_hhf.c b/net/sched/sch_hhf.c index 1cf84a9e13aa..647680b1c625 100644 --- a/net/sched/sch_hhf.c +++ b/net/sched/sch_hhf.c | |||
@@ -607,7 +607,7 @@ static int hhf_init(struct Qdisc *sch, struct nlattr *opt) | |||
607 | 607 | ||
608 | sch->limit = 1000; | 608 | sch->limit = 1000; |
609 | q->quantum = psched_mtu(qdisc_dev(sch)); | 609 | q->quantum = psched_mtu(qdisc_dev(sch)); |
610 | q->perturbation = net_random(); | 610 | q->perturbation = prandom_u32(); |
611 | INIT_LIST_HEAD(&q->new_buckets); | 611 | INIT_LIST_HEAD(&q->new_buckets); |
612 | INIT_LIST_HEAD(&q->old_buckets); | 612 | INIT_LIST_HEAD(&q->old_buckets); |
613 | 613 | ||
diff --git a/net/sched/sch_netem.c b/net/sched/sch_netem.c index 090a4e3ecd0d..3019c10d6c56 100644 --- a/net/sched/sch_netem.c +++ b/net/sched/sch_netem.c | |||
@@ -169,7 +169,7 @@ static inline struct netem_skb_cb *netem_skb_cb(struct sk_buff *skb) | |||
169 | static void init_crandom(struct crndstate *state, unsigned long rho) | 169 | static void init_crandom(struct crndstate *state, unsigned long rho) |
170 | { | 170 | { |
171 | state->rho = rho; | 171 | state->rho = rho; |
172 | state->last = net_random(); | 172 | state->last = prandom_u32(); |
173 | } | 173 | } |
174 | 174 | ||
175 | /* get_crandom - correlated random number generator | 175 | /* get_crandom - correlated random number generator |
@@ -182,9 +182,9 @@ static u32 get_crandom(struct crndstate *state) | |||
182 | unsigned long answer; | 182 | unsigned long answer; |
183 | 183 | ||
184 | if (state->rho == 0) /* no correlation */ | 184 | if (state->rho == 0) /* no correlation */ |
185 | return net_random(); | 185 | return prandom_u32(); |
186 | 186 | ||
187 | value = net_random(); | 187 | value = prandom_u32(); |
188 | rho = (u64)state->rho + 1; | 188 | rho = (u64)state->rho + 1; |
189 | answer = (value * ((1ull<<32) - rho) + state->last * rho) >> 32; | 189 | answer = (value * ((1ull<<32) - rho) + state->last * rho) >> 32; |
190 | state->last = answer; | 190 | state->last = answer; |
@@ -198,7 +198,7 @@ static u32 get_crandom(struct crndstate *state) | |||
198 | static bool loss_4state(struct netem_sched_data *q) | 198 | static bool loss_4state(struct netem_sched_data *q) |
199 | { | 199 | { |
200 | struct clgstate *clg = &q->clg; | 200 | struct clgstate *clg = &q->clg; |
201 | u32 rnd = net_random(); | 201 | u32 rnd = prandom_u32(); |
202 | 202 | ||
203 | /* | 203 | /* |
204 | * Makes a comparison between rnd and the transition | 204 | * Makes a comparison between rnd and the transition |
@@ -264,15 +264,15 @@ static bool loss_gilb_ell(struct netem_sched_data *q) | |||
264 | 264 | ||
265 | switch (clg->state) { | 265 | switch (clg->state) { |
266 | case 1: | 266 | case 1: |
267 | if (net_random() < clg->a1) | 267 | if (prandom_u32() < clg->a1) |
268 | clg->state = 2; | 268 | clg->state = 2; |
269 | if (net_random() < clg->a4) | 269 | if (prandom_u32() < clg->a4) |
270 | return true; | 270 | return true; |
271 | break; | 271 | break; |
272 | case 2: | 272 | case 2: |
273 | if (net_random() < clg->a2) | 273 | if (prandom_u32() < clg->a2) |
274 | clg->state = 1; | 274 | clg->state = 1; |
275 | if (net_random() > clg->a3) | 275 | if (prandom_u32() > clg->a3) |
276 | return true; | 276 | return true; |
277 | } | 277 | } |
278 | 278 | ||
@@ -457,7 +457,8 @@ static int netem_enqueue(struct sk_buff *skb, struct Qdisc *sch) | |||
457 | skb_checksum_help(skb))) | 457 | skb_checksum_help(skb))) |
458 | return qdisc_drop(skb, sch); | 458 | return qdisc_drop(skb, sch); |
459 | 459 | ||
460 | skb->data[net_random() % skb_headlen(skb)] ^= 1<<(net_random() % 8); | 460 | skb->data[prandom_u32() % skb_headlen(skb)] ^= |
461 | 1<<(prandom_u32() % 8); | ||
461 | } | 462 | } |
462 | 463 | ||
463 | if (unlikely(skb_queue_len(&sch->q) >= sch->limit)) | 464 | if (unlikely(skb_queue_len(&sch->q) >= sch->limit)) |
diff --git a/net/sched/sch_pie.c b/net/sched/sch_pie.c index fe65340c8eb4..a255d0200a59 100644 --- a/net/sched/sch_pie.c +++ b/net/sched/sch_pie.c | |||
@@ -122,7 +122,7 @@ static bool drop_early(struct Qdisc *sch, u32 packet_size) | |||
122 | else | 122 | else |
123 | local_prob = q->vars.prob; | 123 | local_prob = q->vars.prob; |
124 | 124 | ||
125 | rnd = net_random(); | 125 | rnd = prandom_u32(); |
126 | if (rnd < local_prob) | 126 | if (rnd < local_prob) |
127 | return true; | 127 | return true; |
128 | 128 | ||
diff --git a/net/sched/sch_sfb.c b/net/sched/sch_sfb.c index 30ea4674cabd..9b0f7093d970 100644 --- a/net/sched/sch_sfb.c +++ b/net/sched/sch_sfb.c | |||
@@ -220,7 +220,7 @@ static u32 sfb_compute_qlen(u32 *prob_r, u32 *avgpm_r, const struct sfb_sched_da | |||
220 | 220 | ||
221 | static void sfb_init_perturbation(u32 slot, struct sfb_sched_data *q) | 221 | static void sfb_init_perturbation(u32 slot, struct sfb_sched_data *q) |
222 | { | 222 | { |
223 | q->bins[slot].perturbation = net_random(); | 223 | q->bins[slot].perturbation = prandom_u32(); |
224 | } | 224 | } |
225 | 225 | ||
226 | static void sfb_swap_slot(struct sfb_sched_data *q) | 226 | static void sfb_swap_slot(struct sfb_sched_data *q) |
@@ -381,7 +381,7 @@ static int sfb_enqueue(struct sk_buff *skb, struct Qdisc *sch) | |||
381 | goto enqueue; | 381 | goto enqueue; |
382 | } | 382 | } |
383 | 383 | ||
384 | r = net_random() & SFB_MAX_PROB; | 384 | r = prandom_u32() & SFB_MAX_PROB; |
385 | 385 | ||
386 | if (unlikely(r < p_min)) { | 386 | if (unlikely(r < p_min)) { |
387 | if (unlikely(p_min > SFB_MAX_PROB / 2)) { | 387 | if (unlikely(p_min > SFB_MAX_PROB / 2)) { |
diff --git a/net/sched/sch_sfq.c b/net/sched/sch_sfq.c index 76f01e0258df..87317ff0b4ec 100644 --- a/net/sched/sch_sfq.c +++ b/net/sched/sch_sfq.c | |||
@@ -629,7 +629,7 @@ static void sfq_perturbation(unsigned long arg) | |||
629 | spinlock_t *root_lock = qdisc_lock(qdisc_root_sleeping(sch)); | 629 | spinlock_t *root_lock = qdisc_lock(qdisc_root_sleeping(sch)); |
630 | 630 | ||
631 | spin_lock(root_lock); | 631 | spin_lock(root_lock); |
632 | q->perturbation = net_random(); | 632 | q->perturbation = prandom_u32(); |
633 | if (!q->filter_list && q->tail) | 633 | if (!q->filter_list && q->tail) |
634 | sfq_rehash(sch); | 634 | sfq_rehash(sch); |
635 | spin_unlock(root_lock); | 635 | spin_unlock(root_lock); |
@@ -698,7 +698,7 @@ static int sfq_change(struct Qdisc *sch, struct nlattr *opt) | |||
698 | del_timer(&q->perturb_timer); | 698 | del_timer(&q->perturb_timer); |
699 | if (q->perturb_period) { | 699 | if (q->perturb_period) { |
700 | mod_timer(&q->perturb_timer, jiffies + q->perturb_period); | 700 | mod_timer(&q->perturb_timer, jiffies + q->perturb_period); |
701 | q->perturbation = net_random(); | 701 | q->perturbation = prandom_u32(); |
702 | } | 702 | } |
703 | sch_tree_unlock(sch); | 703 | sch_tree_unlock(sch); |
704 | kfree(p); | 704 | kfree(p); |
@@ -759,7 +759,7 @@ static int sfq_init(struct Qdisc *sch, struct nlattr *opt) | |||
759 | q->quantum = psched_mtu(qdisc_dev(sch)); | 759 | q->quantum = psched_mtu(qdisc_dev(sch)); |
760 | q->scaled_quantum = SFQ_ALLOT_SIZE(q->quantum); | 760 | q->scaled_quantum = SFQ_ALLOT_SIZE(q->quantum); |
761 | q->perturb_period = 0; | 761 | q->perturb_period = 0; |
762 | q->perturbation = net_random(); | 762 | q->perturbation = prandom_u32(); |
763 | 763 | ||
764 | if (opt) { | 764 | if (opt) { |
765 | int err = sfq_change(sch, opt); | 765 | int err = sfq_change(sch, opt); |