linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] sched: track "isolated" cpus like other cpu masks.
@ 2011-05-20 20:29 Geoff Thorpe
  2011-05-21  3:06 ` yaff2 support ym cheng
  2011-05-23 20:14 ` [PATCH] sched: track "isolated" cpus like other cpu masks Peter Zijlstra
  0 siblings, 2 replies; 4+ messages in thread
From: Geoff Thorpe @ 2011-05-20 20:29 UTC (permalink / raw)
  To: linux-kernel; +Cc: Geoff Thorpe

When a subset of cpus have been isolated, it can be useful for subsystems
or drivers that have cpu-affinity concerns to have access to this mask
(just like the other cpu masks; "possible", "present", "active" and
"online"). Eg. to provide specific handling for isolated cpus, or to
determine the non-isolated cpus (which is what sched.c uses it for).

Signed-off-by: Geoff Thorpe <geoff@geoffthorpe.net>
---

 Hi - please CC me on any replies as I'm not subscribed.

 As part of some work I'm doing, I was using an "isolcpus=" boot-arg to
 control scheduling of user processes, and using this patch to allow my
 driver to obtain the corresponding cpu-mask and make adaptations. That
 isolation awareness was a temporary hack in my driver, and I no longer
 need it, but as part of that work I make the following tidy-up of the
 "isolated" cpu-mask, which I think is an improvement on the existing
 code.

 Right now, all the cpu-masks except "cpu_isolated_map" are statically
 instantiated in kernel/cpu.c. OTOH the isolated mask is internal to
 kernel/sched.c and dynamically allocated, either from bootmem in a
 __setup() hook or later via a zalloc(GFP_NOWAIT) within sched_init(). So
 I think this simplifies things; using the same non-dynamic declaration
 for the isolated mask as the other masks, and providing visibility to it
 beyond sched.c. However I'm working only with one relatively simple arch,
 so perhaps I'm overlooking some portability or scalability considerations
 in sched.c? TIA for any tips.

 NB, this patch is against Linus' tree, node: 257313b2...

 Cheers,
 Geoff

 include/linux/cpumask.h |   11 ++++++++++-
 kernel/cpu.c            |   30 ++++++++++++++++++++++++++++++
 kernel/sched.c          |   22 +++-------------------
 3 files changed, 43 insertions(+), 20 deletions(-)

diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
index bae6fe2..6c05ad5 100644
--- a/include/linux/cpumask.h
+++ b/include/linux/cpumask.h
@@ -37,12 +37,13 @@ extern int nr_cpu_ids;
 
 /*
  * The following particular system cpumasks and operations manage
- * possible, present, active and online cpus.
+ * possible, present, active, online, and isolated cpus.
  *
  *     cpu_possible_mask- has bit 'cpu' set iff cpu is populatable
  *     cpu_present_mask - has bit 'cpu' set iff cpu is populated
  *     cpu_online_mask  - has bit 'cpu' set iff cpu available to scheduler
  *     cpu_active_mask  - has bit 'cpu' set iff cpu available to migration
+ *     cpu_isolated_mask - has bit 'cpu' set iff cpu is isolated
  *
  *  If !CONFIG_HOTPLUG_CPU, present == possible, and active == online.
  *
@@ -79,25 +80,30 @@ extern const struct cpumask *const cpu_possible_mask;
 extern const struct cpumask *const cpu_online_mask;
 extern const struct cpumask *const cpu_present_mask;
 extern const struct cpumask *const cpu_active_mask;
+extern const struct cpumask *const cpu_isolated_mask;
 
 #if NR_CPUS > 1
 #define num_online_cpus()	cpumask_weight(cpu_online_mask)
 #define num_possible_cpus()	cpumask_weight(cpu_possible_mask)
 #define num_present_cpus()	cpumask_weight(cpu_present_mask)
 #define num_active_cpus()	cpumask_weight(cpu_active_mask)
+#define num_isolated_cpus()	cpumask_weight(cpu_isolated_mask)
 #define cpu_online(cpu)		cpumask_test_cpu((cpu), cpu_online_mask)
 #define cpu_possible(cpu)	cpumask_test_cpu((cpu), cpu_possible_mask)
 #define cpu_present(cpu)	cpumask_test_cpu((cpu), cpu_present_mask)
 #define cpu_active(cpu)		cpumask_test_cpu((cpu), cpu_active_mask)
+#define cpu_isolated(cpu)	cpumask_test_cpu((cpu), cpu_isolated_mask)
 #else
 #define num_online_cpus()	1U
 #define num_possible_cpus()	1U
 #define num_present_cpus()	1U
 #define num_active_cpus()	1U
+#define num_isolated_cpus()	0U
 #define cpu_online(cpu)		((cpu) == 0)
 #define cpu_possible(cpu)	((cpu) == 0)
 #define cpu_present(cpu)	((cpu) == 0)
 #define cpu_active(cpu)		((cpu) == 0)
+#define cpu_isolated(cpu)	((cpu) != 0)
 #endif
 
 /* verify cpu argument to cpumask_* operators */
@@ -671,9 +677,11 @@ void set_cpu_possible(unsigned int cpu, bool possible);
 void set_cpu_present(unsigned int cpu, bool present);
 void set_cpu_online(unsigned int cpu, bool online);
 void set_cpu_active(unsigned int cpu, bool active);
+void set_cpu_isolated(unsigned int cpu, bool isolated);
 void init_cpu_present(const struct cpumask *src);
 void init_cpu_possible(const struct cpumask *src);
 void init_cpu_online(const struct cpumask *src);
+void init_cpu_isolated(const struct cpumask *src);
 
 /**
  * to_cpumask - convert an NR_CPUS bitmap to a struct cpumask *
@@ -739,6 +747,7 @@ static inline const struct cpumask *get_cpu_mask(unsigned int cpu)
 #define cpu_online_map		(*(cpumask_t *)cpu_online_mask)
 #define cpu_present_map		(*(cpumask_t *)cpu_present_mask)
 #define cpu_active_map		(*(cpumask_t *)cpu_active_mask)
+#define cpu_isolated_map	(*(cpumask_t *)cpu_isolated_mask)
 
 #define cpumask_of_cpu(cpu) (*get_cpu_mask(cpu))
 
diff --git a/kernel/cpu.c b/kernel/cpu.c
index 12b7458..a7059bc 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -548,6 +548,10 @@ static DECLARE_BITMAP(cpu_active_bits, CONFIG_NR_CPUS) __read_mostly;
 const struct cpumask *const cpu_active_mask = to_cpumask(cpu_active_bits);
 EXPORT_SYMBOL(cpu_active_mask);
 
+static DECLARE_BITMAP(cpu_isolated_bits, CONFIG_NR_CPUS) __read_mostly;
+const struct cpumask *const cpu_isolated_mask = to_cpumask(cpu_isolated_bits);
+EXPORT_SYMBOL(cpu_isolated_mask);
+
 void set_cpu_possible(unsigned int cpu, bool possible)
 {
 	if (possible)
@@ -580,6 +584,14 @@ void set_cpu_active(unsigned int cpu, bool active)
 		cpumask_clear_cpu(cpu, to_cpumask(cpu_active_bits));
 }
 
+void set_cpu_isolated(unsigned int cpu, bool isolated)
+{
+	if (isolated)
+		cpumask_set_cpu(cpu, to_cpumask(cpu_isolated_bits));
+	else
+		cpumask_clear_cpu(cpu, to_cpumask(cpu_isolated_bits));
+}
+
 void init_cpu_present(const struct cpumask *src)
 {
 	cpumask_copy(to_cpumask(cpu_present_bits), src);
@@ -594,3 +606,21 @@ void init_cpu_online(const struct cpumask *src)
 {
 	cpumask_copy(to_cpumask(cpu_online_bits), src);
 }
+
+void init_cpu_isolated(const struct cpumask *src)
+{
+	cpumask_copy(to_cpumask(cpu_isolated_bits), src);
+}
+
+#ifdef CONFIG_SMP
+
+/* Setup the mask of cpus configured for isolated domains */
+static int __init isolated_cpu_setup(char *str)
+{
+	cpulist_parse(str, to_cpumask(cpu_isolated_bits));
+	return 1;
+}
+
+__setup("isolcpus=", isolated_cpu_setup);
+
+#endif
diff --git a/kernel/sched.c b/kernel/sched.c
index c62acf4..83dc2fe 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -6780,19 +6780,6 @@ cpu_attach_domain(struct sched_domain *sd, struct root_domain *rd, int cpu)
 	destroy_sched_domains(tmp, cpu);
 }
 
-/* cpus with isolated domains */
-static cpumask_var_t cpu_isolated_map;
-
-/* Setup the mask of cpus configured for isolated domains */
-static int __init isolated_cpu_setup(char *str)
-{
-	alloc_bootmem_cpumask_var(&cpu_isolated_map);
-	cpulist_parse(str, cpu_isolated_map);
-	return 1;
-}
-
-__setup("isolcpus=", isolated_cpu_setup);
-
 #define SD_NODES_PER_DOMAIN 16
 
 #ifdef CONFIG_NUMA
@@ -7371,7 +7358,7 @@ static int init_sched_domains(const struct cpumask *cpu_map)
 	doms_cur = alloc_sched_domains(ndoms_cur);
 	if (!doms_cur)
 		doms_cur = &fallback_doms;
-	cpumask_andnot(doms_cur[0], cpu_map, cpu_isolated_map);
+	cpumask_andnot(doms_cur[0], cpu_map, cpu_isolated_mask);
 	dattr_cur = NULL;
 	err = build_sched_domains(doms_cur[0], NULL);
 	register_sched_domain_sysctl();
@@ -7467,7 +7454,7 @@ match1:
 	if (doms_new == NULL) {
 		ndoms_cur = 0;
 		doms_new = &fallback_doms;
-		cpumask_andnot(doms_new[0], cpu_active_mask, cpu_isolated_map);
+		cpumask_andnot(doms_new[0], cpu_active_mask, cpu_isolated_mask);
 		WARN_ON_ONCE(dattr_new);
 	}
 
@@ -7653,7 +7640,7 @@ void __init sched_init_smp(void)
 	get_online_cpus();
 	mutex_lock(&sched_domains_mutex);
 	init_sched_domains(cpu_active_mask);
-	cpumask_andnot(non_isolated_cpus, cpu_possible_mask, cpu_isolated_map);
+	cpumask_andnot(non_isolated_cpus, cpu_possible_mask, cpu_isolated_mask);
 	if (cpumask_empty(non_isolated_cpus))
 		cpumask_set_cpu(smp_processor_id(), non_isolated_cpus);
 	mutex_unlock(&sched_domains_mutex);
@@ -7967,9 +7954,6 @@ void __init sched_init(void)
 	atomic_set(&nohz.first_pick_cpu, nr_cpu_ids);
 	atomic_set(&nohz.second_pick_cpu, nr_cpu_ids);
 #endif
-	/* May be allocated at isolcpus cmdline parse time */
-	if (cpu_isolated_map == NULL)
-		zalloc_cpumask_var(&cpu_isolated_map, GFP_NOWAIT);
 #endif /* SMP */
 
 	scheduler_running = 1;
-- 
1.7.4.1


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

* yaff2 support
  2011-05-20 20:29 [PATCH] sched: track "isolated" cpus like other cpu masks Geoff Thorpe
@ 2011-05-21  3:06 ` ym cheng
  2011-05-23 20:14 ` [PATCH] sched: track "isolated" cpus like other cpu masks Peter Zijlstra
  1 sibling, 0 replies; 4+ messages in thread
From: ym cheng @ 2011-05-21  3:06 UTC (permalink / raw)
  To: geoff, linux-kernel

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="utf-8", Size: 2459 bytes --]


In file included from /home/ymcheng/linux-2.6.39/arch/arm/include/asm/thread_info.h:28,
                 from include/linux/thread_info.h:53,
                 from include/linux/preempt.h:9,
                 from include/linux/spinlock.h:50,
                 from include/linux/seqlock.h:29,
                 from include/linux/time.h:8,
                 from include/linux/stat.h:60,
                 from include/linux/module.h:10,
                 from fs/yaffs2/yaffs_fs.c:48:
/home/ymcheng/linux-2.6.39/arch/arm/include/asm/domain.h:86:1: warning: this is the location of the previous definition
fs/yaffs2/yaffs_fs.c:310: warning: initialization from incompatible pointer type
fs/yaffs2/yaffs_fs.c:380: warning: initialization from incompatible pointer type
fs/yaffs2/yaffs_fs.c:393: error: unknown field 'delete_inode' specified in initializer
fs/yaffs2/yaffs_fs.c:393: warning: initialization from incompatible pointer type
fs/yaffs2/yaffs_fs.c:394: error: unknown field 'clear_inode' specified in initializer
fs/yaffs2/yaffs_fs.c:394: warning: initialization from incompatible pointer type
fs/yaffs2/yaffs_fs.c: In function 'yaffs_delete_inode':
fs/yaffs2/yaffs_fs.c:725: error: implicit declaration of function 'clear_inode'
fs/yaffs2/yaffs_fs.c: In function 'yaffs_setattr':
fs/yaffs2/yaffs_fs.c:1703: error: implicit declaration of function 'inode_setattr'
fs/yaffs2/yaffs_fs.c: In function 'yaffs_internal_read_super':
fs/yaffs2/yaffs_fs.c:2498: error: implicit declaration of function 'init_MUTEX'
fs/yaffs2/yaffs_fs.c: In function 'yaffs_read_super':
fs/yaffs2/yaffs_fs.c:2562: error: implicit declaration of function 'get_sb_bdev'
fs/yaffs2/yaffs_fs.c: At top level:
fs/yaffs2/yaffs_fs.c:2579: error: unknown field 'get_sb' specified in initializer
fs/yaffs2/yaffs_fs.c:2579: warning: initialization makes integer from pointer without a cast
fs/yaffs2/yaffs_fs.c:2626: error: unknown field 'get_sb' specified in initializer
fs/yaffs2/yaffs_fs.c:2626: warning: initialization makes integer from pointer without a cast
make[2]: *** [fs/yaffs2/yaffs_fs.o] 错误 1
make[1]: *** [fs/yaffs2] 错误 2



My board is 23c2440 kernel version:2.6.39.

 		 	   		  ÿôèº{.nÇ+‰·Ÿ®‰­†+%ŠËÿ±éݶ\x17¥Šwÿº{.nÇ+‰·¥Š{±þG«éÿŠ{ayº\x1dʇڙë,j\a­¢f£¢·hšïêÿ‘êçz_è®\x03(­éšŽŠÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?™¨è­Ú&£ø§~á¶iO•æ¬z·švØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?–I¥

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

* Re: [PATCH] sched: track "isolated" cpus like other cpu masks.
  2011-05-20 20:29 [PATCH] sched: track "isolated" cpus like other cpu masks Geoff Thorpe
  2011-05-21  3:06 ` yaff2 support ym cheng
@ 2011-05-23 20:14 ` Peter Zijlstra
  2011-05-26 16:38   ` Geoff Thorpe
  1 sibling, 1 reply; 4+ messages in thread
From: Peter Zijlstra @ 2011-05-23 20:14 UTC (permalink / raw)
  To: Geoff Thorpe; +Cc: linux-kernel

On Fri, 2011-05-20 at 16:29 -0400, Geoff Thorpe wrote:
> When a subset of cpus have been isolated, it can be useful for subsystems
> or drivers that have cpu-affinity concerns to have access to this mask
> (just like the other cpu masks; "possible", "present", "active" and
> "online"). Eg. to provide specific handling for isolated cpus, or to
> determine the non-isolated cpus (which is what sched.c uses it for).

Nobody should be using that, isolated CPUs is a 'feature' slated for
removal.


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

* Re: [PATCH] sched: track "isolated" cpus like other cpu masks.
  2011-05-23 20:14 ` [PATCH] sched: track "isolated" cpus like other cpu masks Peter Zijlstra
@ 2011-05-26 16:38   ` Geoff Thorpe
  0 siblings, 0 replies; 4+ messages in thread
From: Geoff Thorpe @ 2011-05-26 16:38 UTC (permalink / raw)
  To: Peter Zijlstra; +Cc: linux-kernel

On 11-05-23 04:14 PM, Peter Zijlstra wrote:
> On Fri, 2011-05-20 at 16:29 -0400, Geoff Thorpe wrote:
>> When a subset of cpus have been isolated, it can be useful for subsystems
>> or drivers that have cpu-affinity concerns to have access to this mask
>> (just like the other cpu masks; "possible", "present", "active" and
>> "online"). Eg. to provide specific handling for isolated cpus, or to
>> determine the non-isolated cpus (which is what sched.c uses it for).
>
> Nobody should be using that, isolated CPUs is a 'feature' slated for
> removal.
>

Ah OK, I wasn't aware of that. Consider the patch dropped then.

Thanks,
Geoff


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

end of thread, other threads:[~2011-05-26 16:38 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-20 20:29 [PATCH] sched: track "isolated" cpus like other cpu masks Geoff Thorpe
2011-05-21  3:06 ` yaff2 support ym cheng
2011-05-23 20:14 ` [PATCH] sched: track "isolated" cpus like other cpu masks Peter Zijlstra
2011-05-26 16:38   ` Geoff Thorpe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).