Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1987993imm; Tue, 22 May 2018 12:42:57 -0700 (PDT) X-Google-Smtp-Source: AB8JxZr9Dre+OqgSb+4tY7tY8Dm7xCKRganY9QcLahUYspK0P2LIVDrPhLAWmJhqa009ph3G7NU2 X-Received: by 2002:a65:6354:: with SMTP id p20-v6mr20411794pgv.437.1527018177255; Tue, 22 May 2018 12:42:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527018177; cv=none; d=google.com; s=arc-20160816; b=mwKhFnQR9vyjY7hKdUA0DZFDygyRueWJkqP5HAGfPXk21jM7fW8BH1lqHrzHYIsY1A WOElV28gfSn7xM9EKjcGKnQiD790rcrhpCyQwg9YjqSM4xQMZDYUosk06zAa6Dm6JCN5 5HdWjwOvmYxselxfnNqs+hNacVIEklma1vN3Q/wougbmXtrnCvF+TpcyRrbVU3Evyy3N ks5GZXjk3sKaJrNZzS5YdD85ybjNTiwMcNaXibImRWl/xyrC+lnDhA5gAQFu8cgHAqGM 18Wk7FRpFuVaIwR1HTBpxL5Rmm7BoPPMVee4oYS7DA5/pRAeZOFcKV2I5w/xrXNoixIL vQ7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=zysa2xTsIQeKTvEl0HQpDrdKjYM2t7ny/qsA+EDIiUM=; b=EZ4clcocSgQhbixE8Rj/XLpmF015wk3P+/pVBVkQj+M4QqS4LXj3rsbGa4l/fmBaf1 97IsK+h3pzYsZs1GBqoZvmuAwWqS8Q+GpSWxu3BA23Ago+c/1zWhnqTcW4DL+x+QdC97 BF/uzgzAlramdo76CUvpTY6ZTGPLshxwfCQabAXjM3/cR5qoUE2lcgEWrs6NX76fjbNd lgYseQRJvphCke0xF6Y0G0IM0dmv+HdFLkamT6hzDp+Jx1w6l8/VXI/hOg0jPOFNJ8zD 250cGgwl6HlWbFiJGcZhmzNbnsj5CgPTp0YB8Ipqj5bc395F1tj5lHeS4Qa2AN8qUFL3 vagQ== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f5-v6si16517705plr.247.2018.05.22.12.42.32; Tue, 22 May 2018 12:42:57 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753022AbeEVTje (ORCPT + 99 others); Tue, 22 May 2018 15:39:34 -0400 Received: from mga04.intel.com ([192.55.52.120]:18867 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752323AbeEVTcC (ORCPT ); Tue, 22 May 2018 15:32:02 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 May 2018 12:32:00 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,430,1520924400"; d="scan'208";a="226406389" Received: from rchatre-s.jf.intel.com ([10.54.70.76]) by orsmga005.jf.intel.com with ESMTP; 22 May 2018 12:32:00 -0700 From: Reinette Chatre To: tglx@linutronix.de, fenghua.yu@intel.com, tony.luck@intel.com, vikas.shivappa@linux.intel.com Cc: gavin.hindman@intel.com, jithu.joseph@intel.com, dave.hansen@intel.com, mingo@redhat.com, hpa@zytor.com, x86@kernel.org, linux-kernel@vger.kernel.org, Reinette Chatre Subject: [PATCH V4 18/38] x86/intel_rdt: Add utility to test if tasks assigned to resource group Date: Tue, 22 May 2018 04:29:06 -0700 Message-Id: X-Mailer: git-send-email 2.13.6 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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 7d623d940e49..f431ab493339 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) { -- 2.13.6