Received: by 2002:a05:7412:2a91:b0:fc:a2b0:25d7 with SMTP id u17csp109726rdh; Tue, 13 Feb 2024 10:50:36 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWDeF/HpOB8dMsZJx2ffat5Fv/+HryRVFLIosJeMVma8/OKlmILKT6st15nCGqu5dJs1cG2fNkDOqlMCLNWA49kqC4kIVOQaljiAUUoHw== X-Google-Smtp-Source: AGHT+IFLzNBIgUooOYL08RctSbgh+FU04V0VB9IYc2hI/bJRZAyE70BK/wVzSfHUKZgtO11+VSpv X-Received: by 2002:a17:906:c356:b0:a3c:b059:9176 with SMTP id ci22-20020a170906c35600b00a3cb0599176mr114000ejb.70.1707850236450; Tue, 13 Feb 2024 10:50:36 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707850236; cv=pass; d=google.com; s=arc-20160816; b=QariecEA95j3WsERMHikAAPuswjdXe9o66h0I7wx59ngTNmxVU59FsTlsIZy7TCDTV 6wA3yrGpAZlZGNSI/+TqQAfL5EbhGdmUB5h448X9iZpTzyZKSa4YpX0/V+uoeOoVBl5c KLGz+sToF34gwf2JDZFT/D2A/aJGNmj9bVugaW2xfwBUhabcTvLCTO8r6MOI98T6bKAH qm3t3u0aQ2JKd6FMtMbABJfV8vKQ7AFJc9lC98Nk/bkWWolQthk0OzpwtLL8b+L50Lag VEdbFZV8/5O/AOJIeC6SqRm/MJIoUC6VA17ft3G7NAPnLLcu5VRTUOoxpCkO7Sx9xBVK fDVg== 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=Bjp/kM0pwgfnsnvfEvpgsjKtodmxi49LEm2hNwZluXY=; fh=73fQdXg2SgNJqu0TaDhh44x3v9TJ0PpFxgseyQ6/xdY=; b=L5LctaR4JF8gd/aQQ1AFgp6LJ9nivDdSb6oF5YLeFAQ3cYiJqdQmuuySe/XxZnP+eN oP5nkSmpR0EOMYehAM2m1pzKZpfx5SV4dCpFqhnYUexX+ymZOricPnWukogWKIrT80dv RU9WRRB3F1/z3GH67in13atFP9CD+xofTcr2/tOWmQg+Any13ocNBLPTyLavnCvRySaN 4gDnn7HMjdXS5H3+6kc0U39GZITtxmYoSZpfvN9NFWUP4c6P43JP57PIGFmwFXN9JhLU Axv/DlYBR+AHIsm5TVknD/1uJEMBK8c/+yDAvvPK93cidhpRW+SVljFiuaGDseaREGCW QzyA==; 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-64113-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-64113-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com X-Forwarded-Encrypted: i=2; AJvYcCXLa7X5FhPHleiDjOPOcKT3RE5DtHX3RxWGkqJ7RQKwV7jXCzqcVGmdmDAdytVCJ4yjE8lBRxUndcYIG+uHVRojgxIhktkJaNQQ1+6EBA== Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id o12-20020a170906358c00b00a38c319921asi1464616ejb.631.2024.02.13.10.50.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 10:50:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-64113-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; 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-64113-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-64113-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 356FC1F24DE7 for ; Tue, 13 Feb 2024 18:50:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1EA7D627EC; Tue, 13 Feb 2024 18:46:18 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 03D4D626C9 for ; Tue, 13 Feb 2024 18:46:15 +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=1707849977; cv=none; b=fxQMFBnAMDc2bxRS+FqCp+9ut53dZE7V51A1QyeAYojV1XyrB68WD2MwGldPyXFWjmByHDMhNtqdjyRwvLSMdtxHJ/HHxSiOJYX8uIGH+8PTz9zGorPkgpz5clZiOjpY0PVltGMEEhbVguynmehaoOJZ3GMwEZxkmTBTGvQ1ukc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707849977; c=relaxed/simple; bh=R72bTUh1j2/iRl0BP2jxva1B3BK/NOYi0JFQYorCmiI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=JNVztWokUMwwK6GJlGKEfHUw2ORFs26t+AVBoitEikULS7Z48TYfQ+QBFL53T5TM84x/PeP9k7EoRQwZKwD6r06BgFw27SOSssBY/CaORDcfv5yJyV8NuOeEYB8ol0b+o4iTfqpcMcCec595Y9Hl7ONGaPVxpCD9pkyvIz3J56k= 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 C3B7E1595; Tue, 13 Feb 2024 10:46:56 -0800 (PST) Received: from merodach.members.linode.com (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 6587A3F766; Tue, 13 Feb 2024 10:46:12 -0800 (PST) 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 , Babu Moger Subject: [PATCH v9 22/24] x86/resctrl: Add CPU offline callback for resctrl work Date: Tue, 13 Feb 2024 18:44:36 +0000 Message-Id: <20240213184438.16675-23-james.morse@arm.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20240213184438.16675-1-james.morse@arm.com> References: <20240213184438.16675-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 The resctrl architecture specific code may need to free a domain when a CPU goes offline, it also needs to reset the CPUs PQR_ASSOC register. Amongst other things, the resctrl filesystem code needs to clear this CPU from the cpu_mask of any control and monitor groups. Currently this is all done in core.c and called from resctrl_offline_cpu(), making the split between architecture and filesystem code unclear. Move the filesystem work to remove the CPU from the control and monitor groups into a filesystem helper called resctrl_offline_cpu(), and rename the one in core.c resctrl_arch_offline_cpu(). Signed-off-by: James Morse Tested-by: Shaopeng Tan Tested-by: Peter Newman Tested-by: Babu Moger Tested-by: Carl Worth # arm64 Reviewed-by: Shaopeng Tan Reviewed-by: Reinette Chatre Reviewed-by: Babu Moger --- arch/x86/kernel/cpu/resctrl/core.c | 25 +++++-------------------- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 24 ++++++++++++++++++++++++ include/linux/resctrl.h | 1 + 3 files changed, 30 insertions(+), 20 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resctrl/core.c index 55322ba629da..4aedefa22f61 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -625,31 +625,15 @@ static int resctrl_arch_online_cpu(unsigned int cpu) return 0; } -static void clear_childcpus(struct rdtgroup *r, unsigned int cpu) +static int resctrl_arch_offline_cpu(unsigned int cpu) { - struct rdtgroup *cr; - - list_for_each_entry(cr, &r->mon.crdtgrp_list, mon.crdtgrp_list) { - if (cpumask_test_and_clear_cpu(cpu, &cr->cpu_mask)) { - break; - } - } -} - -static int resctrl_offline_cpu(unsigned int cpu) -{ - struct rdtgroup *rdtgrp; struct rdt_resource *r; mutex_lock(&rdtgroup_mutex); + resctrl_offline_cpu(cpu); + for_each_capable_rdt_resource(r) domain_remove_cpu(cpu, r); - list_for_each_entry(rdtgrp, &rdt_all_groups, rdtgroup_list) { - if (cpumask_test_and_clear_cpu(cpu, &rdtgrp->cpu_mask)) { - clear_childcpus(rdtgrp, cpu); - break; - } - } clear_closid_rmid(cpu); mutex_unlock(&rdtgroup_mutex); @@ -971,7 +955,8 @@ static int __init resctrl_late_init(void) state = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "x86/resctrl/cat:online:", - resctrl_arch_online_cpu, resctrl_offline_cpu); + resctrl_arch_online_cpu, + resctrl_arch_offline_cpu); if (state < 0) return state; diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/resctrl/rdtgroup.c index f5688c79d94f..5bd3d8fb3f67 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -4017,6 +4017,30 @@ void resctrl_online_cpu(unsigned int cpu) cpumask_set_cpu(cpu, &rdtgroup_default.cpu_mask); } +static void clear_childcpus(struct rdtgroup *r, unsigned int cpu) +{ + struct rdtgroup *cr; + + list_for_each_entry(cr, &r->mon.crdtgrp_list, mon.crdtgrp_list) { + if (cpumask_test_and_clear_cpu(cpu, &cr->cpu_mask)) + break; + } +} + +void resctrl_offline_cpu(unsigned int cpu) +{ + struct rdtgroup *rdtgrp; + + lockdep_assert_held(&rdtgroup_mutex); + + list_for_each_entry(rdtgrp, &rdt_all_groups, rdtgroup_list) { + if (cpumask_test_and_clear_cpu(cpu, &rdtgrp->cpu_mask)) { + clear_childcpus(rdtgrp, cpu); + break; + } + } +} + /* * rdtgroup_init - rdtgroup initialization * diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h index ccbbbe5d18d3..270ff1d5c051 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -226,6 +226,7 @@ u32 resctrl_arch_get_config(struct rdt_resource *r, struct rdt_domain *d, int resctrl_online_domain(struct rdt_resource *r, struct rdt_domain *d); void resctrl_offline_domain(struct rdt_resource *r, struct rdt_domain *d); void resctrl_online_cpu(unsigned int cpu); +void resctrl_offline_cpu(unsigned int cpu); /** * resctrl_arch_rmid_read() - Read the eventid counter corresponding to rmid -- 2.39.2