Skip to content

Commit 60ba9c3

Browse files
author
Frederic Weisbecker
committed
kthread: Comment on the purpose and placement of kthread_affine_node() call
It may not appear obvious why kthread_affine_node() is not called before the kthread creation completion instead of after the first wake-up. The reason is that kthread_affine_node() applies a default affinity behaviour that only takes place if no affinity preference have already been passed by the kthread creation call site. Add a comment to clarify that. Reported-by: Peter Zijlstra <peterz@infradead.org> Signed-off-by: Frederic Weisbecker <frederic@kernel.org> Cc: Marco Crivellari <marco.crivellari@suse.com> Cc: Michal Hocko <mhocko@suse.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Tejun Heo <tj@kernel.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Vlastimil Babka <vbabka@suse.cz> Cc: Waiman Long <longman@redhat.com>
1 parent e894f63 commit 60ba9c3

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

kernel/kthread.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,10 @@ static int kthread(void *_create)
453453

454454
self->started = 1;
455455

456+
/*
457+
* Apply default node affinity if no call to kthread_bind[_mask]() nor
458+
* kthread_affine_preferred() was issued before the first wake-up.
459+
*/
456460
if (!(current->flags & PF_NO_SETAFFINITY) && !self->preferred_affinity)
457461
kthread_affine_node();
458462

0 commit comments

Comments
 (0)