Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752389AbdFZS5V (ORCPT ); Mon, 26 Jun 2017 14:57:21 -0400 Received: from mga09.intel.com ([134.134.136.24]:50178 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752020AbdFZSzf (ORCPT ); Mon, 26 Jun 2017 14:55:35 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.39,397,1493708400"; d="scan'208";a="985411499" From: Vikas Shivappa To: x86@kernel.org, linux-kernel@vger.kernel.org, tglx@linutronix.de Cc: hpa@zytor.com, peterz@infradead.org, ravi.v.shankar@intel.com, vikas.shivappa@intel.com, tony.luck@intel.com, fenghua.yu@intel.com, andi.kleen@intel.com Subject: [PATCH 12/21] x86/intel_rdt/cqm: Add tasks file support Date: Mon, 26 Jun 2017 11:55:59 -0700 Message-Id: <1498503368-20173-13-git-send-email-vikas.shivappa@linux.intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1498503368-20173-1-git-send-email-vikas.shivappa@linux.intel.com> References: <1498503368-20173-1-git-send-email-vikas.shivappa@linux.intel.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2736 Lines: 74 The root directory, ctrl_mon and monitor groups are populated with a read/write file named "tasks". When read, it shows all the task IDs assigned to the resource group. Tasks can be added to groups by writing the PID to the file. A task can be present in one "ctrl_mon" group "and" one "monitor" group. IOW a PID_x can be seen in a ctrl_mon group and a monitor group at the same time. When a task is added to a ctrl_mon group, it is automatically removed from the previous ctrl_mon group where it belonged. Similarly if a task is moved to a monitor group it is removed from the previous monitor group . Also since the monitor groups can only have subset of tasks of parent ctrl_mon group, a task can be moved to a monitor group only if its already present in the parent ctrl_mon group. Task membership is indicated by a new field in the task_struct "u32 rmid" which holds the RMID for the task. RMID=0 is reserved for the default root group where the tasks belong to at mount. Signed-off-by: Vikas Shivappa --- arch/x86/kernel/cpu/intel_rdt_rdtgroup.c | 18 ++++++++++++++++-- include/linux/sched.h | 1 + 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c b/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c index 36078c7..8fd0757 100644 --- a/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c +++ b/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c @@ -352,7 +352,20 @@ static int __rdtgroup_move_task(struct task_struct *tsk, atomic_dec(&rdtgrp->waitcount); kfree(callback); } else { - tsk->closid = rdtgrp->closid; + /* + * For ctrl_mon groups move both closid and rmid. + * For monitor groups, can move the tasks only from + * their parent CTRL group. + */ + if (rdtgrp->type == RDTCTRL_GROUP) { + tsk->closid = rdtgrp->closid; + tsk->rmid = rdtgrp->rmid; + } else if (rdtgrp->type == RDTMON_GROUP) { + if (rdtgrp->parent->closid == tsk->closid) + tsk->rmid = rdtgrp->rmid; + else + ret = -EINVAL; + } } return ret; } @@ -432,7 +445,8 @@ static void show_rdt_tasks(struct rdtgroup *r, struct seq_file *s) rcu_read_lock(); for_each_process_thread(p, t) { - if (t->closid == r->closid) + if ((r->type == RDTCTRL_GROUP && t->closid == r->closid) || + (r->type == RDTMON_GROUP && t->rmid == r->rmid)) seq_printf(s, "%d\n", t->pid); } rcu_read_unlock(); diff --git a/include/linux/sched.h b/include/linux/sched.h index 9e31b3d..6643692 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -866,6 +866,7 @@ struct task_struct { #endif #ifdef CONFIG_INTEL_RDT int closid; + u32 rmid; #endif #ifdef CONFIG_FUTEX struct robust_list_head __user *robust_list; -- 1.9.1