lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1430643116-24049-1-git-send-email-hofrat@osadl.org>
Date:	Sun,  3 May 2015 10:51:56 +0200
From:	Nicholas Mc Guire <hofrat@...dl.org>
To:	Ingo Molnar <mingo@...hat.com>
Cc:	Peter Zijlstra <peterz@...radead.org>,
	linux-kernel@...r.kernel.org, Nicholas Mc Guire <hofrat@...dl.org>
Subject: [PATCH] sched/core: remove unnecessary down/up conversion

rt_period_us is automatically type converted from u64 to long and then cast
back to u64 - this down/up conversion is unnecessary and can be removed to
improve readability.

Signed-off-by: Nicholas Mc Guire <hofrat@...dl.org>
---

sched_group_set_rt_period is called in one place at
kernel/sched/core.c:cpu_rt_period_write_uint:8318
static int cpu_rt_period_write_uint(struct cgroup_subsys_state *css,
                                    struct cftype *cftype, u64 rt_period_us)
{
        return sched_group_set_rt_period(css_tg(css), rt_period_us);
}

here rt_period_us is automatically type converted to long and then cast
back to u64 in sched_group_set_rt_period which should be equivalent to
simply passing it as u64 and dropping the cast.

static int sched_group_set_rt_period(struct task_group *tg, long
rt_period_us)
{
        u64 rt_runtime, rt_period;

        rt_period = (u64)rt_period_us * NSEC_PER_USEC;
        rt_runtime = tg->rt_bandwidth.rt_runtime;

        return tg_set_rt_bandwidth(tg, rt_period, rt_runtime);
}

Patch was compile tested for x86_64_defconfig

Patch is against 4.1-rc1 (localversion-next is -next-20150501)

 kernel/sched/core.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index fe22f75..cf7f327 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -7739,11 +7739,11 @@ static long sched_group_rt_runtime(struct task_group *tg)
 	return rt_runtime_us;
 }
 
-static int sched_group_set_rt_period(struct task_group *tg, long rt_period_us)
+static int sched_group_set_rt_period(struct task_group *tg, u64 rt_period_us)
 {
 	u64 rt_runtime, rt_period;
 
-	rt_period = (u64)rt_period_us * NSEC_PER_USEC;
+	rt_period = rt_period_us * NSEC_PER_USEC;
 	rt_runtime = tg->rt_bandwidth.rt_runtime;
 
 	return tg_set_rt_bandwidth(tg, rt_period, rt_runtime);
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ