sched: Minor cleanups
cover sched: Minor cleanups
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(-)
Signature · 1 line
2.12.0.432.g71c3a4f4ba37
PATCH 1/4 sched: topology: drop memset() from init_rootdomain()
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().
--- kernel/sched/topology.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
kernel/sched/topology.c +1 -3
@@ -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 ;
Signature · 1 line
2.12.0.432.g71c3a4f4ba37
PATCH 2/4 sched: cpudeadline: don't re-initialize struct cpudl
In reply to Viresh KumarThe struct cpudl passed to cpudl_init() is already initialized to zero. Don't do that again.
--- kernel/sched/cpudeadline.c | 2 -- 1 file changed, 2 deletions(-)
kernel/sched/cpudeadline.c +0 -2
@@ -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),
Signature · 1 line
2.12.0.432.g71c3a4f4ba37
PATCH 3/4 sched: cpupri: don't re-initialize struct cpupri
In reply to Viresh KumarThe struct cpupri passed to cpupri_init() is already initialized to zero. Don't do that again.
--- kernel/sched/cpupri.c | 3 --- 1 file changed, 3 deletions(-)
kernel/sched/cpupri.c +0 -3
@@ -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; }
Signature · 1 line
2.12.0.432.g71c3a4f4ba37
PATCH 4/4 sched: core: drop useless expression from sched_init()
In reply to Viresh Kumar'ptr' is never used after setting 'rt_rq' and there is no need to update it.
--- kernel/sched/core.c | 1 - 1 file changed, 1 deletion(-)
kernel/sched/core.c +0 -1
@@ -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 */ }
Signature · 1 line
2.12.0.432.g71c3a4f4ba37
Peter Zijlstra
maintainerQuoted 6 lines · 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.
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.
Quoted 9 lines · Peter Zijlstra
Quoted 6 lines · 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.
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?
Quoted 5 lines
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.
Quoted 3 lines
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.
Signature · 1 line
viresh