Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions Documentation/kernel-parameters.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1623,6 +1623,16 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
kstack=N [X86] Print N words from the kernel stack
in oops dumps.

kthread= [KNL, SMP] Only run kernel threads on the specified
list of processors. The kernel will start threads
on the indicated processors only (unless there
are specific reasons to run a thread with
different affinities). This can be used to make
init start on certain processors and also to
control where kmod and other user space threads
are being spawned. Allows to keep kernel threads
away from certain cores unless absoluteluy necessary.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo in absoluteluy


kvm.ignore_msrs=[KVM] Ignore guest accesses to unhandled MSRs.
Default is 0 (don't ignore, but inject #GP)

Expand Down
2 changes: 2 additions & 0 deletions include/linux/cpumask.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ extern int nr_cpu_ids;
* 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_kthread_mask - has bit 'cpu' set iff general kernel threads allowed
*
* If !CONFIG_HOTPLUG_CPU, present == possible, and active == online.
*
Expand Down Expand Up @@ -80,6 +81,7 @@ 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_kthread_mask;

#if NR_CPUS > 1
#define num_online_cpus() cpumask_weight(cpu_online_mask)
Expand Down
13 changes: 13 additions & 0 deletions kernel/cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -754,6 +754,19 @@ 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_kthread_bits, CONFIG_NR_CPUS) __read_mostly
= CPU_BITS_ALL;
const struct cpumask *const cpu_kthread_mask = to_cpumask(cpu_kthread_bits);
EXPORT_SYMBOL(cpu_kthread_mask);

static int __init kthread_setup(char *str)
{
cpulist_parse(str, (struct cpumask *)&cpu_kthread_bits);
return 1;
}
__setup("kthread=", kthread_setup);


void set_cpu_possible(unsigned int cpu, bool possible)
{
if (possible)
Expand Down
4 changes: 2 additions & 2 deletions kernel/kmod.c
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,8 @@ static int ____call_usermodehelper(void *data)
flush_signal_handlers(current, 1);
spin_unlock_irq(&current->sighand->siglock);

/* We can run anywhere, unlike our parent keventd(). */
set_cpus_allowed_ptr(current, cpu_all_mask);
/* We can run only where init is allowed to run. */
set_cpus_allowed_ptr(current, cpu_kthread_mask);

/*
* Our parent is keventd, which runs with elevated scheduling priority.
Expand Down
2 changes: 2 additions & 0 deletions kernel/kthread.c
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@ struct task_struct *kthread_create_on_node(int (*threadfn)(void *data),
*/
sched_setscheduler_nocheck(task, SCHED_NORMAL, &param);
set_cpus_allowed_ptr(task, cpu_all_mask);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are both of these lines still here? Isn't there one line where they can be scheduled anywhere?

set_cpus_allowed_ptr(task, cpu_kthread_mask);
}
kfree(create);
return task;
Expand Down Expand Up @@ -488,6 +489,7 @@ int kthreadd(void *unused)
set_task_comm(tsk, "kthreadd");
ignore_signals(tsk);
set_cpus_allowed_ptr(tsk, cpu_all_mask);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment here

set_cpus_allowed_ptr(tsk, cpu_kthread_mask);
set_mems_allowed(node_states[N_MEMORY]);

current->flags |= PF_NOFREEZE;
Expand Down
2 changes: 2 additions & 0 deletions kernel/workqueue.c
Original file line number Diff line number Diff line change
Expand Up @@ -3815,6 +3815,7 @@ int apply_workqueue_attrs(struct workqueue_struct *wq,
/* make a copy of @attrs and sanitize it */
copy_workqueue_attrs(new_attrs, attrs);
cpumask_and(new_attrs->cpumask, new_attrs->cpumask, cpu_possible_mask);
cpumask_and(new_attrs->cpumask, new_attrs->cpumask, cpu_kthread_mask);

/*
* We may create multiple pwqs with differing cpumasks. Make a
Expand Down Expand Up @@ -4583,6 +4584,7 @@ static void restore_unbound_workers_cpumask(struct worker_pool *pool, int cpu)

/* is @cpu the only online CPU? */
cpumask_and(&cpumask, pool->attrs->cpumask, cpu_online_mask);
cpumask_and(&cpumask, pool->attrs->cpumask, cpu_kthread_mask);
if (cpumask_weight(&cpumask) != 1)
return;

Expand Down