Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp6848803rdb; Fri, 15 Dec 2023 09:49:15 -0800 (PST) X-Google-Smtp-Source: AGHT+IHhuuiF0g7/RnccpUFTdnGIqJevfmMFgQD5GxHIifvb/PVvzTnB6BAQ0r5qmUEv8tvJvqj1 X-Received: by 2002:a17:906:3f57:b0:a1d:b790:b556 with SMTP id f23-20020a1709063f5700b00a1db790b556mr5942731ejj.155.1702662555390; Fri, 15 Dec 2023 09:49:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702662555; cv=none; d=google.com; s=arc-20160816; b=I/kB3Oq2g7q2vVoF6TZCiNQ+zNizVqRiQuREmFp2xfbTMazQOeJFxzVLUDBcfJaNSo yM6o7seQVyzS3j0tDkEkAJ6Lk8jLYx6Ph85N2igNC0KGQ3BsW/kXEoG9s7R94x3p6MrX 9QKhBp8nqMK9c0/l5bsXhTFRqGrn9sRX8meVkXUnX8vaxboj2MQ8MmxR8KbXAG6+1PEq lRvgPmPY/O8JAnCRg7ME6ssuhm31AfWfhcB0NlkeRvJkUWYsWYYiKIGpOZU3BGvKvgbP Vdbwe38DyuiGrsbkYyUfyHqbgkCevgrkm0Xi9XK54NqVqg72sCxyXxgPgJhzHfw/ksJ+ 6qxw== ARC-Message-Signature: i=1; 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=x5Xa8wer1tlxmv7jPH8wefAVBsqtLgaFZHiIi17nFrI=; fh=B41BSS80/g48MVbql1jW7CCXTAGMSWslnmHIfPLpVL4=; b=PFlmveJlinDC4edsI1WFDFVK8c0/PuMdFrGabcfUdKwXLwVwmTRupbV0aTEYlilP2F zhO/4najp8D9Z21lonVfUoNVn7dNMhxokx0B8lsy5CQppzpX5Wm9fFRicgcmRiZK95xf Axb7zduS/UDJLoq+Fo3FK/gobdTu/xqkjZGU9p7DoJ4nCf8rCGlsFTa5JU6D1x7q/3wH h8PxsHSR+eucQJPIXRleWYmfeNgn2EsQjHr5KXK8cWlwd0dAvoKVbT7WtoVjVAzY+B/z NUQpSLZ10gTwuFKDWNaSLwTkiXh3CheWOcSc3ywKq1FVNk6itFASAs6kx70vrsuN7b1i 1Q9w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-1459-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-1459-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id c4-20020a170906170400b00a1c592541d8si7663915eje.80.2023.12.15.09.49.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Dec 2023 09:49:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-1459-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-1459-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-1459-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 290211F214E9 for ; Fri, 15 Dec 2023 17:49:15 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7ED385F85B; Fri, 15 Dec 2023 17:45:07 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 10F705F850 for ; Fri, 15 Dec 2023 17:45:03 +0000 (UTC) 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 953761650; Fri, 15 Dec 2023 09:45:48 -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 A30D23F5A1; Fri, 15 Dec 2023 09:45:00 -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, Babu Moger Subject: [PATCH v8 20/24] x86/resctrl: Add CPU online callback for resctrl work Date: Fri, 15 Dec 2023 17:43:39 +0000 Message-Id: <20231215174343.13872-21-james.morse@arm.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20231215174343.13872-1-james.morse@arm.com> References: <20231215174343.13872-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 create a domain when a CPU comes online, it also needs to reset the CPUs PQR_ASSOC register. The resctrl filesystem code needs to update the rdtgroup_default CPU mask when CPUs are brought online. Currently this is all done in one function, resctrl_online_cpu(). This will need to be split into architecture and filesystem parts before resctrl can be moved to /fs/. Pull the rdtgroup_default update work out as a filesystem specific cpu_online helper. resctrl_online_cpu() is the obvious name for this, which means the version in core.c needs renaming. resctrl_online_cpu() is called by the arch code once it has done the work to add the new CPU to any domains. In future patches, resctrl_online_cpu() will take the rdtgroup_mutex itself. Signed-off-by: James Morse Tested-by: Shaopeng Tan Tested-by: Peter Newman Tested-by: Babu Moger Reviewed-by: Shaopeng Tan Reviewed-by: Reinette Chatre Reviewed-by: Babu Moger --- Changes since v3: * Renamed err to ret Changes since v4: * Changes in capitalisation. Changes since v5: * More changes in capitalisation. * Made resctrl_online_cpu() return void. --- arch/x86/kernel/cpu/resctrl/core.c | 8 ++++---- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 8 ++++++++ include/linux/resctrl.h | 1 + 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resctrl/core.c index ba6daef6bd26..8ac89dbf4484 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -608,16 +608,16 @@ static void clear_closid_rmid(int cpu) RESCTRL_RESERVED_CLOSID); } -static int resctrl_online_cpu(unsigned int cpu) +static int resctrl_arch_online_cpu(unsigned int cpu) { struct rdt_resource *r; mutex_lock(&rdtgroup_mutex); for_each_capable_rdt_resource(r) domain_add_cpu(cpu, r); - /* The cpu is set in default rdtgroup after online. */ - cpumask_set_cpu(cpu, &rdtgroup_default.cpu_mask); clear_closid_rmid(cpu); + + resctrl_online_cpu(cpu); mutex_unlock(&rdtgroup_mutex); return 0; @@ -969,7 +969,7 @@ static int __init resctrl_late_init(void) state = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "x86/resctrl/cat:online:", - resctrl_online_cpu, resctrl_offline_cpu); + resctrl_arch_online_cpu, resctrl_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 89aef67588c0..76aa73c49fad 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -4012,6 +4012,14 @@ int resctrl_online_domain(struct rdt_resource *r, struct rdt_domain *d) return 0; } +void resctrl_online_cpu(unsigned int cpu) +{ + lockdep_assert_held(&rdtgroup_mutex); + + /* The CPU is set in default rdtgroup after online. */ + cpumask_set_cpu(cpu, &rdtgroup_default.cpu_mask); +} + /* * rdtgroup_init - rdtgroup initialization * diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h index bf460c912bf5..4c4bad3c34e4 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -223,6 +223,7 @@ u32 resctrl_arch_get_config(struct rdt_resource *r, struct rdt_domain *d, u32 closid, enum resctrl_conf_type type); 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); /** * resctrl_arch_rmid_read() - Read the eventid counter corresponding to rmid -- 2.20.1