Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp122744imm; Tue, 19 Jun 2018 17:23:12 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIwX0Jb3rOJcvO3cJshy4tkzQEprN4IEaFI+jtn+ca3W2GjOEa6/tS4F5kIh+12BzCFrLom X-Received: by 2002:a17:902:c3:: with SMTP id a61-v6mr21267506pla.149.1529454192106; Tue, 19 Jun 2018 17:23:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529454192; cv=none; d=google.com; s=arc-20160816; b=aXmmN6UZ+msFy4Y1MJuKVt2yeiZM1n9Uj8h/spNyrt3zqrL9FZ1UrxaPFJoKxVsiWI NP6yYWaPg4vyZySSmvKQWwkD8vEhbOt1V6PW9MGXqXWDqqq6Lk4nUTb6N9qm9aqyt86z NbboU8iXFomZEb2sC997WimD1UdB/Wy1QG90FiWGkpNs3OAFmPe2Bs/xgEuP4SHJsoWy GoEOnJ/weLnUf+W25xFKvOuzkHL8/WEAk+zCuzAIsMBMJDX1QjUnmNldIwiK7c61Szrs HCg+HVUOakVKI93QvDt1tF68YFKLqcIBThG/xTioHV6hfzBAHwLYnpxlTDlQ2popvj2e wbSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:mime-version:robot-unsubscribe:robot-id :git-commit-id:subject:to:references:in-reply-to:reply-to:cc :message-id:from:date:arc-authentication-results; bh=gz1UjrBBbMZ9HJNc/m5ljDAMhk8PYDCZOVqjGv8fWVk=; b=j6wcdU3yYslMw31aN/5XZua9lkA2Pcr+6C/d2z7qqeowKRb6+3f9tnFdaa7aLRvgnP r0pm4ALBvdrBC0nULoBIjeEQ41MdDY2T51/Trn6nmm2CrUI6Le+LNJILbUm6t4WTdUIh uQt9uCK9yoiqfc4MrlaBQC2fb74Yx8IcC5jYUWA3n6D4YthR0FKzyhzkAoDsvCCwhVIl Rv2MdW05CB8tF8ODn7mKYmCnsboQ8Rrtkuv6eTsnDR5AfxAzLg7Czw343rjl2XYBVIAI CGgo/jj7EW6MFaPZVyfghy4hm5rda1T6yHDM1gWqybE5iWKf9iH9ndNyfU8yiPGMQtXa OmuQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q8-v6si831774pgf.40.2018.06.19.17.22.58; Tue, 19 Jun 2018 17:23:12 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753862AbeFTAWR (ORCPT + 99 others); Tue, 19 Jun 2018 20:22:17 -0400 Received: from terminus.zytor.com ([198.137.202.136]:36531 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750929AbeFTAWN (ORCPT ); Tue, 19 Jun 2018 20:22:13 -0400 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTPS id w5K0M9sU3297576 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 19 Jun 2018 17:22:09 -0700 Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id w5K0M9cH3297573; Tue, 19 Jun 2018 17:22:09 -0700 Date: Tue, 19 Jun 2018 17:22:09 -0700 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for Reinette Chatre Message-ID: Cc: mingo@kernel.org, tglx@linutronix.de, linux-kernel@vger.kernel.org, hpa@zytor.com, reinette.chatre@intel.com Reply-To: tglx@linutronix.de, mingo@kernel.org, reinette.chatre@intel.com, hpa@zytor.com, linux-kernel@vger.kernel.org In-Reply-To: <9149005d01de4b197bae13a45e6efdb536383ca1.1527593970.git.reinette.chatre@intel.com> References: <9149005d01de4b197bae13a45e6efdb536383ca1.1527593970.git.reinette.chatre@intel.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/cache] x86/intel_rdt: Add utility to test if tasks assigned to resource group Git-Commit-ID: dd0cd63323fc59c5e232c3d03ad4a2a73fc07395 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 X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00, T_DATE_IN_FUTURE_96_Q autolearn=ham autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on terminus.zytor.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: dd0cd63323fc59c5e232c3d03ad4a2a73fc07395 Gitweb: https://git.kernel.org/tip/dd0cd63323fc59c5e232c3d03ad4a2a73fc07395 Author: Reinette Chatre AuthorDate: Tue, 29 May 2018 05:57:43 -0700 Committer: Thomas Gleixner CommitDate: Wed, 20 Jun 2018 00:56:33 +0200 x86/intel_rdt: Add utility to test if tasks assigned to resource group In considering changes to a resource group it becomes necessary to know whether tasks have been assigned to the resource group in question. Introduce a new utility that can be used to check if any tasks have been assigned to a particular resource group. Signed-off-by: Reinette Chatre Signed-off-by: Thomas Gleixner Cc: fenghua.yu@intel.com Cc: tony.luck@intel.com Cc: vikas.shivappa@linux.intel.com Cc: gavin.hindman@intel.com Cc: jithu.joseph@intel.com Cc: dave.hansen@intel.com Cc: hpa@zytor.com Link: https://lkml.kernel.org/r/9149005d01de4b197bae13a45e6efdb536383ca1.1527593970.git.reinette.chatre@intel.com --- arch/x86/kernel/cpu/intel_rdt.h | 1 + arch/x86/kernel/cpu/intel_rdt_rdtgroup.c | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/arch/x86/kernel/cpu/intel_rdt.h b/arch/x86/kernel/cpu/intel_rdt.h index bda87f5ef7bc..10a1539cbec6 100644 --- a/arch/x86/kernel/cpu/intel_rdt.h +++ b/arch/x86/kernel/cpu/intel_rdt.h @@ -480,6 +480,7 @@ bool rdtgroup_cbm_overlaps(struct rdt_resource *r, struct rdt_domain *d, unsigned int rdtgroup_cbm_to_size(struct rdt_resource *r, struct rdt_domain *d, u32 cbm); enum rdtgrp_mode rdtgroup_mode_by_closid(int closid); +int rdtgroup_tasks_assigned(struct rdtgroup *r); struct rdt_domain *get_domain_from_cpu(int cpu, struct rdt_resource *r); int update_domains(struct rdt_resource *r, int closid); void closid_free(int closid); diff --git a/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c b/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c index 0ddb455b126d..be692e154546 100644 --- a/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c +++ b/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c @@ -564,6 +564,32 @@ static int __rdtgroup_move_task(struct task_struct *tsk, return ret; } +/** + * rdtgroup_tasks_assigned - Test if tasks have been assigned to resource group + * @r: Resource group + * + * Return: 1 if tasks have been assigned to @r, 0 otherwise + */ +int rdtgroup_tasks_assigned(struct rdtgroup *r) +{ + struct task_struct *p, *t; + int ret = 0; + + lockdep_assert_held(&rdtgroup_mutex); + + rcu_read_lock(); + for_each_process_thread(p, t) { + if ((r->type == RDTCTRL_GROUP && t->closid == r->closid) || + (r->type == RDTMON_GROUP && t->rmid == r->mon.rmid)) { + ret = 1; + break; + } + } + rcu_read_unlock(); + + return ret; +} + static int rdtgroup_task_write_permission(struct task_struct *task, struct kernfs_open_file *of) {