Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752565AbdHAUzM (ORCPT ); Tue, 1 Aug 2017 16:55:12 -0400 Received: from terminus.zytor.com ([65.50.211.136]:34185 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752310AbdHAUzL (ORCPT ); Tue, 1 Aug 2017 16:55:11 -0400 Date: Tue, 1 Aug 2017 13:54:03 -0700 From: tip-bot for Vikas Shivappa Message-ID: Cc: linux-kernel@vger.kernel.org, vikas.shivappa@linux.intel.com, hpa@zytor.com, tglx@linutronix.de, mingo@kernel.org Reply-To: linux-kernel@vger.kernel.org, vikas.shivappa@linux.intel.com, mingo@kernel.org, hpa@zytor.com, tglx@linutronix.de In-Reply-To: <1501017287-28083-21-git-send-email-vikas.shivappa@linux.intel.com> References: <1501017287-28083-21-git-send-email-vikas.shivappa@linux.intel.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/cache] x86/intel_rdt: Separate the ctrl bits from rmdir Git-Commit-ID: f9049547f7e72377049d717354b2f56f36a5854a X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3170 Lines: 103 Commit-ID: f9049547f7e72377049d717354b2f56f36a5854a Gitweb: http://git.kernel.org/tip/f9049547f7e72377049d717354b2f56f36a5854a Author: Vikas Shivappa AuthorDate: Tue, 25 Jul 2017 14:14:39 -0700 Committer: Thomas Gleixner CommitDate: Tue, 1 Aug 2017 22:41:26 +0200 x86/intel_rdt: Separate the ctrl bits from rmdir Re-factor the code to separate the ctrl group removal from the rmdir to prepare to add RDT monitoring group removal. Signed-off-by: Vikas Shivappa Signed-off-by: Thomas Gleixner Cc: ravi.v.shankar@intel.com Cc: tony.luck@intel.com Cc: fenghua.yu@intel.com Cc: peterz@infradead.org Cc: eranian@google.com Cc: vikas.shivappa@intel.com Cc: ak@linux.intel.com Cc: davidcc@google.com Cc: reinette.chatre@intel.com Link: http://lkml.kernel.org/r/1501017287-28083-21-git-send-email-vikas.shivappa@linux.intel.com --- arch/x86/kernel/cpu/intel_rdt_rdtgroup.c | 48 ++++++++++++++++++++++---------- 1 file changed, 33 insertions(+), 15 deletions(-) diff --git a/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c b/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c index 59de36d..3b62287 100644 --- a/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c +++ b/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c @@ -1565,20 +1565,10 @@ static int rdtgroup_mkdir(struct kernfs_node *parent_kn, const char *name, return -EPERM; } -static int rdtgroup_rmdir(struct kernfs_node *kn) +static int rdtgroup_rmdir_ctrl(struct kernfs_node *kn, struct rdtgroup *rdtgrp, + cpumask_var_t tmpmask) { - int ret, cpu, closid = rdtgroup_default.closid; - struct rdtgroup *rdtgrp; - cpumask_var_t tmpmask; - - if (!zalloc_cpumask_var(&tmpmask, GFP_KERNEL)) - return -ENOMEM; - - rdtgrp = rdtgroup_kn_lock_live(kn); - if (!rdtgrp) { - ret = -EPERM; - goto out; - } + int cpu; /* Give any tasks back to the default group */ rdt_move_group_tasks(rdtgrp, &rdtgroup_default, tmpmask); @@ -1589,7 +1579,7 @@ static int rdtgroup_rmdir(struct kernfs_node *kn) /* Update per cpu closid of the moved CPUs first */ for_each_cpu(cpu, &rdtgrp->cpu_mask) - per_cpu(rdt_cpu_default.closid, cpu) = closid; + per_cpu(rdt_cpu_default.closid, cpu) = rdtgroup_default.closid; /* * Update the MSR on moved CPUs and CPUs which have moved * task running on them. @@ -1607,7 +1597,35 @@ static int rdtgroup_rmdir(struct kernfs_node *kn) */ kernfs_get(kn); kernfs_remove(rdtgrp->kn); - ret = 0; + + return 0; +} + +static int rdtgroup_rmdir(struct kernfs_node *kn) +{ + struct kernfs_node *parent_kn = kn->parent; + struct rdtgroup *rdtgrp; + cpumask_var_t tmpmask; + int ret = 0; + + if (!zalloc_cpumask_var(&tmpmask, GFP_KERNEL)) + return -ENOMEM; + + rdtgrp = rdtgroup_kn_lock_live(kn); + if (!rdtgrp) { + ret = -EPERM; + goto out; + } + + /* + * If the rdtgroup is a ctrl_mon group and parent directory + * is the root directory, remove the ctrl group. + */ + if (rdtgrp->type == RDTCTRL_GROUP && parent_kn == rdtgroup_default.kn) + ret = rdtgroup_rmdir_ctrl(kn, rdtgrp, tmpmask); + else + ret = -EPERM; + out: rdtgroup_kn_unlock(kn); free_cpumask_var(tmpmask);