Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1350899rwd; Thu, 25 May 2023 11:15:33 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7gW4GskJbIjddPaODVvGb2La9p12ei9iOOfuygO1aNjv6EZhuRTDXsbnzhrudxwMU7cFZg X-Received: by 2002:a05:6a20:914f:b0:10c:37ed:3e88 with SMTP id x15-20020a056a20914f00b0010c37ed3e88mr13566049pzc.23.1685038533133; Thu, 25 May 2023 11:15:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685038533; cv=none; d=google.com; s=arc-20160816; b=eb2gM0ZmegtKHqFi2spbOP+AnBK1pwGsvqOG/UrUXH+qvewiqjbzt/6h9isam1zvXe rnbG9RsKsnjDfLNEdNh6UbEqwX14kG4OUS9mY3sJRb1z+7Ry0IgQxNrPIa/RIUnQFuRN Q6TPaFsUIwQ2WZpuKwrnFpUD/nAsAGblFcghIxH5MzLpHgnivjefDM0E0DhDG4VO8CNt LJ4crFG3p+MEevL7lpBtSFyubnLqKlLhsF2MhCUVJYtSVk4UDVbLG/+HTrVHeQDRBmTy Ha7+8gJmPHyxmphjNAOqH/kMbvGJc1hEcD5v8a4D6tI11M8DDxgq5NVowlHUVG6gprQM +X8A== 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=Viz1+o91JqD1SAiznVT/wUys9bxBnOXTip9k3WVYi74=; b=Vx5WBZjp8EdEDQhPguFfwncavWxo1EeKwH9nTfpXkCcqmhaMBOkfWOqIq5Gd1gKgkL w3ZKhHOT++td2z71lZa+A4yPmAehhslxrZzRJub+zFgtd2Zx5tVVY3Ebp3J+Bu9sQ2vG Jls/ov3VQ0IbCpUW+ECf9yED0EavI8V3JVf5NlB0rbW3AHNgkNeLXfHMZOTb0XpumK19 ialw/s1ebTD3CgKfnzi1b0Pnm5tLxjJ3H0CENHBqRYTLEcF28lGOgyMERCePj9UJQ8qm YCY+aNtYgYLEiyC8Jd9oFMvsTz/Roqp695fjIyRRQe9PiOCJfo8ds54vizYWJ6mDByuR 7scg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s23-20020a639257000000b0053f2810a30bsi131177pgn.127.2023.05.25.11.15.17; Thu, 25 May 2023 11:15:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241330AbjEYSFk (ORCPT + 99 others); Thu, 25 May 2023 14:05:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34028 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241309AbjEYSFT (ORCPT ); Thu, 25 May 2023 14:05:19 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id F32451731 for ; Thu, 25 May 2023 11:04:29 -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 529A51692; Thu, 25 May 2023 11:04:23 -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 8A1813F6C4; Thu, 25 May 2023 11:03:35 -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, xingxin.hx@openanolis.org, baolin.wang@linux.alibaba.com, Jamie Iles , Xin Hao , peternewman@google.com, dfustini@baylibre.com Subject: [PATCH v4 23/24] x86/resctrl: Move domain helper migration into resctrl_offline_cpu() Date: Thu, 25 May 2023 18:02:08 +0000 Message-Id: <20230525180209.19497-24-james.morse@arm.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20230525180209.19497-1-james.morse@arm.com> References: <20230525180209.19497-1-james.morse@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE 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 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 --- arch/x86/kernel/cpu/resctrl/core.c | 16 ---------------- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 15 +++++++++++++++ 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resctrl/core.c index 9128a9710537..edc0dd123317 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -578,22 +578,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(r, 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 08b426f52f6d..3a8e2c98b611 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -3749,7 +3749,9 @@ static void clear_childcpus(struct rdtgroup *r, unsigned int cpu) void resctrl_offline_cpu(unsigned int cpu) { + struct rdt_domain *d; struct rdtgroup *rdtgrp; + struct rdt_resource *l3 = &rdt_resources_all[RDT_RESOURCE_L3].r_resctrl; lockdep_assert_held(&rdtgroup_mutex); @@ -3759,6 +3761,19 @@ void resctrl_offline_cpu(unsigned int cpu) break; } } + + 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(l3, d)) { + cancel_delayed_work(&d->cqm_limbo); + cqm_setup_limbo_handler(d, 0, cpu); + } + } } /* -- 2.39.2