* [PATCH 0/4] sched: Minor cleanups
@ 2017-03-23 11:35 Viresh Kumar
2017-03-23 11:35 ` [PATCH 1/4] sched: topology: drop memset() from init_rootdomain() Viresh Kumar
` (4 more replies)
0 siblings, 5 replies; 7+ messages in thread
From: Viresh Kumar @ 2017-03-23 11:35 UTC (permalink / raw)
To: Ingo Molnar, Peter Zijlstra
Cc: linaro-kernel, linux-kernel, Vincent Guittot, Viresh Kumar
Hi,
Here are few minor cleanups for the sched core. The first three tries to
avoid reinitializing memory which is already set to zero and the last
one drops an unused statement.
--
viresh
Viresh Kumar (4):
sched: topology: drop memset() from init_rootdomain()
sched: cpudeadline: don't re-initialize struct cpudl
sched: cpupri: don't re-initialize struct cpupri
sched: core: drop useless expression from sched_init()
kernel/sched/core.c | 1 -
kernel/sched/cpudeadline.c | 2 --
kernel/sched/cpupri.c | 3 ---
kernel/sched/topology.c | 4 +---
4 files changed, 1 insertion(+), 9 deletions(-)
--
2.12.0.432.g71c3a4f4ba37
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 1/4] sched: topology: drop memset() from init_rootdomain()
2017-03-23 11:35 [PATCH 0/4] sched: Minor cleanups Viresh Kumar
@ 2017-03-23 11:35 ` Viresh Kumar
2017-03-23 11:35 ` [PATCH 2/4] sched: cpudeadline: don't re-initialize struct cpudl Viresh Kumar
` (3 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: Viresh Kumar @ 2017-03-23 11:35 UTC (permalink / raw)
To: Ingo Molnar, Peter Zijlstra
Cc: linaro-kernel, linux-kernel, Vincent Guittot, Viresh Kumar
There are only two callers of init_rootdomain(). One of them passes a
global to it and another one sends dynamically allocated root-domain.
There is no need to memset the root-domain in the first case as the
structure is already reset.
Update alloc_rootdomain() to allocate the memory with kzalloc() and
remove the memset() call from init_rootdomain().
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
kernel/sched/topology.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c
index 1b0b4fb12837..a2497702e628 100644
--- a/kernel/sched/topology.c
+++ b/kernel/sched/topology.c
@@ -242,8 +242,6 @@ void rq_attach_root(struct rq *rq, struct root_domain *rd)
static int init_rootdomain(struct root_domain *rd)
{
- memset(rd, 0, sizeof(*rd));
-
if (!zalloc_cpumask_var(&rd->span, GFP_KERNEL))
goto out;
if (!zalloc_cpumask_var(&rd->online, GFP_KERNEL))
@@ -292,7 +290,7 @@ static struct root_domain *alloc_rootdomain(void)
{
struct root_domain *rd;
- rd = kmalloc(sizeof(*rd), GFP_KERNEL);
+ rd = kzalloc(sizeof(*rd), GFP_KERNEL);
if (!rd)
return NULL;
--
2.12.0.432.g71c3a4f4ba37
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 2/4] sched: cpudeadline: don't re-initialize struct cpudl
2017-03-23 11:35 [PATCH 0/4] sched: Minor cleanups Viresh Kumar
2017-03-23 11:35 ` [PATCH 1/4] sched: topology: drop memset() from init_rootdomain() Viresh Kumar
@ 2017-03-23 11:35 ` Viresh Kumar
2017-03-23 11:35 ` [PATCH 3/4] sched: cpupri: don't re-initialize struct cpupri Viresh Kumar
` (2 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: Viresh Kumar @ 2017-03-23 11:35 UTC (permalink / raw)
To: Ingo Molnar, Peter Zijlstra
Cc: linaro-kernel, linux-kernel, Vincent Guittot, Viresh Kumar
The struct cpudl passed to cpudl_init() is already initialized to zero.
Don't do that again.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
kernel/sched/cpudeadline.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/kernel/sched/cpudeadline.c b/kernel/sched/cpudeadline.c
index fba235c7d026..a51e91bf3907 100644
--- a/kernel/sched/cpudeadline.c
+++ b/kernel/sched/cpudeadline.c
@@ -246,9 +246,7 @@ int cpudl_init(struct cpudl *cp)
{
int i;
- memset(cp, 0, sizeof(*cp));
raw_spin_lock_init(&cp->lock);
- cp->size = 0;
cp->elements = kcalloc(nr_cpu_ids,
sizeof(struct cpudl_item),
--
2.12.0.432.g71c3a4f4ba37
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 3/4] sched: cpupri: don't re-initialize struct cpupri
2017-03-23 11:35 [PATCH 0/4] sched: Minor cleanups Viresh Kumar
2017-03-23 11:35 ` [PATCH 1/4] sched: topology: drop memset() from init_rootdomain() Viresh Kumar
2017-03-23 11:35 ` [PATCH 2/4] sched: cpudeadline: don't re-initialize struct cpudl Viresh Kumar
@ 2017-03-23 11:35 ` Viresh Kumar
2017-03-23 11:35 ` [PATCH 4/4] sched: core: drop useless expression from sched_init() Viresh Kumar
2017-03-27 13:58 ` [PATCH 0/4] sched: Minor cleanups Peter Zijlstra
4 siblings, 0 replies; 7+ messages in thread
From: Viresh Kumar @ 2017-03-23 11:35 UTC (permalink / raw)
To: Ingo Molnar, Peter Zijlstra
Cc: linaro-kernel, linux-kernel, Vincent Guittot, Viresh Kumar
The struct cpupri passed to cpupri_init() is already initialized to
zero. Don't do that again.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
kernel/sched/cpupri.c | 3 ---
1 file changed, 3 deletions(-)
diff --git a/kernel/sched/cpupri.c b/kernel/sched/cpupri.c
index 981fcd7dc394..d6165d87ef3e 100644
--- a/kernel/sched/cpupri.c
+++ b/kernel/sched/cpupri.c
@@ -209,12 +209,9 @@ int cpupri_init(struct cpupri *cp)
{
int i;
- memset(cp, 0, sizeof(*cp));
-
for (i = 0; i < CPUPRI_NR_PRIORITIES; i++) {
struct cpupri_vec *vec = &cp->pri_to_cpu[i];
- atomic_set(&vec->count, 0);
if (!zalloc_cpumask_var(&vec->mask, GFP_KERNEL))
goto cleanup;
}
--
2.12.0.432.g71c3a4f4ba37
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 4/4] sched: core: drop useless expression from sched_init()
2017-03-23 11:35 [PATCH 0/4] sched: Minor cleanups Viresh Kumar
` (2 preceding siblings ...)
2017-03-23 11:35 ` [PATCH 3/4] sched: cpupri: don't re-initialize struct cpupri Viresh Kumar
@ 2017-03-23 11:35 ` Viresh Kumar
2017-03-27 13:58 ` [PATCH 0/4] sched: Minor cleanups Peter Zijlstra
4 siblings, 0 replies; 7+ messages in thread
From: Viresh Kumar @ 2017-03-23 11:35 UTC (permalink / raw)
To: Ingo Molnar, Peter Zijlstra
Cc: linaro-kernel, linux-kernel, Vincent Guittot, Viresh Kumar
'ptr' is never used after setting 'rt_rq' and there is no need to update
it.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
kernel/sched/core.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 6d6cad9a46af..bd33a05d038b 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -5992,7 +5992,6 @@ void __init sched_init(void)
ptr += nr_cpu_ids * sizeof(void **);
root_task_group.rt_rq = (struct rt_rq **)ptr;
- ptr += nr_cpu_ids * sizeof(void **);
#endif /* CONFIG_RT_GROUP_SCHED */
}
--
2.12.0.432.g71c3a4f4ba37
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 0/4] sched: Minor cleanups
2017-03-23 11:35 [PATCH 0/4] sched: Minor cleanups Viresh Kumar
` (3 preceding siblings ...)
2017-03-23 11:35 ` [PATCH 4/4] sched: core: drop useless expression from sched_init() Viresh Kumar
@ 2017-03-27 13:58 ` Peter Zijlstra
2017-04-10 9:30 ` Viresh Kumar
4 siblings, 1 reply; 7+ messages in thread
From: Peter Zijlstra @ 2017-03-27 13:58 UTC (permalink / raw)
To: Viresh Kumar; +Cc: Ingo Molnar, linaro-kernel, linux-kernel, Vincent Guittot
On Thu, Mar 23, 2017 at 05:05:55PM +0530, Viresh Kumar wrote:
> Hi,
>
> Here are few minor cleanups for the sched core. The first three tries to
> avoid reinitializing memory which is already set to zero and the last
> one drops an unused statement.
>
I'm OK with the kzalloc/memset thing, but I'd prefer to keep all those
other bits.
Yes they're superfluous, but this is init code, so nobody cares about
performance and having those things explitic makes it easier to read.
As to the very latest patch, that's there so that if/when we extend that
array we can simply continue. Also its more symmetric/consistent. Any
half sane DCE pass should get rid of it anyway, as the result is unused.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 0/4] sched: Minor cleanups
2017-03-27 13:58 ` [PATCH 0/4] sched: Minor cleanups Peter Zijlstra
@ 2017-04-10 9:30 ` Viresh Kumar
0 siblings, 0 replies; 7+ messages in thread
From: Viresh Kumar @ 2017-04-10 9:30 UTC (permalink / raw)
To: Peter Zijlstra; +Cc: Ingo Molnar, linaro-kernel, linux-kernel, Vincent Guittot
On 27-03-17, 15:58, Peter Zijlstra wrote:
> On Thu, Mar 23, 2017 at 05:05:55PM +0530, Viresh Kumar wrote:
> > Hi,
> >
> > Here are few minor cleanups for the sched core. The first three tries to
> > avoid reinitializing memory which is already set to zero and the last
> > one drops an unused statement.
> >
>
> I'm OK with the kzalloc/memset thing,
I assume that you are fine with removal of memset as done in the first
3 patches. Or you are fine with just the first patch?
> but I'd prefer to keep all those
> other bits.
>
> Yes they're superfluous, but this is init code, so nobody cares about
> performance and having those things explitic makes it easier to read.
Sure.
> As to the very latest patch, that's there so that if/when we extend that
> array we can simply continue. Also its more symmetric/consistent. Any
> half sane DCE pass should get rid of it anyway, as the result is unused.
But we aren't going to extend the array all the time and keeping a
statement like that just for symmetry doesn't sound that great :).
Anyway, I will drop the last patch as you suggested.
--
viresh
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2017-04-10 9:31 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-03-23 11:35 [PATCH 0/4] sched: Minor cleanups Viresh Kumar
2017-03-23 11:35 ` [PATCH 1/4] sched: topology: drop memset() from init_rootdomain() Viresh Kumar
2017-03-23 11:35 ` [PATCH 2/4] sched: cpudeadline: don't re-initialize struct cpudl Viresh Kumar
2017-03-23 11:35 ` [PATCH 3/4] sched: cpupri: don't re-initialize struct cpupri Viresh Kumar
2017-03-23 11:35 ` [PATCH 4/4] sched: core: drop useless expression from sched_init() Viresh Kumar
2017-03-27 13:58 ` [PATCH 0/4] sched: Minor cleanups Peter Zijlstra
2017-04-10 9:30 ` Viresh Kumar
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox