Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp1903603imm; Sat, 23 Jun 2018 05:18:11 -0700 (PDT) X-Google-Smtp-Source: ADUXVKL/Sb+WvepivF6kTRPsm5SMFbqeymRslWJQ0Zg6tMLDxk3uHqE6bwerZ8IxjU9a/mYg0ATt X-Received: by 2002:a65:538e:: with SMTP id x14-v6mr4679205pgq.330.1529756291284; Sat, 23 Jun 2018 05:18:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529756291; cv=none; d=google.com; s=arc-20160816; b=exys12RLY+NWTFEaGAgO5FV/gMVBrxecfmkoSZI4z/V0kjo0Ok/dUziU0GVFYzrP5K 1p3IEJeDV83qpKGhlPrEYw5t8fhrt5zIKXlw6lOeLGipDYAr6+6MC+W7zOmZyLJFhnLI PLpwU3aL6kdeUPStBVIDBjGfQKsrSJTcJ5vD5G98XIPhvx56IjDeWrym6qs4jxAvTYjl LY8UvQWFa9Env9FSLMO58e9aRsjgiq0sqqxwyPRAoXeTmx6WEIiHwryIC4Q/6XUuXRy3 EDueRgSExQHr8T7hL7MJ/fRBdzG218OzzfeoZslAdCBHmhDkaO496VuUSfo7krgfRDqE 329g== 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=JmGF2kOs4tLkqGd6676AEZyOrOtH7jKqYr6rBRk6J4w=; b=jDBjgV09YpqaLmyPTC/9QWzikv+6rmDMV9kk2WIoZb+FxqzZ6vToHT9y+wqpdZAA7K og3kkq+JLebxx2ptiNkxBoI4QtCh419qubQ5xotQdEep1q1X42Qolwnd9KuwPOKuJhe+ YpUjbjF1THR2BJZb1Kihq7uDQj4HC8C4yLWKPBKsVdcxcIrjNX3vkaf8oHW0fMX82kyK BEDpfR2qu7T2mh5Ac1pJc6TT2fi70MnwHUzi5YauuJF5BOl6tAup2Dfj8rCnN5sCg1QC LVC8Qsxr+knOBhoefzkpmLRQghMENUZIEC3+2bJ4SVlAY9PzgzBiYU/1f0+HRiEiGJ7Q /VpA== 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 f26-v6si7852566pgn.247.2018.06.23.05.17.56; Sat, 23 Jun 2018 05:18:11 -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 S1752101AbeFWMQt (ORCPT + 99 others); Sat, 23 Jun 2018 08:16:49 -0400 Received: from terminus.zytor.com ([198.137.202.136]:37579 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751640AbeFWMQs (ORCPT ); Sat, 23 Jun 2018 08:16:48 -0400 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTPS id w5NCGiAj464460 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Sat, 23 Jun 2018 05:16:44 -0700 Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id w5NCGiuV464456; Sat, 23 Jun 2018 05:16:44 -0700 Date: Sat, 23 Jun 2018 05:16:44 -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: reinette.chatre@intel.com, linux-kernel@vger.kernel.org, hpa@zytor.com, tglx@linutronix.de, mingo@kernel.org Reply-To: reinette.chatre@intel.com, linux-kernel@vger.kernel.org, hpa@zytor.com, mingo@kernel.org, tglx@linutronix.de In-Reply-To: References: 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: f7a6e3f6f5ffa4926818ea2b3e8994ecef00b84f 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, 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: f7a6e3f6f5ffa4926818ea2b3e8994ecef00b84f Gitweb: https://git.kernel.org/tip/f7a6e3f6f5ffa4926818ea2b3e8994ecef00b84f Author: Reinette Chatre AuthorDate: Fri, 22 Jun 2018 15:42:10 -0700 Committer: Thomas Gleixner CommitDate: Sat, 23 Jun 2018 13:03:45 +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/be9ea3969ffd731dfd90c0ebcd5a0e0a2d135bb2.1529706536.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 7b872f2cc294..11c76c4b9a5e 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 6eb716765a3f..59e1de9fe2d5 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) {