Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp2059963ybz; Thu, 30 Apr 2020 10:08:35 -0700 (PDT) X-Google-Smtp-Source: APiQypJlNDcLZt8SZ1b2s7Q/uzL6Wr7S8C7YGFIKLV61+8z8wQsN3TvB/Lw/WrglRCmuOOMkqPxX X-Received: by 2002:a50:b286:: with SMTP id p6mr3645348edd.350.1588266515205; Thu, 30 Apr 2020 10:08:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588266515; cv=none; d=google.com; s=arc-20160816; b=jWL5I533hzvtFPl0w82duLMdLB+vwZPEGKV8OFjnxocUYSgquzSVFS5Gr+e3PhjZs+ FRndbb8eeaTyqUKSoZdAq55CZRFbMgcGYQCwCgZp4wO17wX7QEWaDrqOpJ/uo3dhXL0o QOjLR+SxdvO3sU+ctkTSqL9A49TRaEmmymNYJFrSKGEPeaiczTrtPyUynntTAMeh2FyR 1oRK0eHPnFioeSLx8hHBSbCG/6U5saHja9cLbINQkecSv51KolTI5LcxjhszvrNPSxrj v+p5QIGR9QPbxeWVaA7Q1PfJoKWpdA2hG+XbEvZw9kukcg0UmbJT9I9A/NLTx073mcaJ Mm1w== 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=eX+6TrJQpNyEzx4vVM99IGm0u7nUIyYoSIyeygeMMkA=; b=TdY/6YQunkhpI9eGrUXC1SwjV0XXx/CglGzf9dMJHCkTzoXVspvfRcNGIj4ouMPWCi byzMp7lInNBSyJLtIuwLE7+4lxNwd0d62gRySjWtZ1vhRZW3Xnk6K/H+DTNy5dq4clgm R1RBOZfbzN2DGDizPxc1eCol2lVnQIGy3nUxOXwV+SGFXc93rhGuS5ZF27l/Jwi1S4UG adsu7MuZkVs0Lm9hFHCbw1nMphHSlGCajpmEQpgXiXnTtt1MH5jKU/3ao55GPx7qmL6i GW5Nltkt0QyNydL7qMGXKD6BNCThBXdTNK2fOVCMum0FFyuvYybV893orDEeyLEUzbWQ a6hQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k24si116479ejs.444.2020.04.30.10.08.11; Thu, 30 Apr 2020 10:08:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727844AbgD3REd (ORCPT + 99 others); Thu, 30 Apr 2020 13:04:33 -0400 Received: from foss.arm.com ([217.140.110.172]:59188 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726809AbgD3REc (ORCPT ); Thu, 30 Apr 2020 13:04:32 -0400 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 15CCA1045; Thu, 30 Apr 2020 10:04:32 -0700 (PDT) Received: from melchizedek.cambridge.arm.com (melchizedek.cambridge.arm.com [10.1.196.50]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id BAD263F73D; Thu, 30 Apr 2020 10:04:30 -0700 (PDT) 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 v2 06/10] x86/resctrl: Use is_closid_match() in more places Date: Thu, 30 Apr 2020 18:03:56 +0100 Message-Id: <20200430170400.21501-7-james.morse@arm.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20200430170400.21501-1-james.morse@arm.com> References: <20200430170400.21501-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 aditionally 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 Reviewed-by: Reinette Chatre --- 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 9fe489904fc7..ffeb31918364 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(); @@ -2244,18 +2254,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.26.1