Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp620257lqp; Thu, 21 Mar 2024 10:23:35 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVsf3yxfaUdXR5G61JcpaY76uSqBqqdpI0/wuTXhyy7XLIbsEwcyVFfUyiOtzaUS1sLvbXSEgrvBjOy5EZ1/DTFw1Cd7JImyIK+YND07Q== X-Google-Smtp-Source: AGHT+IGYR6XgPFG+OQPVzzlpKfiHRw9ymACOBPmfSB1DM8rMfz0IZZWHq8Cmfp6HQ8YpbC41bYlD X-Received: by 2002:a05:6a20:7b07:b0:1a3:8793:8817 with SMTP id s7-20020a056a207b0700b001a387938817mr120787pzh.56.1711041814972; Thu, 21 Mar 2024 10:23:34 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711041814; cv=pass; d=google.com; s=arc-20160816; b=GjtsLRtdDcBmxLgTy7R2sn2QVe3+myUxqgIipVNPY76TDNHKP1QH9O9YK24HI2KJrW rYal+JHNu0uIfI4wHT1T9ijpSTDMppcbHl2gwb3GeS9gwhpcXM5VAPG8YaOabjaC9VhZ sQnBuwCjRlfKKbjB1sqhVuc2pzsWqUZis3qxXIpOctTPPvZz2eixPCGcCkZKnosQnse+ QATS9UvoeV624z3XhqcwYQgUpJdg6O4H5OuTbi+PJAppZ8i1krjdd/DO6+kflaZlRIOr 39JXiScSziJ//3qoYtuq4l4wcECdfimCr88Xv1vtlpJtWTmuqhC2OVdk1FwL2rqeoy5+ haIA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=jE2tguA5tkXe9fIVy+IFARRyQdLa058lzKA+NTEHugo=; fh=knouHfhWmUABu+sT2q0nnGKUzC7/WRiZH1KSpGv7uFs=; b=QYjZM0g+QwoKECWVWqp3MjfW2+eocxBT8R+O2tTnBZsCXFY+490TZCuGF5BpdUis/l SbTgqdGvZKv8qul6Nx6RKQdf3D2dpUvhZCxjquJroO/W03WOXPqHAa1u4xhQriY9Ad5j qRrq8x2x7vRRSn34VO+Zwc8Gbsp5uph0Ba9WT5BsuQih5+V1u04ssGQkvdMfQhxfsxRA gl42EA1tR48/GiSWu4pNRBZOv4mn3DVHKJXvLVNK+sYHKNrjzXsdjAcBb5wQ2lxTpoI1 jSHyO3aMcxRRcrY7Zc4XKHqOrig75zLsuRFlTCOBbpHKko+cNImAjvhkWqYxWQVZAQ6E z55w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-110426-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-110426-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id z11-20020a170902d54b00b001e064a7f7b2si113425plf.226.2024.03.21.10.23.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Mar 2024 10:23:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-110426-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-110426-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-110426-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 015A6B2685B for ; Thu, 21 Mar 2024 17:00:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 06C5313A89A; Thu, 21 Mar 2024 16:52:01 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EFB0213A871 for ; Thu, 21 Mar 2024 16:51:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711039920; cv=none; b=seZhxzDuH8nL+LX+Gab7APED1q9ZdujY4tPrXvu88KNkWzM90ikbcfdYi9P7BDFBBqHrt/TsJSjtIzHDJsmAYngZRf0Wtvo5w/K5UT4cPnTdYxiL2H79br8l2cndeiftKGIJCdvloMM5UzWor2gnRi8eYKtK/W21wXpz2nTXSlo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711039920; c=relaxed/simple; bh=o1zn+OQp7jij+/S14yaNK/v9gJcYPVyuhx5I/BBFRX0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=i43Vn8M2Zx7vxYkOX2jDhuzdgdBzvZMjzQJmRQ40kgCq+PAJVYNtwFDD07JKT4HElYbt+dZxWCFLXsj8nt+OvvNuSvICaV/DOVQXbAHlPAOtOKBh3c20WTbrD2eoKoXqgkCv0J6mI4fMC/hJ1vf4PEHHZto48CXo261WXgFDMSg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com 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 DB50A1063; Thu, 21 Mar 2024 09:52:32 -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 9C7B03F67D; Thu, 21 Mar 2024 09:51:55 -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 , shameerali.kolothum.thodi@huawei.com, D Scott Phillips OS , carl@os.amperecomputing.com, lcherian@marvell.com, bobo.shaobowang@huawei.com, tan.shaopeng@fujitsu.com, baolin.wang@linux.alibaba.com, Jamie Iles , Xin Hao , peternewman@google.com, dfustini@baylibre.com, amitsinght@marvell.com, David Hildenbrand , Rex Nie , Dave Martin Subject: [PATCH v1 09/31] x86/resctrl: Add a resctrl helper to reset all the resources Date: Thu, 21 Mar 2024 16:50:44 +0000 Message-Id: <20240321165106.31602-10-james.morse@arm.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20240321165106.31602-1-james.morse@arm.com> References: <20240321165106.31602-1-james.morse@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit On umount(), resctrl resets each resource back to its default configuration. It only ever does this for all resources in one go. reset_all_ctrls() is architecture specific as it works with struct rdt_hw_resource. Add an architecture helper to reset all resources. Signed-off-by: James Morse --- arch/x86/include/asm/resctrl.h | 2 ++ arch/x86/kernel/cpu/resctrl/rdtgroup.c | 16 +++++++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/arch/x86/include/asm/resctrl.h b/arch/x86/include/asm/resctrl.h index f61382258743..5f6a5375bb4a 100644 --- a/arch/x86/include/asm/resctrl.h +++ b/arch/x86/include/asm/resctrl.h @@ -15,6 +15,8 @@ */ #define X86_RESCTRL_EMPTY_CLOSID ((u32)~0) +void resctrl_arch_reset_resources(void); + /** * struct resctrl_pqr_state - State cache for the PQR MSR * @cur_rmid: The cached Resource Monitoring ID diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/resctrl/rdtgroup.c index 1a49c9918f8d..13c24cb18d76 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -2859,6 +2859,14 @@ static int reset_all_ctrls(struct rdt_resource *r) return 0; } +void resctrl_arch_reset_resources(void) +{ + struct rdt_resource *r; + + for_each_capable_rdt_resource(r) + reset_all_ctrls(r); +} + /* * Move tasks from one to the other group. If @from is NULL, then all tasks * in the systems are moved unconditionally (used for teardown). @@ -2968,16 +2976,14 @@ static void rmdir_all_sub(void) static void rdt_kill_sb(struct super_block *sb) { - struct rdt_resource *r; - cpus_read_lock(); mutex_lock(&rdtgroup_mutex); rdt_disable_ctx(); - /*Put everything back to default values. */ - for_each_alloc_capable_rdt_resource(r) - reset_all_ctrls(r); + /* Put everything back to default values. */ + resctrl_arch_reset_resources(); + rmdir_all_sub(); rdt_pseudo_lock_release(); rdtgroup_default.mode = RDT_MODE_SHAREABLE; -- 2.39.2