Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753400AbdHWBvm (ORCPT ); Tue, 22 Aug 2017 21:51:42 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:38125 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753335AbdHWBvf (ORCPT ); Tue, 22 Aug 2017 21:51:35 -0400 From: Frederic Weisbecker To: LKML Cc: Frederic Weisbecker , Peter Zijlstra , Chris Metcalf , Thomas Gleixner , Luiz Capitulino , Christoph Lameter , "Paul E . McKenney" , Ingo Molnar , Mike Galbraith , Rik van Riel , Wanpeng Li Subject: [RFC PATCH 10/12] housekeeping: Affine unbound kthreads Date: Wed, 23 Aug 2017 03:51:09 +0200 Message-Id: <1503453071-952-11-git-send-email-fweisbec@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503453071-952-1-git-send-email-fweisbec@gmail.com> References: <1503453071-952-1-git-send-email-fweisbec@gmail.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2231 Lines: 64 We want to be able to force the kthreads affinity when we'll repinplement isolcpus= on top of housekeeping. Unfortunately many kthreads also override their own affinity so we may need to revisit some of them. Signed-off-by: Frederic Weisbecker Cc: Chris Metcalf Cc: Rik van Riel Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: Mike Galbraith Cc: Ingo Molnar Cc: Christoph Lameter Cc: Paul E. McKenney Cc: Wanpeng Li Cc: Luiz Capitulino --- include/linux/housekeeping.h | 1 + kernel/kthread.c | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/include/linux/housekeeping.h b/include/linux/housekeeping.h index 0959601..2a9b808 100644 --- a/include/linux/housekeeping.h +++ b/include/linux/housekeeping.h @@ -11,6 +11,7 @@ enum hk_flags { HK_FLAG_MISC = (1 << 2), HK_FLAG_SCHED = (1 << 3), HK_FLAG_WORKQUEUE = (1 << 4), + HK_FLAG_KTHREAD = (1 << 5), }; #ifdef CONFIG_CPU_ISOLATION diff --git a/kernel/kthread.c b/kernel/kthread.c index 26db528..d4f1e63 100644 --- a/kernel/kthread.c +++ b/kernel/kthread.c @@ -21,6 +21,7 @@ #include #include #include +#include #include static DEFINE_SPINLOCK(kthread_create_lock); @@ -317,7 +318,7 @@ struct task_struct *__kthread_create_on_node(int (*threadfn)(void *data), * The kernel thread should not inherit these properties. */ sched_setscheduler_nocheck(task, SCHED_NORMAL, ¶m); - set_cpus_allowed_ptr(task, cpu_all_mask); + set_cpus_allowed_ptr(task, housekeeping_cpumask(HK_FLAG_KTHREAD)); } kfree(create); return task; @@ -536,7 +537,7 @@ int kthreadd(void *unused) /* Setup a clean context for our children to inherit. */ set_task_comm(tsk, "kthreadd"); ignore_signals(tsk); - set_cpus_allowed_ptr(tsk, cpu_all_mask); + set_cpus_allowed_ptr(tsk, housekeeping_cpumask(HK_FLAG_KTHREAD)); set_mems_allowed(node_states[N_MEMORY]); current->flags |= PF_NOFREEZE; -- 2.7.4