Skip to contentSkip to conversation

sched: mc/smt power savings sched policy

PATCH In review Siddha, Suresh B 3 participants 5 messages Jun 6, 2006 – Jun 7, 2006

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sched: mc/smt power savings sched policy

Appended the patch. Can someone please test compile the powerpc change?

thanks,
suresh
--

sysfs entries 'sched_mc_power_savings' and 'sched_smt_power_savings' in /sys/devices/system/cpu/ control the MC/SMT power savings policy for the scheduler.

Based on the values (1-enable, 0-disable) for these controls, sched groups cpu power will be determined for different domains. When power savings policy is enabled and under light load conditions, scheduler will minimize the physical packages/cpu cores carrying the load and thus conserving power(with a perf impact based on the workload characteristics... see OLS 2005 CMP kernel scheduler paper for more details..)

arch/i386/kernel/smpboot.c +5 -3
diff -pNru linux-2.6.17-rc5/arch/i386/kernel/smpboot.c linux/arch/i386/kernel/smpboot.c
@@ -446,10 +446,12 @@ cpumask_t cpu_coregroup_map(int cpu)
 	struct cpuinfo_x86 *c = cpu_data + cpu;
 	/*
 	 * For perf, we return last level cache shared map.
-	 * TBD: when power saving sched policy is added, we will return
-	 *      cpu_core_map when power saving policy is enabled
+	 * And for power savings, we return cpu_core_map
 	 */
-	return c->llc_shared_map;
+	if (sched_mc_power_savings || sched_smt_power_savings)
+		return cpu_core_map[cpu];
+	else
+		return c->llc_shared_map;
 }
 
 /* representing cpus for which sibling maps can be computed */
arch/x86_64/kernel/smpboot.c +5 -3
diff -pNru linux-2.6.17-rc5/arch/x86_64/kernel/smpboot.c linux/arch/x86_64/kernel/smpboot.c
@@ -450,10 +450,12 @@ cpumask_t cpu_coregroup_map(int cpu)
 	struct cpuinfo_x86 *c = cpu_data + cpu;
 	/*
 	 * For perf, we return last level cache shared map.
-	 * TBD: when power saving sched policy is added, we will return
-	 *      cpu_core_map when power saving policy is enabled
+	 * And for power savings, we return cpu_core_map
 	 */
-	return c->llc_shared_map;
+	if (sched_mc_power_savings || sched_smt_power_savings)
+		return cpu_core_map[cpu];
+	else
+		return c->llc_shared_map;
 }
 
 /* representing cpus for which sibling maps can be computed */
drivers/base/cpu.c +9 -1
diff -pNru linux-2.6.17-rc5/drivers/base/cpu.c linux/drivers/base/cpu.c
@@ -143,5 +143,13 @@ EXPORT_SYMBOL_GPL(get_cpu_sysdev);
 
 int __init cpu_dev_init(void)
 {
-	return sysdev_class_register(&cpu_sysdev_class);
+	int err;
+
+	err = sysdev_class_register(&cpu_sysdev_class);
+#if defined(CONFIG_SCHED_MC) || defined(CONFIG_SCHED_SMT)
+	if (!err)
+		err = sched_create_sysfs_power_savings_entries(&cpu_sysdev_class);
+#endif
+
+	return err;
 }
include/asm-i386/topology.h +5 -0
diff -pNru linux-2.6.17-rc5/include/asm-i386/topology.h linux/include/asm-i386/topology.h
@@ -112,4 +112,9 @@ extern unsigned long node_remap_size[];
 
 extern cpumask_t cpu_coregroup_map(int cpu);
 
+#ifdef CONFIG_SMP
+#define mc_capable()	(boot_cpu_data.x86_max_cores > 1)
+#define smt_capable()	(smp_num_siblings > 1)
+#endif
+
 #endif /* _ASM_I386_TOPOLOGY_H */
include/asm-ia64/topology.h +1 -0
diff -pNru linux-2.6.17-rc5/include/asm-ia64/topology.h linux/include/asm-ia64/topology.h
@@ -112,6 +112,7 @@ void build_cpu_to_node_map(void);
 #define topology_core_id(cpu)			(cpu_data(cpu)->core_id)
 #define topology_core_siblings(cpu)		(cpu_core_map[cpu])
 #define topology_thread_siblings(cpu)		(cpu_sibling_map[cpu])
+#define smt_capable() 				(smp_num_siblings > 1)
 #endif
 
 #include <asm-generic/topology.h>
include/asm-powerpc/topology.h +5 -0
diff -pNru linux-2.6.17-rc5/include/asm-powerpc/topology.h linux/include/asm-powerpc/topology.h
@@ -88,5 +88,10 @@ static inline void sysfs_remove_device_f
 
 #endif /* CONFIG_NUMA */
 
+#ifdef CONFIG_SMP
+#include <asm/cputable.h>
+#define smt_capable() 		(cpu_has_feature(CPU_FTR_SMT))
+#endif
+
 #endif /* __KERNEL__ */
 #endif	/* _ASM_POWERPC_TOPOLOGY_H */
include/asm-x86_64/topology.h +2 -0
diff -pNru linux-2.6.17-rc5/include/asm-x86_64/topology.h linux/include/asm-x86_64/topology.h
@@ -59,6 +59,8 @@ extern int __node_distance(int, int);
 #define topology_core_id(cpu)			(cpu_data[cpu].cpu_core_id)
 #define topology_core_siblings(cpu)		(cpu_core_map[cpu])
 #define topology_thread_siblings(cpu)		(cpu_sibling_map[cpu])
+#define mc_capable()			(boot_cpu_data.x86_max_cores > 1)
+#define smt_capable() 			(smp_num_siblings > 1)
 #endif
 
 #include <asm-generic/topology.h>
include/linux/sched.h +10 -0
diff -pNru linux-2.6.17-rc5/include/linux/sched.h linux/include/linux/sched.h
@@ -610,6 +610,11 @@ enum idle_type
 #define SD_WAKE_AFFINE		32	/* Wake task to waking CPU */
 #define SD_WAKE_BALANCE		64	/* Perform balancing at task wakeup */
 #define SD_SHARE_CPUPOWER	128	/* Domain members share cpu power */
+#define SD_POWERSAVINGS_BALANCE	256	/* Balance for power savings */
+
+#define BALANCE_FOR_POWER	((sched_mc_power_savings || sched_smt_power_savings) \
+				 ? SD_POWERSAVINGS_BALANCE : 0)
+
 
 struct sched_group {
 	struct sched_group *next;	/* Must be a circular list */
@@ -1527,6 +1532,11 @@ static inline void arch_pick_mmap_layout
 extern long sched_setaffinity(pid_t pid, cpumask_t new_mask);
 extern long sched_getaffinity(pid_t pid, cpumask_t *mask);
 
+#include <linux/sysdev.h>
+extern int sched_mc_power_savings, sched_smt_power_savings;
+extern struct sysdev_attribute attr_sched_mc_power_savings, attr_sched_smt_power_savings;
+extern int sched_create_sysfs_power_savings_entries(struct sysdev_class *cls);
+
 extern void normalize_rt_tasks(void);
 
 #ifdef CONFIG_PM
include/linux/topology.h +2 -1
diff -pNru linux-2.6.17-rc5/include/linux/topology.h linux/include/linux/topology.h
@@ -134,7 +134,8 @@
 	.flags			= SD_LOAD_BALANCE	\
 				| SD_BALANCE_NEWIDLE	\
 				| SD_BALANCE_EXEC	\
-				| SD_WAKE_AFFINE,	\
+				| SD_WAKE_AFFINE	\
+				| BALANCE_FOR_POWER,	\
 	.last_balance		= jiffies,		\
 	.balance_interval	= 1,			\
 	.nr_balance_failed	= 0,			\
kernel/sched.c +216 -26

344 lines not on this page · raw message

#1 lore raw
Quoted 10 lines · Suresh B

Appended the patch. Can someone please test compile the powerpc change?

thanks,
suresh
--

sysfs entries 'sched_mc_power_savings' and 'sched_smt_power_savings' in /sys/devices/system/cpu/ control the MC/SMT power savings policy for the scheduler.

Quoted 6 lines

Based on the values (1-enable, 0-disable) for these controls, sched groups cpu power will be determined for different domains. When power savings policy is enabled and under light load conditions, scheduler will minimize the physical packages/cpu cores carrying the load and thus conserving power(with a perf impact based on the workload characteristics... see OLS 2005 CMP kernel scheduler paper for more details..)

This MC code is a maze of #ifdefs within functions and getting harder to follow with each subsequent patch. Can we not deviate so much from kernel style?

Signature · 1 line
-ck
#2 lore raw
Quoted 3 lines · Con Kolivas

This MC code is a maze of #ifdefs within functions and getting harder to follow with each subsequent patch. Can we not deviate so much from kernel style?

build_sched_domains() originally was not designed with this many sched domains in mind.. I can take a look at cleaning up of the sched domains setup..

thanks,
suresh

#3 lore raw
In reply to Siddha, Suresh B
Quoted 1 line · Suresh B

Appended the patch. Can someone please test compile the powerpc change?

powerpc compiles and boots OK, but sparc64 is not so good.

kernel/built-in.o(.text+0x6ec0): In function `sched_create_sysfs_power_savings_entries':
: undefined reference to `smt_capable'

#4 lore raw
Quoted 9 lines · Andrew Morton
Quoted 1 line · Suresh B

Appended the patch. Can someone please test compile the powerpc change?

powerpc compiles and boots OK, but sparc64 is not so good.

kernel/built-in.o(.text+0x6ec0): In function `sched_create_sysfs_power_savings_entries':
: undefined reference to `smt_capable'

Dave, I am not sure if the appended patch is the correct(perhaps temporary?) mechanism(currently smp_prepare_cpus() also uses this mechanism) in identifying a SMT capable sparc64 processor. Can you confirm?

thanks,
suresh
--

include/asm-sparc64/topology.h +3 -0
@@ -1,6 +1,9 @@
 #ifndef _ASM_SPARC64_TOPOLOGY_H
 #define _ASM_SPARC64_TOPOLOGY_H
 
+#include <asm/spitfire.h>
+#define smt_capable()	(tlb_type == hypervisor)
+
 #include <asm-generic/topology.h>
 
 #endif /* _ASM_SPARC64_TOPOLOGY_H */