Received: by 10.192.165.148 with SMTP id m20csp1024420imm; Wed, 25 Apr 2018 11:18:38 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+YSGXzhcWy9KG3r488FCKNL5uGZpJVTzOB4z48qKVu1L6GuDl3woNETyiHcpTnvrg2hyb4 X-Received: by 10.99.157.12 with SMTP id i12mr23716074pgd.87.1524680318646; Wed, 25 Apr 2018 11:18:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524680318; cv=none; d=google.com; s=arc-20160816; b=tertJNoNSUu9pbREMsaHfv0r1nuEfOb8jP/qsZAlvpBsONnSjiw1DsIJcef0RnXJ1g d8MFl4ZUHJlpiKtITRu1miRhdOH+zeIPJMzuenWMCG0WtKoi7devIlH9L8uRrNmdYadn +Je64lk1MjqqLmjMOfKutvB2umBKuQFrVe5XRJYkFWEJSKfIofRC3LUGDnsTwCvvJVem cftGlXqWHE2y0Etuc55PBWcr2tbZwS2LuD1nPCfiz7AUjBRSPa1x5MYCfUrMzVQM3GMM s8DVIw9sk73eiziT3+MvAelMf8b9L3NAMNaIoJDSNnvbPgLO9BY6NyQjno1ca2O1g42B SEmg== 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=VkgyAraet8MJQllF4AD4JvsNipMHXa+GVElktilqqiI=; b=wm9eOk/x/NqSEg0pebAFJnGDSWouv+dfMd8ewFMoMn/JAOHMyqYmPRNe8zpkkYL0rA 77yhCDEwE+NxXMnp1ksBRDvano58K9L3Kqy4xqAg49ZBruHixYY2OsfQikCRtRg8zf/r M1wJkiD1o066BDIQBzTCnMEqsgXx3iTfbq/TpgCLHVMPe3gV9GKwMu1hpw/+obFb6A+b b1wFbXWgYM+YthwEaOp0QYbtTNlPGr4TCQ65OhPZVguzWMwdgDSh34JAaR34HO5knpAr uTg/o+u6gZdxToMhckaRk9FAWA9xYvg6hwUHWp66Em7Kcv5ypT1/EEqY2zf9LFGLUs2F sArw== 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 k3-v6si16401527pld.9.2018.04.25.11.18.24; Wed, 25 Apr 2018 11:18:38 -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 S932288AbeDYSNF (ORCPT + 99 others); Wed, 25 Apr 2018 14:13:05 -0400 Received: from mga02.intel.com ([134.134.136.20]:41713 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932160AbeDYSMm (ORCPT ); Wed, 25 Apr 2018 14:12:42 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 Apr 2018 11:12:42 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,327,1520924400"; d="scan'208";a="35243691" Received: from rchatre-s.jf.intel.com ([10.54.70.76]) by fmsmga008.fm.intel.com with ESMTP; 25 Apr 2018 11:12:41 -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 V3 18/39] x86/intel_rdt: Add utility to test if tasks assigned to resource group Date: Wed, 25 Apr 2018 03:09:54 -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 fa2aa7e8ad73..e33b1215f394 100644 --- a/arch/x86/kernel/cpu/intel_rdt.h +++ b/arch/x86/kernel/cpu/intel_rdt.h @@ -465,6 +465,7 @@ int 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 541103a2dea0..f2da6a2827c8 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