mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] sched/core: remove unnecessary down/up conversion
@ 2015-05-03  8:51 Nicholas Mc Guire
  2015-05-08 13:21 ` [tip:sched/core] sched/core: Remove unnecessary down/ up conversion tip-bot for Nicholas Mc Guire
  0 siblings, 1 reply; 2+ messages in thread
From: Nicholas Mc Guire @ 2015-05-03  8:51 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: Peter Zijlstra, linux-kernel, Nicholas Mc Guire

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@osadl.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


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [tip:sched/core] sched/core: Remove unnecessary down/ up conversion
  2015-05-03  8:51 [PATCH] sched/core: remove unnecessary down/up conversion Nicholas Mc Guire
@ 2015-05-08 13:21 ` tip-bot for Nicholas Mc Guire
  0 siblings, 0 replies; 2+ messages in thread
From: tip-bot for Nicholas Mc Guire @ 2015-05-08 13:21 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: hpa, tglx, hofrat, akpm, mingo, peterz, torvalds, linux-kernel, bp

Commit-ID:  ce2f5fe46303d1e1a2ba453753a7e8200d32182c
Gitweb:     http://git.kernel.org/tip/ce2f5fe46303d1e1a2ba453753a7e8200d32182c
Author:     Nicholas Mc Guire <hofrat@osadl.org>
AuthorDate: Sun, 3 May 2015 10:51:56 +0200
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Fri, 8 May 2015 12:10:07 +0200

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.

This will also help us not truncate 'rt_period_us' to 32 bits on 32-bit kernels,
should we ever have so large values. (unlikely, not the least due to procfs.)

Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/1430643116-24049-1-git-send-email-hofrat@osadl.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 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 527fc28..46a5d6f 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -7738,11 +7738,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);

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-05-08 13:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-03  8:51 [PATCH] sched/core: remove unnecessary down/up conversion Nicholas Mc Guire
2015-05-08 13:21 ` [tip:sched/core] sched/core: Remove unnecessary down/ up conversion tip-bot for Nicholas Mc Guire

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome