From patchwork Mon Dec 24 02:14:09 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akinobu Mita X-Patchwork-Id: 208012 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id B5EDF2C0087 for ; Mon, 24 Dec 2012 13:18:00 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753010Ab2LXCRl (ORCPT ); Sun, 23 Dec 2012 21:17:41 -0500 Received: from mail-da0-f44.google.com ([209.85.210.44]:39052 "EHLO mail-da0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752978Ab2LXCPS (ORCPT ); Sun, 23 Dec 2012 21:15:18 -0500 Received: by mail-da0-f44.google.com with SMTP id z20so2952790dae.17 for ; Sun, 23 Dec 2012 18:15:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=gSaKiM6rN2JHuUyX4xbMRgNKjzQplEuER/do9aMOTTI=; b=EuIdlfgTd+E0vMzK/dsCOZuIUVLVlOz7K3OVE+79Nq9LjkXk9eFGZVyQvl+wH5ypog gB9tN+Azvxfodist2RTIBDrvw2M+rU4MqxNm9UcA0CdKPttS9GSyC+mLnmE1WUpcwVZI mwHcm8vRwaICzCA6jY/RssRB3E7qO5gqXi8xmZJYiMcojcClZqRsQU1zFxh1njAGDnit X30GMmyywD+arqwVOnPJzQFlhqQx0RZleomkH5iENv8J6anyd1MpIjoIauTExAL78Rar 6gD14JV4wNLTycVd1lr7+llvvqNAzdeS6QXHmBu893GGb50V6jkl9elT9C/7QKzkRj2c OLoA== X-Received: by 10.68.240.36 with SMTP id vx4mr62303416pbc.90.1356315317899; Sun, 23 Dec 2012 18:15:17 -0800 (PST) Received: from localhost.localdomain (p2126-ipbf3106hodogaya.kanagawa.ocn.ne.jp. [114.149.157.126]) by mx.google.com with ESMTPS id wr4sm11379909pbc.72.2012.12.23.18.15.15 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 23 Dec 2012 18:15:17 -0800 (PST) From: Akinobu Mita To: linux-kernel@vger.kernel.org, akpm@linux-foundation.org Cc: Akinobu Mita , Stephen Hemminger , Jamal Hadi Salim , "David S. Miller" , netem@lists.linux-foundation.org, netdev@vger.kernel.org Subject: [PATCH 22/29] net/sched: rename random32() and net_random() to prandom_u32() Date: Mon, 24 Dec 2012 11:14:09 +0900 Message-Id: <1356315256-6572-23-git-send-email-akinobu.mita@gmail.com> X-Mailer: git-send-email 1.7.11.7 In-Reply-To: <1356315256-6572-1-git-send-email-akinobu.mita@gmail.com> References: <1356315256-6572-1-git-send-email-akinobu.mita@gmail.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Use more preferable function name which implies using a pseudo-random number generator. Signed-off-by: Akinobu Mita Cc: Stephen Hemminger Cc: Jamal Hadi Salim Cc: "David S. Miller" Cc: netem@lists.linux-foundation.org Cc: netdev@vger.kernel.org Cc: netdev@vger.kernel.org --- net/sched/act_gact.c | 2 +- net/sched/sch_choke.c | 2 +- net/sched/sch_fq_codel.c | 2 +- net/sched/sch_netem.c | 19 ++++++++++--------- net/sched/sch_sfb.c | 4 ++-- net/sched/sch_sfq.c | 6 +++--- 6 files changed, 18 insertions(+), 17 deletions(-) diff --git a/net/sched/act_gact.c b/net/sched/act_gact.c index 05d60859..d3ceed8 100644 --- a/net/sched/act_gact.c +++ b/net/sched/act_gact.c @@ -37,7 +37,7 @@ static struct tcf_hashinfo gact_hash_info = { #ifdef CONFIG_GACT_PROB static int gact_net_rand(struct tcf_gact *gact) { - if (!gact->tcfg_pval || net_random() % gact->tcfg_pval) + if (!gact->tcfg_pval || prandom_u32() % gact->tcfg_pval) return gact->tcf_action; return gact->tcfg_paction; } diff --git a/net/sched/sch_choke.c b/net/sched/sch_choke.c index cc37dd5..ef53ab8 100644 --- a/net/sched/sch_choke.c +++ b/net/sched/sch_choke.c @@ -80,7 +80,7 @@ struct choke_sched_data { /* deliver a random number between 0 and N - 1 */ static u32 random_N(unsigned int N) { - return reciprocal_divide(random32(), N); + return reciprocal_divide(prandom_u32(), N); } /* number of elements in queue including holes */ diff --git a/net/sched/sch_fq_codel.c b/net/sched/sch_fq_codel.c index 4e606fc..93d7f41 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) sch->limit = 10*1024; q->flows_cnt = 1024; q->quantum = psched_mtu(qdisc_dev(sch)); - q->perturbation = net_random(); + q->perturbation = prandom_u32(); INIT_LIST_HEAD(&q->new_flows); INIT_LIST_HEAD(&q->old_flows); codel_params_init(&q->cparams); diff --git a/net/sched/sch_netem.c b/net/sched/sch_netem.c index 298c0dd..e3126e2 100644 --- a/net/sched/sch_netem.c +++ b/net/sched/sch_netem.c @@ -142,7 +142,7 @@ static inline struct netem_skb_cb *netem_skb_cb(struct sk_buff *skb) static void init_crandom(struct crndstate *state, unsigned long rho) { state->rho = rho; - state->last = net_random(); + state->last = prandom_u32(); } /* get_crandom - correlated random number generator @@ -155,9 +155,9 @@ static u32 get_crandom(struct crndstate *state) unsigned long answer; if (state->rho == 0) /* no correlation */ - return net_random(); + return prandom_u32(); - value = net_random(); + value = prandom_u32(); rho = (u64)state->rho + 1; answer = (value * ((1ull<<32) - rho) + state->last * rho) >> 32; state->last = answer; @@ -171,7 +171,7 @@ static u32 get_crandom(struct crndstate *state) static bool loss_4state(struct netem_sched_data *q) { struct clgstate *clg = &q->clg; - u32 rnd = net_random(); + u32 rnd = prandom_u32(); /* * Makes a comparison between rnd and the transition @@ -238,14 +238,14 @@ static bool loss_gilb_ell(struct netem_sched_data *q) switch (clg->state) { case 1: - if (net_random() < clg->a1) + if (prandom_u32() < clg->a1) clg->state = 2; - if (net_random() < clg->a4) + if (prandom_u32() < clg->a4) return true; case 2: - if (net_random() < clg->a2) + if (prandom_u32() < clg->a2) clg->state = 1; - if (clg->a3 > net_random()) + if (clg->a3 > prandom_u32()) return true; } @@ -415,7 +415,8 @@ static int netem_enqueue(struct sk_buff *skb, struct Qdisc *sch) skb_checksum_help(skb))) return qdisc_drop(skb, sch); - skb->data[net_random() % skb_headlen(skb)] ^= 1<<(net_random() % 8); + skb->data[prandom_u32() % skb_headlen(skb)] ^= + 1 << (prandom_u32() % 8); } if (unlikely(skb_queue_len(&sch->q) >= sch->limit)) diff --git a/net/sched/sch_sfb.c b/net/sched/sch_sfb.c index 30ea467..9b0f709 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 static void sfb_init_perturbation(u32 slot, struct sfb_sched_data *q) { - q->bins[slot].perturbation = net_random(); + q->bins[slot].perturbation = prandom_u32(); } 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) goto enqueue; } - r = net_random() & SFB_MAX_PROB; + r = prandom_u32() & SFB_MAX_PROB; if (unlikely(r < p_min)) { if (unlikely(p_min > SFB_MAX_PROB / 2)) { diff --git a/net/sched/sch_sfq.c b/net/sched/sch_sfq.c index d3a1bc2..921130e 100644 --- a/net/sched/sch_sfq.c +++ b/net/sched/sch_sfq.c @@ -627,7 +627,7 @@ static void sfq_perturbation(unsigned long arg) spinlock_t *root_lock = qdisc_lock(qdisc_root_sleeping(sch)); spin_lock(root_lock); - q->perturbation = net_random(); + q->perturbation = prandom_u32(); if (!q->filter_list && q->tail) sfq_rehash(sch); spin_unlock(root_lock); @@ -696,7 +696,7 @@ static int sfq_change(struct Qdisc *sch, struct nlattr *opt) del_timer(&q->perturb_timer); if (q->perturb_period) { mod_timer(&q->perturb_timer, jiffies + q->perturb_period); - q->perturbation = net_random(); + q->perturbation = prandom_u32(); } sch_tree_unlock(sch); kfree(p); @@ -757,7 +757,7 @@ static int sfq_init(struct Qdisc *sch, struct nlattr *opt) q->quantum = psched_mtu(qdisc_dev(sch)); q->scaled_quantum = SFQ_ALLOT_SIZE(q->quantum); q->perturb_period = 0; - q->perturbation = net_random(); + q->perturbation = prandom_u32(); if (opt) { int err = sfq_change(sch, opt);