From: Peter Zijlstra on
On Thu, 2010-06-10 at 13:10 +0200, Andi Kleen wrote:
> This will save a few bytes in the non offstack cpumask case.
>
> Found by gcc 4.6's new warnings.
>
> Cc: peterz(a)infradead.org
> Cc: mingo(a)elte.hu
> Signed-off-by: Andi Kleen <ak(a)linux.intel.com>
>
> ---
> kernel/sched.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> Index: linux-2.6.35-rc2-gcc/kernel/sched.c
> ===================================================================
> --- linux-2.6.35-rc2-gcc.orig/kernel/sched.c
> +++ linux-2.6.35-rc2-gcc/kernel/sched.c
> @@ -7482,7 +7482,7 @@ static void init_tg_rt_entry(struct task
> void __init sched_init(void)
> {
> int i, j;
> - unsigned long alloc_size = 0, ptr;
> + unsigned long alloc_size = 0;
>
> #ifdef CONFIG_FAIR_GROUP_SCHED
> alloc_size += 2 * nr_cpu_ids * sizeof(void **);
> @@ -7494,7 +7494,10 @@ void __init sched_init(void)
> alloc_size += num_possible_cpus() * cpumask_size();
> #endif
> if (alloc_size) {
> +#ifdef CONFIG_CPUMASK_OFFSTACK
> + unsigned long ptr;
> ptr = (unsigned long)kzalloc(alloc_size, GFP_NOWAIT);
> +#endif
>
> #ifdef CONFIG_FAIR_GROUP_SCHED
> init_task_group.se = (struct sched_entity **)ptr;

This patch will actually break things.. please read the code.

I guess we could move the unsigned long into that block, but I really
don't see the point.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
From: Peter Zijlstra on
On Thu, 2010-06-10 at 16:52 +0200, Andi Kleen wrote:
> > This patch will actually break things.. please read the code.
> >
> > I guess we could move the unsigned long into that block, but I really
> > don't see the point.
>
> How does it break things?
>
> ptr is not used for anything unless that define is set. gcc doesn't
> lie on this.

if (alloc_size) {
ptr = (unsigned long)kzalloc(alloc_size, GFP_NOWAIT);

#ifdef CONFIG_FAIR_GROUP_SCHED
init_task_group.se = (struct sched_entity **)ptr;
ptr += nr_cpu_ids * sizeof(void **);

init_task_group.cfs_rq = (struct cfs_rq **)ptr;
ptr += nr_cpu_ids * sizeof(void **);

#endif /* CONFIG_FAIR_GROUP_SCHED */
#ifdef CONFIG_RT_GROUP_SCHED
init_task_group.rt_se = (struct sched_rt_entity **)ptr;
ptr += nr_cpu_ids * sizeof(void **);

init_task_group.rt_rq = (struct rt_rq **)ptr;
ptr += nr_cpu_ids * sizeof(void **);

#endif /* CONFIG_RT_GROUP_SCHED */
#ifdef CONFIG_CPUMASK_OFFSTACK
for_each_possible_cpu(i) {
per_cpu(load_balance_tmpmask, i) = (void *)ptr;
ptr += cpumask_size();
}
#endif /* CONFIG_CPUMASK_OFFSTACK */
}

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
From: Peter Zijlstra on
On Thu, 2010-06-10 at 17:06 +0200, Andi Kleen wrote:
> +#if defined(CONFIG_CPUMASK_OFFSTACK) || defined(CONFIG_FAIR_GROUP_SCHED)

Still wrong.. something like the below might work, but I really think
its not worth the trouble.

---
kernel/sched.c | 11 ++++++-----
1 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/kernel/sched.c b/kernel/sched.c
index 19b3c5d..af40894 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -7689,7 +7689,9 @@ static void init_tg_rt_entry(struct task_group *tg, struct rt_rq *rt_rq,
void __init sched_init(void)
{
int i, j;
- unsigned long alloc_size = 0, ptr;
+
+#if defined CONFIG_FAIR_GROUP_SCHED || defined CONFIG_RT_GROUP_SCHED || defined CONFIG_CPUMASK_OFFSTACK
+ unsigned long alloc_size = 0;

#ifdef CONFIG_FAIR_GROUP_SCHED
alloc_size += 2 * nr_cpu_ids * sizeof(void **);
@@ -7701,6 +7703,8 @@ void __init sched_init(void)
alloc_size += num_possible_cpus() * cpumask_size();
#endif
if (alloc_size) {
+ unsigned long ptr;
+
ptr = (unsigned long)kzalloc(alloc_size, GFP_NOWAIT);

#ifdef CONFIG_FAIR_GROUP_SCHED
@@ -7726,6 +7730,7 @@ void __init sched_init(void)
}
#endif /* CONFIG_CPUMASK_OFFSTACK */
}
+#endif /* {FAIR,RT}_GROUP,OFFSTACK */

#ifdef CONFIG_SMP
init_defrootdomain();
@@ -7762,7 +7767,6 @@ void __init sched_init(void)
#ifdef CONFIG_FAIR_GROUP_SCHED
init_task_group.shares = init_task_group_load;
INIT_LIST_HEAD(&rq->leaf_cfs_rq_list);
-#ifdef CONFIG_CGROUP_SCHED
/*
* How much cpu bandwidth does init_task_group get?
*
@@ -7783,16 +7787,13 @@ void __init sched_init(void)
* directly in rq->cfs (i.e init_task_group->se[] = NULL).
*/
init_tg_cfs_entry(&init_task_group, &rq->cfs, NULL, i, 1, NULL);
-#endif
#endif /* CONFIG_FAIR_GROUP_SCHED */

rq->rt.rt_runtime = def_rt_bandwidth.rt_runtime;
#ifdef CONFIG_RT_GROUP_SCHED
INIT_LIST_HEAD(&rq->leaf_rt_rq_list);
-#ifdef CONFIG_CGROUP_SCHED
init_tg_rt_entry(&init_task_group, &rq->rt, NULL, i, 1, NULL);
#endif
-#endif

for (j = 0; j < CPU_LOAD_IDX_MAX; j++)
rq->cpu_load[j] = 0;

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