lkml.org 
[lkml]   [2015]   [Apr]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH v4 1/2] smpboot: allow excluding cpus from the smpboot threads
Date
From: Chris Metcalf <cmetcalf@ezchip.com>

This change allows some cores to be excluded from running the
smp_hotplug_thread tasks. The motivating example for this is
the watchdog threads, which by default we don't want to run
on any enabled nohz_full cores.

Signed-off-by: Chris Metcalf <cmetcalf@ezchip.com>
---
Relative to the quick diff I emailed out yesterday (sorry missed
adding Thomas to that one), this change uses a notion of "exclude_mask"
for smp_hotplug_thread. I think this is a better fit in general to
the idea that smp_hotplug_thread should run everywhere (including on
any newly-onlined cpus), EXCEPT for cores that have been specifically
tagged as reserved for some reason. Obviously for nohz_full we have
the nohz_full boot argument to use for this at the moment.

Thomas, Peter, how does this look to you?

include/linux/smpboot.h | 2 ++
kernel/smpboot.c | 11 ++++++++---
2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/include/linux/smpboot.h b/include/linux/smpboot.h
index 13e929679550..0631964525f7 100644
--- a/include/linux/smpboot.h
+++ b/include/linux/smpboot.h
@@ -27,6 +27,7 @@ struct smpboot_thread_data;
* @pre_unpark: Optional unpark function, called before the thread is
* unparked (cpu online). This is not guaranteed to be
* called on the target cpu of the thread. Careful!
+ * @exclude_mask: Optional cpumask, specifying cores to exclude.
* @selfparking: Thread is not parked by the park function.
* @thread_comm: The base name of the thread
*/
@@ -41,6 +42,7 @@ struct smp_hotplug_thread {
void (*park)(unsigned int cpu);
void (*unpark)(unsigned int cpu);
void (*pre_unpark)(unsigned int cpu);
+ cpumask_t *exclude_mask;
bool selfparking;
const char *thread_comm;
};
diff --git a/kernel/smpboot.c b/kernel/smpboot.c
index 40190f28db35..7df326ed80eb 100644
--- a/kernel/smpboot.c
+++ b/kernel/smpboot.c
@@ -172,6 +172,9 @@ __smpboot_create_thread(struct smp_hotplug_thread *ht, unsigned int cpu)
if (tsk)
return 0;

+ if (ht->exclude_mask && cpumask_test_cpu(cpu, ht->exclude_mask))
+ return 0;
+
td = kzalloc_node(sizeof(*td), GFP_KERNEL, cpu_to_node(cpu));
if (!td)
return -ENOMEM;
@@ -220,9 +223,11 @@ static void smpboot_unpark_thread(struct smp_hotplug_thread *ht, unsigned int cp
{
struct task_struct *tsk = *per_cpu_ptr(ht->store, cpu);

- if (ht->pre_unpark)
- ht->pre_unpark(cpu);
- kthread_unpark(tsk);
+ if (tsk) {
+ if (ht->pre_unpark)
+ ht->pre_unpark(cpu);
+ kthread_unpark(tsk);
+ }
}

void smpboot_unpark_threads(unsigned int cpu)
--
2.1.2


\
 
 \ /
  Last update: 2015-04-03 18:41    [W:0.201 / U:1.116 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site