Received: by 2002:a89:413:0:b0:1fd:dba5:e537 with SMTP id m19csp875677lqs; Fri, 14 Jun 2024 08:07:34 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVRFEi6waCm3jIa9zTQaeH7N3WFm7ARCT80tsKruMPFwE9ctGNljXFMwCKP7Ip2BpOQGnXdeIY8xVuyWCzlT+P6lxsNSrFs5Osb50urxg== X-Google-Smtp-Source: AGHT+IHapCQ8AM5EsqtCqMxu08L2UR+b7gwfmSui3Z3SLLelzUXHYFpe7b4c0syO73tg8inpPtUm X-Received: by 2002:aa7:8a12:0:b0:705:b535:d283 with SMTP id d2e1a72fcca58-705d712042dmr3342200b3a.7.1718377654145; Fri, 14 Jun 2024 08:07:34 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718377654; cv=pass; d=google.com; s=arc-20160816; b=bAIsD44PVfxhCEbEbQ5KO2Ij4UCr04y/15hQt74yrAOPbCqQOpnlbjoOyBwurneHgU 6A5/bDb9r7UTtlprIpSx/T5VYBfN6rhcjtQ8lOyyEHxqFGJDv5Yr9FHwDGaOO4qVEhO5 Bhz/H9MRXCQ9uNMEH6V0E9zEHLIqp7GrgoAf6Kvx7LRenUMIOApn7vSMtvp6bhqlLz2l JQZf6Cg0s1v7T+PunwIFqi1aezQYkixmteK/aBixzTXuUj1UBrsK9av32UHm+j9t3Sz3 Dj6OpOG3cEovEcrO89XB4kFn7Gcw05HyC32ZmCtF5wyVU40jSZpP6BEDTo3ThatluE91 4ieA== 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=9afunrdUsUqC5+k4ZhY6jpplHklo0PCv1bi7BHC5iIM=; fh=AQRRtkmHyvZI0LQ5UvExX7X5tmBE1F1lr2MH+s0Lwao=; b=Xa/bAY+FC0QWm/TRse/6f9tn59UGSNgMLyYTFXPcn+LAa06fSeNhVTB0+bPeFMqwnt CCOpznYep8y3EM4t6pRjbS+BOLntG4r45CvuDS2q4oW0PuWI6kL6eDrb7xTKL41jLg7N V0iPWeQrZBS52d4k7Bseoiy7RqONQo749w7Xjd4kTozAKGiI7uFWM+Y5+46/cFtfzbiQ kDlnXcD9SkGKd01zSQQfOpnoC9PCbaYYY0iZFZjnAbLPYSoRGDAVlsRjfDKlk2jyzl4f 32cAdlt0rhF6jzo34lJ2fZULRiVdSLtbmQyGZnNkHhTp3WprWgcBtJte17mcEXBS9KiT 6k3w==; 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-215080-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-215080-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id 41be03b00d2f7-6fedd4f44d8si3975722a12.54.2024.06.14.08.07.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Jun 2024 08:07:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-215080-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; 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-215080-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-215080-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id CA72128E378 for ; Fri, 14 Jun 2024 15:04:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D0E2319E7FC; Fri, 14 Jun 2024 15:01:57 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EAE7119D09D for ; Fri, 14 Jun 2024 15:01:55 +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=1718377317; cv=none; b=hlbRA/18FmxtpwER6zPzDJSrrdxicpKyLYhk++yvAaFP94f5sQHhmxchpI81Q59WrJn8uHfxRQM4XVbz8oRwuPFo6JYeyNag4E2E89tej1kddxPn33+LC3NM4rYHGX693lVgLPVauFwvWAMDJpkL+SYC828pL/05l1oJVqdc0c4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718377317; c=relaxed/simple; bh=3wpFQSebzGJ6W2UA1qNmbrRhkheuQJ2SBXapTJRZ+Rs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=tIiiPT0VDLsJxw6AMYb3JlOne+7Q6XuSxmUF0cO8dHdXXMRtjcSimUJeXRqksNMnjkuwL2725bWM7aKy/MJCc1JvjNxUf4fTqCRv8EJgnVs/iPLB2vd5qfg/j6lkSgnnZM5IOGh9FdAiOiprwC/xajmKv6ZHGgKRVvzNmcVm8+U= 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 EE3251763; Fri, 14 Jun 2024 08:02:19 -0700 (PDT) Received: from merodach.members.linode.com (usa-sjc-mx-foss1.foss.arm.com [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 2D51C3F5A1; Fri, 14 Jun 2024 08:01:52 -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 , Dave Martin , Shaopeng Tan Subject: [PATCH v3 14/38] x86/resctrl: Add a resctrl helper to reset all the resources Date: Fri, 14 Jun 2024 15:00:09 +0000 Message-Id: <20240614150033.10454-15-james.morse@arm.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20240614150033.10454-1-james.morse@arm.com> References: <20240614150033.10454-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. Co-developed-by: Dave Martin Signed-off-by: Dave Martin Signed-off-by: James Morse Tested-by: Peter Newman Tested-by: Shaopeng Tan --- Changes since v1: * Rename the for_each_capable_rdt_resource() introduced in the new function resctrl_arch_reset_resources(), back to for_each_alloc_capable_rdt_resource() as it was in the original code. The change looked unintentional; and presumably a resource that does not support resource allocation doesn't have any properties to reset... --- 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 1574f5afd0e8..82d64885c6c0 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -2886,6 +2886,14 @@ static int reset_all_ctrls(struct rdt_resource *r) return 0; } +void resctrl_arch_reset_resources(void) +{ + struct rdt_resource *r; + + for_each_alloc_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). @@ -2995,16 +3003,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