Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp2750230rda; Wed, 25 Oct 2023 11:08:52 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGgKDNCkx7MXg8TtuUcruFPlYisFDfUswudSb3Wz1aX7W9Ew62fBtliEli/kc5WDyFmlZfR X-Received: by 2002:a25:e7c2:0:b0:d9a:d31a:2197 with SMTP id e185-20020a25e7c2000000b00d9ad31a2197mr15339851ybh.62.1698257331728; Wed, 25 Oct 2023 11:08:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698257331; cv=none; d=google.com; s=arc-20160816; b=u46tRssAmUq2iQlrwkEA5QCGI6KEFJsffiCBTfzwoTSjM6UEmKaZiXhSFzbfkTnIGH OECo7gujO07WpLL6eEpQY6RSZo9RjAmDelP4RW5H87heZBs4j7S5ShU8juflAhQtxGcW CXqIp5Va3VQOsTNIf+EMWtGLfiaDqKUoImgCkPvhEnmeNHlFoKXRTsPRsAN3GynABcJ6 u2kR3QERSAlCbFmzhnaT2+j4vzNLkcgPpjeSeJV+8heQtyQwRtm1Vg4atQ7MUZo5eeZ7 8iVVFU8gvC+8UcvFHttgIEeiaPtVu2qWZaYU77rFoPIRl9Un5rHLfW8AxSaSAqhJnLiz qC1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=k8TxtLYfSvneksDoqdSHjzMX2CF7eMxD1t0EX8W5HcQ=; fh=66J7Y+TGxNFNx8VjvpfZFFUqd7hqgnmmrifbhuLe8jE=; b=Y5wINFyYTBOA1tHVzvhFC+fAqr74uKT+JTHaY+8xxCdGd67X/XG+V8qUggYyLdCbj3 d5jMsj2DWFAkeXaQE3P1jOUdxq8Cbchpvy4uwkDa8eoa6DA88KtMFJFbhABe9yRpn0by cx/t7MQwkLG+0n4GAwlaVmLhjU+6TgEg+9RSVV0xFbhJLoe6pNSrB7CYx1uzwFWSFTnD 3aRMHhLzw8bIq0ZNcx6XeHug/ESupIW/OcofIthrmdY0m3JP9XZbHRl3LWeI2fe1uf4U Ljw8ddiwqH2wcu0I+NrlH6xpN1mT51cpsJYqNWDwOH0wNleEmvcP3V+xTorkvu0nitVR tHRw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id e130-20020a25e788000000b00d9cb899a60csi10952905ybh.176.2023.10.25.11.08.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Oct 2023 11:08:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 3C11780D6E54; Wed, 25 Oct 2023 11:08:48 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234859AbjJYSIo (ORCPT + 99 others); Wed, 25 Oct 2023 14:08:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53284 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234855AbjJYSI1 (ORCPT ); Wed, 25 Oct 2023 14:08:27 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 92D722D5A for ; Wed, 25 Oct 2023 11:06:53 -0700 (PDT) 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 983421516; Wed, 25 Oct 2023 11:07:33 -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 2D5163F738; Wed, 25 Oct 2023 11:06:40 -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 Subject: [PATCH v7 23/24] x86/resctrl: Move domain helper migration into resctrl_offline_cpu() Date: Wed, 25 Oct 2023 18:03:44 +0000 Message-Id: <20231025180345.28061-24-james.morse@arm.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20231025180345.28061-1-james.morse@arm.com> References: <20231025180345.28061-1-james.morse@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Wed, 25 Oct 2023 11:08:48 -0700 (PDT) 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. Tested-by: Shaopeng Tan Tested-by: Peter Newman Reviewed-by: Shaopeng Tan Reviewed-by: Reinette Chatre Signed-off-by: James Morse --- Changes since v5: * Changed fir tree order of variables. * Added mon-capable check for cpu offline. No changes since v6 --- 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 7d09b8d7c653..a90a07a5c876 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -582,22 +582,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 971a8397e243..d38b2fe6e3ca 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -4034,7 +4034,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); @@ -4044,6 +4046,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); + } + } } /* -- 2.39.2