Received: by 2002:a25:2c96:0:0:0:0:0 with SMTP id s144csp195449ybs; Tue, 26 May 2020 07:04:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzamunrTKrWw6Gf8EY2XjMsv5//NMIzkdQuj6BNZywQqrOgQs6xRGtyh7lDc+h8bjDEyLa+ X-Received: by 2002:a17:906:be2:: with SMTP id z2mr1233117ejg.169.1590501844343; Tue, 26 May 2020 07:04:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590501844; cv=none; d=google.com; s=arc-20160816; b=LVKCQT5HXEQjd3VOYd4J0JztjPuRWOXndFPQR9pw0bHVC3pzCuC55KwGOHjwqB0Su1 CA1nNnu9SogG+Qt/KRggw/wvWZs9m2stBWOR/BIdCUPbqoX9XTp++o0kSAAsMq6mMWm3 bx0UPXDPRSIhNsB9Zuhr7Fdd5iqt6vaqVOzLjIBRaVpwW4dp2ogijMWZKQL9FonD+gHY dkjpQ/vhh70CS/RT1uBjVPZTEDaE2bq4DloxcdlIgoFf8/ZO1utGCNj3f88H7jCk/NJZ m/XVuot/X/fCT6UmuGrbCfKmZs7b/E8GgiP8Ti4AuywFEPj+whUzNaSxRwP0ukmo5ydk Sp7Q== 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=8McpTnLIqFJadBiMZMEeMSa04ieE78n2hWTQvyEraNE=; b=WK7ehwgQX+QD0pbeGC70sqKG0rk8IBDNbzHKalfGAyXOzN+UCfyp6TdQ8eOxjEbFAt QZZuxh//pkewYhxyxi7fajFJj5gHPkCqfq5eTtDV4b4j4Voge/34Vva3yNhC0spd6tOZ ZQcTyTGoFkX69F7KIp9STguKrKKQIro7xroWB6cyDIfd9nA2WigRWLiYWkV7bWw1ghRA juKmnTb+cPiPxcV/ozLROKwbk0J0016bobuOp4hTgDyjUCVnLdrjIy8Fh+Orf9lwA/Ci AbIz7EKsEpsgtOcoPiK3uG5Awz12Xmmm6hxxfa9XQ0SqYxDJK1S8TOtCUIihTyG1kT35 9Siw== 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 do2si12934062ejc.178.2020.05.26.07.03.38; Tue, 26 May 2020 07:04:04 -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 S2389067AbgEZNlY (ORCPT + 99 others); Tue, 26 May 2020 09:41:24 -0400 Received: from foss.arm.com ([217.140.110.172]:51006 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389022AbgEZNlV (ORCPT ); Tue, 26 May 2020 09:41:21 -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 2B40C11B3; Tue, 26 May 2020 06:41:21 -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 A9FBF3F6C4; Tue, 26 May 2020 06:41:19 -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 v4 06/10] x86/resctrl: Use is_closid_match() in more places Date: Tue, 26 May 2020 14:40:55 +0100 Message-Id: <20200526134059.1690-7-james.morse@arm.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20200526134059.1690-1-james.morse@arm.com> References: <20200526134059.1690-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 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 24bdb52446aa..d3aa55e1380f 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.19.1