From patchwork Tue Feb 13 18:44:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Morse X-Patchwork-Id: 200564 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:bc8a:b0:106:860b:bbdd with SMTP id dn10csp740919dyb; Tue, 13 Feb 2024 10:51:14 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCURzK4gIkeHP69vMjOhd33n86lHSZ/fTGehzP4Nt4JZciDpOrxEhkroD2dc/etLDDGDhPCVPsK2CunIl+lSOb6BBQqEWQ== X-Google-Smtp-Source: AGHT+IGF0lniPjJgjb72EfXex6xDTucskC18h36wAc/Z/nY12oSsF9lPICZQBe2C+4lhOkQmY/Kl X-Received: by 2002:ac8:5909:0:b0:42c:6923:6e52 with SMTP id 9-20020ac85909000000b0042c69236e52mr338465qty.17.1707850273812; Tue, 13 Feb 2024 10:51:13 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707850273; cv=pass; d=google.com; s=arc-20160816; b=xTduTe2p/RFp3dQW+8WgV4sMAeryaUSOHBl9p65/xxeIiQojuCZrpRCNS1ipoGx7UM zqJS9DYZbj0tFaDTbapTq/tVpoQXb6ZLuPDGi4+ZBaap3T8eqcUHR28xHKfhLYkpo3z6 4KD56Qi3npqpzvIqUpVI5vz5eahtxU3X/e4SDnZYLbhxIq+8VW4dZV1+2rzdR42SYHMt ZVP38TRWrrm1xuA809KCU8ICrugTVsEf79k91svLiIJeNmSQMLXa3OF2ui3igg7ZpbB3 uARZMuYmHeAWb9AHbm3HvQ+y/RbbQg9kwG3+okLv9HrILWjKBdR0FnQyuZTdyJqQHYNf feWQ== 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=FoON0ULOmmeByLgj/eRokC6XIVi03jW4OrcL3lQWo8A=; fh=loFYBUI7/zRwwbKkRN9zrQ4QXQQXCSF85bNP2+Rk8Bc=; b=kXcOjYob8YEDCPIydC6AdSQSx2BKMKOybv2cEDjiFBR8G4ehShFetmV0uCok0a9BO5 pqP8eiqqg+8Bma6/TP7wJCCDMo/hSsA6GOMrCfW0YgGqLV98mLAmNuNI4I/noSA/FGrt 8NLlY0Rs7l29mwCaLJEgQayypJmX5OdTCuBKEFUQXA3i04HBTtt86ub0AtSz7Gw9PS56 tlhvD143wKRHBDBmgoka4TTvCkBFEtAbNBQ3sk8l46t5+uN6BGeiHzdIxPvjNIC1uVdY ZdQpbCDRjCYvfv+gi19qwl/0p/Z9H8rZGN7eM/YV93e9EGyDo80JFOgnFOEBYvqu5Wbm EFKQ==; 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-64114-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-64114-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com X-Forwarded-Encrypted: i=2; AJvYcCXIcjx/g8SfpTZEo581er8+FrNUl3+GafAad2omFdX6ISH4M2O9XtFeIF9e+N0o3U61PCIj5L0tSPIUWvHWitDodQrbeQ== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id b7-20020ac85bc7000000b0042c2f47ede5si3766621qtb.467.2024.02.13.10.51.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 10:51:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-64114-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::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-64114-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-64114-ouuuleilei=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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 5102C1C2474C for ; Tue, 13 Feb 2024 18:50:55 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 530A2111B2; Tue, 13 Feb 2024 18:46:22 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 25F9360893 for ; Tue, 13 Feb 2024 18:46:19 +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=1707849980; cv=none; b=dA7g8jmASAluzF2MweLBCDzw+fpH5jNfYxU+naFWBz6LHAvp8/88L3oHDHFxpdfm9n0oDgg3Hy4PrFD8PJOQqEscNDvgUUw8zuM4rmX82r3qdj1GA2I6rgOgFsxn64MBhgu7md7OK3jH4eLm/ghfH4Jihza0lgLbRAG1OopAHgk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707849980; c=relaxed/simple; bh=hHAjGEeRkRs4daqFFngb0LSIvNeLboUSwjB1bPyY14U=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=QFM0AJNeVcjFtxdHPV1IxBd5PqhO3BieqnNXvfW8Z4mALn+OrpyZSxtn4Eqc7qnXkO4X/6pv/wJPwPc+tmGTNL0fduCVZ8gzFz2ZsFDqY9nIrdnGOuXLG1RqojqdiRAEXdTQ2prBa8vhZKZe8F3xUqkJAjN/FY+UmHO3zWBl1Tg= 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 1CB8B1576; Tue, 13 Feb 2024 10:47:00 -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 B71123F766; Tue, 13 Feb 2024 10:46:15 -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 23/24] x86/resctrl: Move domain helper migration into resctrl_offline_cpu() Date: Tue, 13 Feb 2024 18:44:37 +0000 Message-Id: <20240213184438.16675-24-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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790810808702939932 X-GMAIL-MSGID: 1790810808702939932 When a CPU is taken offline the resctrl filesystem code needs to check if it was the CPU nominated to perform the periodic overflow and limbo work. If so, another CPU needs to be chosen to do this work. This is currently done in core.c, mixed in with the code that removes the CPU from the domain's mask, and potentially free()s the domain. Move the migration of the overflow and limbo helpers into the filesystem code, into resctrl_offline_cpu(). As resctrl_offline_cpu() runs before the architecture code has removed the CPU from the domain mask, the callers need to be told which CPU is being removed, to avoid picking it as the new CPU. This uses the exclude_cpu feature previously added. 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 --- Changes since v5: * Changed fir tree order of variables. * Added mon-capable check for cpu offline. --- arch/x86/kernel/cpu/resctrl/core.c | 16 ---------------- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 18 ++++++++++++++++++ 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resctrl/core.c index 4aedefa22f61..b03a6c658ae5 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -580,22 +580,6 @@ static void domain_remove_cpu(int cpu, struct rdt_resource *r) return; } - - if (r == &rdt_resources_all[RDT_RESOURCE_L3].r_resctrl) { - if (is_mbm_enabled() && cpu == d->mbm_work_cpu) { - cancel_delayed_work(&d->mbm_over); - /* - * temporary: exclude_cpu=-1 as this CPU has already - * been removed by cpumask_clear_cpu()d - */ - mbm_setup_overflow_handler(d, 0, RESCTRL_PICK_ANY_CPU); - } - if (is_llc_occupancy_enabled() && cpu == d->cqm_work_cpu && - has_busy_rmid(d)) { - cancel_delayed_work(&d->cqm_limbo); - cqm_setup_limbo_handler(d, 0, RESCTRL_PICK_ANY_CPU); - } - } } static void clear_closid_rmid(int cpu) diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/resctrl/rdtgroup.c index 5bd3d8fb3f67..777e9f680332 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -4029,7 +4029,9 @@ static void clear_childcpus(struct rdtgroup *r, unsigned int cpu) void resctrl_offline_cpu(unsigned int cpu) { + struct rdt_resource *l3 = &rdt_resources_all[RDT_RESOURCE_L3].r_resctrl; struct rdtgroup *rdtgrp; + struct rdt_domain *d; lockdep_assert_held(&rdtgroup_mutex); @@ -4039,6 +4041,22 @@ void resctrl_offline_cpu(unsigned int cpu) break; } } + + if (!l3->mon_capable) + return; + + d = get_domain_from_cpu(cpu, l3); + if (d) { + if (is_mbm_enabled() && cpu == d->mbm_work_cpu) { + cancel_delayed_work(&d->mbm_over); + mbm_setup_overflow_handler(d, 0, cpu); + } + if (is_llc_occupancy_enabled() && cpu == d->cqm_work_cpu && + has_busy_rmid(d)) { + cancel_delayed_work(&d->cqm_limbo); + cqm_setup_limbo_handler(d, 0, cpu); + } + } } /*