From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EADB4606A32F for ; Wed, 18 Nov 2026 17:02:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=361ISdXu; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=foss header.b=BeDnEUjL DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:In-Reply-To:From:References:Cc:To:Subject:MIME-Version:Date: Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Unsubscribe-Post: List-Owner; bh=PRfp6SOVrrAYPUPThQxBxPybxQdM+w6pFXYthm3P4rY=; b=361ISdXuBh//J8 7SuWSO2A1z6u8ybBoAMAdUBklZ+dTM14OMTAgZTv1nYim7bwF5FatTuJBLsZI77fsPT2Ik8dgaeCJ MzylxZk5SoXc+QcGtn+EUWHf/by1mhF4L0f+HEHeCMPRQNZnBf6HKOJYbtp7S7RypFil9VyyE0A/V +SBk4yOxSgtJpu8jMKAG6gPTWOHPhX8Up/dOeQv4ZP4lXP/QwApxWaVtyiX8byuhVubheua+Tu9F/ rW17YIiFwhok/suvul5FKarut1lHSrnztbzHpgXahzjnASjruR10l4YS126TpxIDdK0MgSClJZbZb KXzzrr08t/gRjm/poWhg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xTj2k-00000009fwM-0zRU; Wed, 18 Nov 2026 17:01:58 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xTj2X-00000009fnK-2KBE for linux-arm-kernel@lists.infradead.org; Wed, 18 Nov 2026 17:01:57 +0000 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 B9B401477; Wed, 18 Nov 2026 09:01:41 -0800 (PST) Received: from [10.2.212.8] (e134344.arm.com [10.2.212.8]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id EE5373F673; Wed, 18 Nov 2026 09:01:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1795021304; bh=LS1Mza+LT5GtPiXw370EYY3WnzupngYzyQpWADqAtBc=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=BeDnEUjL7hljS5HnslQ+mrbt0j2OSrGwkAzycbQGkJ56SzUhqugnrlY8dqEC28ay1 u6jKSZVACBDEC9FfwNUZ9l5pYvH+LDxkflx7EPYK5/+/CdPKaETp7p686GRaRLt21D wrYcvhttDLmUtC6v+LjtNCVWHa4Zvg+KdEgdNSHw= Message-ID: Date: Wed, 18 Nov 2026 17:01:41 +0000 X-Archived-By: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3 4/8] arm_mpam: resctrl: Do not fail CPU online when domain setup fails To: Reinette Chatre , james.morse@arm.com, Dave.Martin@arm.com, fenghuay@nvidia.com, ruanjinjie@huawei.com Cc: tony.luck@intel.com, yu.c.chen@intel.com, babu.moger@amd.com, fustini@kernel.org, tan.shaopeng@fujitsu.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, patches@lists.linux.dev References: Content-Language: en-US From: Ben Horgan In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20261118_090145_892584_31C51B7C X-CRM114-Status: GOOD ( 37.72 ) X-Spam-Score: -4.4 (----) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" X-Spam-Status: No, score=-17.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 Hi Reinette, On 10/11/2026 04:19, Reinette Chatre wrote: > When a CPU comes online, mpam_resctrl_online_cpu() adds it to the resctrl > domains of each resource in use, and sets up a new domain when the CPU > is the first of its domain to come online. A failure to set up a domain > is returned as the failure of MPAM's CPU hotplug startup callback. > > The CPU hotplug core does not run the teardown callback for a CPU whose > startup callback failed, so everything done for the CPU before the > failure stays in place: the CPU remains in the domains of the resources > that were handled before the failing one, and MPAM's per-MSC state for > the CPU is not undone. If the failure happens when MPAM installs its > CPU hotplug callbacks during enabling, the hotplug core discards the > callbacks, leaving MPAM enabled and resctrl initialized but MPAM no > longer notified of CPU hotplug. If it happens when a CPU comes online > later, the CPU fails to come online. > > Setting up a domain only fails if a memory allocation fails or if a > class unexpectedly has no component for the CPU. For such rare failures > losing a resctrl domain is a smaller cost than failing CPU online or > leaving MPAM in an inconsistent state. > > Do not report domain setup failures from mpam_resctrl_online_cpu() and > leave the CPU without a domain for that resource. Make > mpam_resctrl_alloc_domain() return nothing since its failures are no > longer reported. Keep adding the CPU to resctrl's default group even > when a domain could not be set up, since the CPU is online and runs > tasks regardless, and resctrl expects every online CPU to belong to a > resource group. Warn on a failed domain allocation and on a missing > monitoring component so these failures are not silent. Drop the warning > when a CPU going offline has no domain, since a missing domain is now > expected. > > Only domains that were set up are exposed through resctrl and torn down > when their CPUs go offline. When another CPU of the same domain comes > online, it sets up the domain again, and if that succeeds the domain > does not include the CPU for which setup failed. > > Signed-off-by: Reinette Chatre > Tested-by: Jinjie Ruan > Reviewed-by: Jinjie Ruan Looks good to me. Reviewed-by: Ben Horgan > --- > Changes since RFC v2: > - Add Jinjie's Reviewed-by tag. > - Add Jinjie's Tested-by tag. > - WARN when domain allocation fails. (Ben) > - Squash patch that replaces WARN_ON_ONCE(0) with > WARN_ON_ONCE(!any_mon_comp). (Ben) > --- > drivers/resctrl/mpam_devices.c | 2 +- > drivers/resctrl/mpam_internal.h | 4 ++-- > drivers/resctrl/mpam_resctrl.c | 37 +++++++++++++++------------------ > 3 files changed, 20 insertions(+), 23 deletions(-) > > diff --git a/drivers/resctrl/mpam_devices.c b/drivers/resctrl/mpam_devices.c > index 27abf60f4d67..a95326f2ef88 100644 > --- a/drivers/resctrl/mpam_devices.c > +++ b/drivers/resctrl/mpam_devices.c > @@ -2247,7 +2247,7 @@ static int mpam_cpu_online(unsigned int cpu) > } > > if (mpam_resctrl_enabled) > - return mpam_resctrl_online_cpu(cpu); > + mpam_resctrl_online_cpu(cpu); > > return 0; > } > diff --git a/drivers/resctrl/mpam_internal.h b/drivers/resctrl/mpam_internal.h > index 1f86cc158100..84c7adbb1a40 100644 > --- a/drivers/resctrl/mpam_internal.h > +++ b/drivers/resctrl/mpam_internal.h > @@ -525,13 +525,13 @@ int mpam_get_cpumask_from_cache_id(unsigned long cache_id, u32 cache_level, > #ifdef CONFIG_RESCTRL_FS > int mpam_resctrl_setup(void); > void mpam_resctrl_exit(void); > -int mpam_resctrl_online_cpu(unsigned int cpu); > +void mpam_resctrl_online_cpu(unsigned int cpu); > void mpam_resctrl_offline_cpu(unsigned int cpu); > void mpam_resctrl_teardown_class(struct mpam_class *class); > #else > static inline int mpam_resctrl_setup(void) { return 0; } > static inline void mpam_resctrl_exit(void) { } > -static inline int mpam_resctrl_online_cpu(unsigned int cpu) { return 0; } > +static inline void mpam_resctrl_online_cpu(unsigned int cpu) { } > static inline void mpam_resctrl_offline_cpu(unsigned int cpu) { } > static inline void mpam_resctrl_teardown_class(struct mpam_class *class) { } > #endif /* CONFIG_RESCTRL_FS */ > diff --git a/drivers/resctrl/mpam_resctrl.c b/drivers/resctrl/mpam_resctrl.c > index d0c7c741ce90..ec39f3909388 100644 > --- a/drivers/resctrl/mpam_resctrl.c > +++ b/drivers/resctrl/mpam_resctrl.c > @@ -1640,8 +1640,8 @@ static struct mpam_component *find_component(struct mpam_class *class, int cpu) > return NULL; > } > > -static struct mpam_resctrl_dom * > -mpam_resctrl_alloc_domain(unsigned int cpu, struct mpam_resctrl_res *res) > +static void mpam_resctrl_alloc_domain(unsigned int cpu, > + struct mpam_resctrl_res *res) > { > int err; > struct mpam_resctrl_dom *dom; > @@ -1656,11 +1656,11 @@ mpam_resctrl_alloc_domain(unsigned int cpu, struct mpam_resctrl_res *res) > comp = find_component(class, cpu); > /* class has no component for this CPU */ > if (WARN_ON_ONCE(!comp)) > - return ERR_PTR(-EINVAL); > + return; > > dom = kzalloc_node(sizeof(*dom), GFP_KERNEL, cpu_to_node(cpu)); > - if (!dom) > - return ERR_PTR(-ENOMEM); > + if (WARN_ON_ONCE(!dom)) > + return; > > if (r->alloc_capable) { > dom->ctrl_comp = comp; > @@ -1701,11 +1701,8 @@ mpam_resctrl_alloc_domain(unsigned int cpu, struct mpam_resctrl_res *res) > if (mon_comp) > any_mon_comp = mon_comp; > } > - if (!any_mon_comp) { > - WARN_ON_ONCE(0); > - err = -EFAULT; > + if (WARN_ON_ONCE(!any_mon_comp)) > goto offline_ctrl_domain; > - } > > mon_d = &dom->resctrl_mon_dom; > mpam_resctrl_domain_hdr_init(cpu, any_mon_comp, r->rid, &mon_d->hdr); > @@ -1719,7 +1716,7 @@ mpam_resctrl_alloc_domain(unsigned int cpu, struct mpam_resctrl_res *res) > pr_debug("Skipped monitor domain online - no monitors\n"); > } > > - return dom; > + return; > > offline_ctrl_domain: > if (r->alloc_capable) { > @@ -1728,9 +1725,6 @@ mpam_resctrl_alloc_domain(unsigned int cpu, struct mpam_resctrl_res *res) > } > free_domain: > kfree(dom); > - dom = ERR_PTR(err); > - > - return dom; > } > > /* > @@ -1782,7 +1776,7 @@ mpam_resctrl_get_domain_from_cpu(int cpu, struct mpam_resctrl_res *res) > return mpam_resctrl_get_mon_domain_from_cpu(cpu); > } > > -int mpam_resctrl_online_cpu(unsigned int cpu) > +void mpam_resctrl_online_cpu(unsigned int cpu) > { > struct mpam_resctrl_res *res; > enum resctrl_res_level rid; > @@ -1797,9 +1791,13 @@ int mpam_resctrl_online_cpu(unsigned int cpu) > > dom = mpam_resctrl_get_domain_from_cpu(cpu, res); > if (!dom) { > - dom = mpam_resctrl_alloc_domain(cpu, res); > - if (IS_ERR(dom)) > - return PTR_ERR(dom); > + /* > + * On failure the CPU is left without a domain for this > + * resource, which mpam_resctrl_offline_cpu() tolerates. > + * resctrl_online_cpu() still adds the CPU to the default > + * group because the CPU is online and runs tasks. > + */ > + mpam_resctrl_alloc_domain(cpu, res); > } else { > if (r->alloc_capable) { > struct rdt_ctrl_domain *ctrl_d = &dom->resctrl_ctrl_dom; > @@ -1815,8 +1813,6 @@ int mpam_resctrl_online_cpu(unsigned int cpu) > } > > resctrl_online_cpu(cpu); > - > - return 0; > } > > void mpam_resctrl_offline_cpu(unsigned int cpu) > @@ -1837,8 +1833,9 @@ void mpam_resctrl_offline_cpu(unsigned int cpu) > if (!res->class) > continue; // dummy resource > > + /* The domain may be missing if its setup failed. */ > dom = mpam_resctrl_get_domain_from_cpu(cpu, res); > - if (WARN_ON_ONCE(!dom)) > + if (!dom) > continue; > > if (r->alloc_capable) {