From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933215AbcIHHAw (ORCPT ); Thu, 8 Sep 2016 03:00:52 -0400 Received: from mga05.intel.com ([192.55.52.43]:41891 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932955AbcIHG60 (ORCPT ); Thu, 8 Sep 2016 02:58:26 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.30,298,1470726000"; d="scan'208";a="1052967070" From: "Fenghua Yu" To: "Thomas Gleixner" , "H. Peter Anvin" , "Ingo Molnar" , "Tony Luck" , "Peter Zijlstra" , "Tejun Heo" , "Borislav Petkov" , "Stephane Eranian" , "Marcelo Tosatti" , "David Carrillo-Cisneros" , "Shaohua Li" , "Ravi V Shankar" , "Vikas Shivappa" , "Sai Prakhya" Cc: "linux-kernel" , "x86" , Fenghua Yu Subject: [PATCH v2 26/33] Task fork and exit for rdtgroup Date: Thu, 8 Sep 2016 02:57:20 -0700 Message-Id: <1473328647-33116-27-git-send-email-fenghua.yu@intel.com> X-Mailer: git-send-email 1.8.0.1 In-Reply-To: <1473328647-33116-1-git-send-email-fenghua.yu@intel.com> References: <1473328647-33116-1-git-send-email-fenghua.yu@intel.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Fenghua Yu When a task is forked, it inherites its parent rdtgroup. The task can be moved to other rdtgroup during its run time. When the task exits, it's deleted from it's current rdtgroup's task list. Signed-off-by: Fenghua Yu Reviewed-by: Tony Luck --- arch/x86/kernel/cpu/intel_rdt_rdtgroup.c | 22 ++++++++++++++++++++++ kernel/exit.c | 2 ++ kernel/fork.c | 2 ++ 3 files changed, 26 insertions(+) diff --git a/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c b/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c index 7842194..acea62c 100644 --- a/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c +++ b/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c @@ -956,3 +956,25 @@ int __init rdtgroup_init(void) return 0; } + +void rdtgroup_fork(struct task_struct *child) +{ + struct rdtgroup *rdtgrp; + + INIT_LIST_HEAD(&child->rg_list); + if (!rdtgroup_mounted) + return; + + mutex_lock(&rdtgroup_mutex); + + rdtgrp = current->rdtgroup; + if (!rdtgrp) + goto out; + + list_add_tail(&child->rg_list, &rdtgrp->pset.tasks); + child->rdtgroup = rdtgrp; + atomic_inc(&rdtgrp->refcount); + +out: + mutex_unlock(&rdtgroup_mutex); +} diff --git a/kernel/exit.c b/kernel/exit.c index 091a78b..270ede6 100644 --- a/kernel/exit.c +++ b/kernel/exit.c @@ -54,6 +54,7 @@ #include #include #include +#include #include #include @@ -837,6 +838,7 @@ void do_exit(long code) perf_event_exit_task(tsk); cgroup_exit(tsk); + rdtgroup_exit(tsk); /* * FIXME: do that only when needed, using sched_exit tracepoint diff --git a/kernel/fork.c b/kernel/fork.c index beb3172..79bfc99 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -76,6 +76,7 @@ #include #include #include +#include #include #include @@ -1426,6 +1427,7 @@ static struct task_struct *copy_process(unsigned long clone_flags, p->io_context = NULL; p->audit_context = NULL; cgroup_fork(p); + rdtgroup_fork(p); #ifdef CONFIG_NUMA p->mempolicy = mpol_dup(p->mempolicy); if (IS_ERR(p->mempolicy)) { -- 2.5.0