Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp1374480rwb; Fri, 23 Sep 2022 11:42:56 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6VVP2gJrQQ4nqijFVds2Vp1gtO/y/8u2ElXaR04ymKGL6qKF8E5wi/sruQnVpc/ihGE+Td X-Received: by 2002:a17:902:ea11:b0:178:1c19:b0f5 with SMTP id s17-20020a170902ea1100b001781c19b0f5mr9830652plg.152.1663958576677; Fri, 23 Sep 2022 11:42:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663958576; cv=none; d=google.com; s=arc-20160816; b=owzt7i5vEnjVt9m5VHDCD7wqhwm3rSlx+f7d1HzX8rC8HNuncmuHOwjIPHHUv5XeH1 x67NBqSklczsnMGK6r7Uktjp815MwNplvyrb4HIijcPY7DBgPyZhQ9qyEkonCzxhgTUo NyOh9Pg5Fd0MmtXNIBxsAWLFYrEGR7tlghM2RuTZkRairYvWKNsn+p6LJCYg4nTWfbyT 7+3DkcnkM79axriGcGu0O2GIb6QuUr8t/KytrR7rF+o2wcoJSI+7YEEryRAYJ2LB4toz FOcVmbXltonEioO2dMujxoff5Gz6H54O/uNb9COUm/7tFYfTHZavKq6ezZFpJZoIeYUk 3Qeg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=wk9ByOGWhYGaJSRveqF77XxGxLJRdBox3MOCpChVo5g=; b=wObzA23CG0vFkusQ26XVO49lRy9ta4kDjlTbVL6N9LefAWV5/7I6cPFwdXbqhMbeHr T3EUY9WVpib5whStLOfvicgnTPfMbSy63NFF+moGvTnOayzfA5La0ddHz9KjGcUGP+yl l1c4QSrkLpUw/20rj/pJw7kDy35zAT6TG6bdYiT9A13Al7Goqv8zDD4pv1iHCngdKm71 PZ09OZHTGOS92146mzaxRfXwtCl3/lsHvfgVjMoqzFyUn9J0bqn6UBMEAkaS5ZxdwC1M OmR9f1LhO+/LGiEgjcZtI1Ozagl5pS2mEjeeHjMzeKIS9A1AkkwGUisB013IhvNHCwyS wcBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=pXNEkCsM; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w12-20020a056a0014cc00b0053ab9e2886dsi10252826pfu.49.2022.09.23.11.42.45; Fri, 23 Sep 2022 11:42:56 -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; dkim=pass header.i=@linutronix.de header.s=2020 header.b=pXNEkCsM; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232877AbiIWSD3 (ORCPT + 99 others); Fri, 23 Sep 2022 14:03:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36624 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232650AbiIWSCi (ORCPT ); Fri, 23 Sep 2022 14:02:38 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 751CA13EEAA; Fri, 23 Sep 2022 11:02:00 -0700 (PDT) Date: Fri, 23 Sep 2022 18:01:57 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1663956119; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wk9ByOGWhYGaJSRveqF77XxGxLJRdBox3MOCpChVo5g=; b=pXNEkCsMLOWVqwACB928I4Qf9+Nn5c/OKC6troXVG4kaLcuBonXUiME3gxPhgaWwUz3x+n Gvcil2hdxnDyf+7ZwumhxMGWdRHqHSfj02JW6EZEu1KK1Q4cProeddvPpO08jC/sjqgYGv v9IkB9wFs2iy6SqmQ944L1nARonHAnW1NY1hKoFjDbHA4uhHnskYU3+qWifEewz1tPPqsY ORPh0ql5CIyCe8kEADn3FRNJ1SkmlFqx6+RVIxf2z/g+1mXwl8XNjk+5Kr5F5Q4PriwWfQ lKQgRX0e+OzIZ6RLgXPue+OUpnuCTW56FmiUYXHPUQdQf3jC3kItgqFlnXuNKQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1663956119; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wk9ByOGWhYGaJSRveqF77XxGxLJRdBox3MOCpChVo5g=; b=60sXgjXKZHJOTLmlJNP1gzcl/jgbGt9iDv7Un76jdaOd14QM69GDHbkrq3RSPSPOYconjy lApsGKa/rl+dC3Bg== From: "tip-bot2 for James Morse" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/cache] x86/resctrl: Group struct rdt_hw_domain cleanup Cc: James Morse , Borislav Petkov , Jamie Iles , Shaopeng Tan , Reinette Chatre , Xin Hao , Cristian Marussi , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20220902154829.30399-5-james.morse@arm.com> References: <20220902154829.30399-5-james.morse@arm.com> MIME-Version: 1.0 Message-ID: <166395611790.401.175925430801977412.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS 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 The following commit has been merged into the x86/cache branch of tip: Commit-ID: 7add3af4178d9e25afc8d990a7d1000ccb22b6a0 Gitweb: https://git.kernel.org/tip/7add3af4178d9e25afc8d990a7d1000ccb22b6a0 Author: James Morse AuthorDate: Fri, 02 Sep 2022 15:48:12 Committer: Borislav Petkov CommitterDate: Thu, 22 Sep 2022 15:27:15 +02:00 x86/resctrl: Group struct rdt_hw_domain cleanup domain_add_cpu() and domain_remove_cpu() need to kfree() the child arrays that were allocated by domain_setup_ctrlval(). As this memory is moved around, and new arrays are created, adjusting the error handling cleanup code becomes noisier. To simplify this, move all the kfree() calls into a domain_free() helper. This depends on struct rdt_hw_domain being kzalloc()d, allowing it to unconditionally kfree() all the child arrays. Signed-off-by: James Morse Signed-off-by: Borislav Petkov Reviewed-by: Jamie Iles Reviewed-by: Shaopeng Tan Reviewed-by: Reinette Chatre Tested-by: Xin Hao Tested-by: Shaopeng Tan Tested-by: Cristian Marussi Link: https://lore.kernel.org/r/20220902154829.30399-5-james.morse@arm.com --- arch/x86/kernel/cpu/resctrl/core.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resctrl/core.c index 25f3014..e37889f 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -414,6 +414,13 @@ void setup_default_ctrlval(struct rdt_resource *r, u32 *dc, u32 *dm) } } +static void domain_free(struct rdt_hw_domain *hw_dom) +{ + kfree(hw_dom->ctrl_val); + kfree(hw_dom->mbps_val); + kfree(hw_dom); +} + static int domain_setup_ctrlval(struct rdt_resource *r, struct rdt_domain *d) { struct rdt_hw_resource *hw_res = resctrl_to_arch_res(r); @@ -488,7 +495,7 @@ static void domain_add_cpu(int cpu, struct rdt_resource *r) rdt_domain_reconfigure_cdp(r); if (r->alloc_capable && domain_setup_ctrlval(r, d)) { - kfree(hw_dom); + domain_free(hw_dom); return; } @@ -497,9 +504,7 @@ static void domain_add_cpu(int cpu, struct rdt_resource *r) err = resctrl_online_domain(r, d); if (err) { list_del(&d->list); - kfree(hw_dom->ctrl_val); - kfree(hw_dom->mbps_val); - kfree(hw_dom); + domain_free(hw_dom); } } @@ -547,12 +552,10 @@ static void domain_remove_cpu(int cpu, struct rdt_resource *r) if (d->plr) d->plr->d = NULL; - kfree(hw_dom->ctrl_val); - kfree(hw_dom->mbps_val); bitmap_free(d->rmid_busy_llc); kfree(d->mbm_total); kfree(d->mbm_local); - kfree(hw_dom); + domain_free(hw_dom); return; }