Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp707655ybt; Wed, 8 Jul 2020 09:42:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzdrgeTDaZgU3Vv9jnU1/GJghl/el9PDoTsvJdcUrKo6rlwFMFPTe4x/hagDtO0luRwWfTM X-Received: by 2002:a05:6402:1841:: with SMTP id v1mr54611992edy.198.1594226562166; Wed, 08 Jul 2020 09:42:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594226562; cv=none; d=google.com; s=arc-20160816; b=ypKdSomtrKbK7e1BC04jvdXqfMSp7tIF+WU3bnGzJ6noWRdImE/JH4zldFRmBgNxTU uCpYENwUA7M1ynTYut7P98hIyVwZlRrdxh5atLN5tTWbhG0H37G+Xw/cCvr2GkSwkOJk YI+BquF6HUu0/At4CDsGACOYTN7/yyOtiF/f+u4/FcV+Df+iRzoo4P5KM5Bu/OTOLyhz BjC30CZgsOgm2k1kjfEftvW+faDtT3v3FMJbEBCxK/Q4hZYAnTuR+I1VrZdoaMqNXJrr s/MulhuBv//ucpruNvPbgzBPnRNJv38ACNdT1JkxT5psSbw8GSXSMEyTw409Rb6spjqm VRMA== 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=RhdMQrF8TLLfNVkN5nDsR+sFEHS6cDXlehnXQ/oNPg8=; b=Hf7cRIUVpMx8/EncDDNwblsVYIhWiuE44Vi4576s/MbQVxxUd4LML0YZfpo3W6tY4w /1wXVhXEzXOhEvZG8WmqI2IPT/JfKuyh9SPPsPK9Bk3MDNw4HbkV2EduIfr87qKDyDmL QsaahyhrHM5INU2F65DJMy7Z2+6kuW3rrCa/fTfyU/QHthJzJdgUf+jf5z2N1GIsagJ7 F4ZBRtockL/Ibdf1IfqOkubqklim/5AdhNJDWcLn0egfeU6UDU81A2zf88Mwsf0zRkdX WGm9u5T8cpoUVs1dKpNabd1RXUwOQm4Nn6tuPXXrVcCaE/LyAaIuSHQVhVxG2RXD0DsQ JXxw== 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 m25si349991edr.11.2020.07.08.09.42.19; Wed, 08 Jul 2020 09:42:42 -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 S1730653AbgGHQkO (ORCPT + 99 others); Wed, 8 Jul 2020 12:40:14 -0400 Received: from foss.arm.com ([217.140.110.172]:51294 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730643AbgGHQkN (ORCPT ); Wed, 8 Jul 2020 12:40:13 -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 F3F491396; Wed, 8 Jul 2020 09:40:12 -0700 (PDT) Received: from merodach.members.linode.com (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 9C8D03F68F; Wed, 8 Jul 2020 09:40:11 -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 v5 06/10] x86/resctrl: Use is_closid_match() in more places Date: Wed, 8 Jul 2020 16:39:25 +0000 Message-Id: <20200708163929.2783-7-james.morse@arm.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200708163929.2783-1-james.morse@arm.com> References: <20200708163929.2783-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 0398769b90f1..5ec0cf27b426 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.20.1