Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp2048621ybv; Fri, 14 Feb 2020 10:26:36 -0800 (PST) X-Google-Smtp-Source: APXvYqypxfQC6zNrboOXK0qgFcGje0/exPseVMOuN0l6fqbpSHL5dS8QLWo14lX3mVr4X0PfYnC+ X-Received: by 2002:a9d:6290:: with SMTP id x16mr3217944otk.343.1581704796300; Fri, 14 Feb 2020 10:26:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581704796; cv=none; d=google.com; s=arc-20160816; b=TKLHOJuPxyD3ZtzYcEglqiQuTPjzTghLbB9+53FgyvrT814GpPJvAiszKfMfeiOOxs zz3dlVt7Vd0FFgCpv5V4KI7nqbyd/SaXZ+GGUI2ClDvD5/rPxrBes8lp/8DvIr8fOtOw faPLKQ6cOFPFK+QZf+L0AmK74b7PGC70AtZuSJzktKED9mJTPrZzRrFQ0QUdZCl/OGZP f0jQSGNaYTPczKCmlNg6bDW40/RTeMa0rdz7J2zJNZ21M0U5XbCuNVB3BXQG8qDIBJ+7 uLRBazloWM2dqLBlFEaJsSD3HKaaGLsjKcO1Xc6EmikF44LQoDflhr/HRXBFwfA3rgAE XDVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=LnY+qaolM9/YUoCDtFdwYWgN8k0/TjCkJVpeGoOJqcA=; b=Yn6cRBWVl/xtu06x3Yf1pCPjP++6/EmSxuw6EeehFRpF5GmZC+pHLTfcsZSabaXzau m8dwb6rxCe+/i4fKiKcvaXEW2wTba6JAoMkWrXsyCxnR+pU40H2IWGbnszYkLRPzMTP/ P77tvGdKjpi/saRihzSneNCnvtTukxgjSZBhlccMDPR8Y/lejuEjti2ONmeRxmslbLiL JHYA8ATzsZ1955YhVSuVl8VkQjmzgVBUOkjLIfGaHA4IjeOKkn0+BmFT3a29RcfX7lpo UY+T4Owc7Xi5js7bankTjg95msRNwiY9L0Ar2/b5DEzbmBZEQV5ee803dSwA52V86Qug a5Zg== 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 i13si3314034otc.228.2020.02.14.10.26.24; Fri, 14 Feb 2020 10:26:36 -0800 (PST) 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 S2394937AbgBNSYw (ORCPT + 99 others); Fri, 14 Feb 2020 13:24:52 -0500 Received: from foss.arm.com ([217.140.110.172]:43308 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405588AbgBNSYs (ORCPT ); Fri, 14 Feb 2020 13:24:48 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id E6633101E; Fri, 14 Feb 2020 10:24:47 -0800 (PST) Received: from eglon.cambridge.arm.com (eglon.cambridge.arm.com [10.1.196.105]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 9803D3F68E; Fri, 14 Feb 2020 10:24:46 -0800 (PST) From: James Morse To: x86@kernel.org, linux-kernel@vger.kernel.org Cc: Fenghua Yu , Reinette Chatre , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H . Peter Anvin" , Babu Moger , James Morse Subject: [PATCH 06/10] x86/resctrl: Use is_closid_match() in more places Date: Fri, 14 Feb 2020 18:23:57 +0000 Message-Id: <20200214182401.39008-7-james.morse@arm.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200214182401.39008-1-james.morse@arm.com> References: <20200214182401.39008-1-james.morse@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org rdtgroup_tasks_assigned() and show_rdt_tasks() loop over threads testing for a CTRL/MON group match by closid/rmid with the provided rdtgrp. Further down the file are helpers to do this, move these further up and make use of them here. These helpers additionally check for alloc/mon capable. This is harmless as rdtgroup_mkdir() tests these capable flags before allowing the config directories to be created. Signed-off-by: James Morse --- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 30 ++++++++++++-------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/resctrl/rdtgroup.c index fef09105cbe4..c84b1f355a9a 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -592,6 +592,18 @@ static int __rdtgroup_move_task(struct task_struct *tsk, return ret; } +static bool is_closid_match(struct task_struct *t, struct rdtgroup *r) +{ + return (rdt_alloc_capable && + (r->type == RDTCTRL_GROUP) && (t->closid == r->closid)); +} + +static bool is_rmid_match(struct task_struct *t, struct rdtgroup *r) +{ + return (rdt_mon_capable && + (r->type == RDTMON_GROUP) && (t->rmid == r->mon.rmid)); +} + /** * rdtgroup_tasks_assigned - Test if tasks have been assigned to resource group * @r: Resource group @@ -607,8 +619,7 @@ int rdtgroup_tasks_assigned(struct rdtgroup *r) 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)) { + if (is_closid_match(t, r) || is_rmid_match(t, r)) { ret = 1; break; } @@ -706,8 +717,7 @@ static void show_rdt_tasks(struct rdtgroup *r, struct seq_file *s) 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)) + if (is_closid_match(t, r) || is_rmid_match(t, r)) seq_printf(s, "%d\n", t->pid); } rcu_read_unlock(); @@ -2231,18 +2241,6 @@ static int reset_all_ctrls(struct rdt_resource *r) return 0; } -static bool is_closid_match(struct task_struct *t, struct rdtgroup *r) -{ - return (rdt_alloc_capable && - (r->type == RDTCTRL_GROUP) && (t->closid == r->closid)); -} - -static bool is_rmid_match(struct task_struct *t, struct rdtgroup *r) -{ - return (rdt_mon_capable && - (r->type == RDTMON_GROUP) && (t->rmid == r->mon.rmid)); -} - /* * Move tasks from one to the other group. If @from is NULL, then all tasks * in the systems are moved unconditionally (used for teardown). -- 2.24.1