From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.13]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9A746367B9B for ; Tue, 4 Aug 2026 01:15:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.13 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785806112; cv=none; b=R9b/oL54JXpetz2pHaXJaoLCFQfUJfgBdKuu92ynD89OLL4LswYNjrBq7uR46gSxnvLg+b+fNEKQ2FW7CYvzVBkcpSoZwhO3Av90TTL2KVppR5PxilozW3nndj9NZVaL3LIAOxV2ineRD+gewB3nGqX9DEwZD1eCoNDMEFR64K8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785806112; c=relaxed/simple; bh=1r5DK9Ru9GhnaGZVwfb8cBvudnvyRp0Sc/+jBnOTpcI=; h=Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References: Content-Type:MIME-Version; b=q6h7hucXTH8sbsMq/UtSEohqAjsl0Z3rZjSfzX1WN8jnZAokX5YUukEaRmxVcQhzqzA4AyC5/CB+n8g3F8I47SwTtfWeCZJr92j8RH+hQUVghRkOsnvknvfpZPuyckaSSu62zxjnhjewpXdj78C6/vRXnCLeIzhsSjlDBOCDW9A= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=pass smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=fYcOERI4; arc=none smtp.client-ip=192.198.163.13 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="fYcOERI4" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1785806110; x=1817342110; h=message-id:subject:from:to:cc:date:in-reply-to: references:content-transfer-encoding:mime-version; bh=1r5DK9Ru9GhnaGZVwfb8cBvudnvyRp0Sc/+jBnOTpcI=; b=fYcOERI4jjYhlPnPfeLlGCBSYeHdBvqmkNP3GRdpYZn+O9kzu5P+gBt8 O5i2TODy12aDNYBklSarjuasxXsoHU8/9ClHlXq57iuM2OF7h7HQnv5AK UWmZGOjf1NIeahhrfxrX6vpJ+oT5hp/4QEahtD1l2DM3lA9aaYHUHukOh tReqUjcg1cWTeRLyGzFBZ7P189LYW4jXPhPj7PAFzJe3ccJ39veyohK/K +nJILX4Uf7j+eY8Wv3Qlm4gaJgZaadTvNjuJUbXxRIZmD+VVI6HtfmDDb bYhcQaQ331DmBjf/dEeu0mv2ARaWcd5brBMe04UjkXUUCBkSUaRvFmbCV w==; X-CSE-ConnectionGUID: +PctjPJaTjCFcaBWL9o8EA== X-CSE-MsgGUID: Icpa8Bl0TSe07XrY+UntMg== X-IronPort-AV: E=McAfee;i="6800,10657,11864"; a="88878054" X-IronPort-AV: E=Sophos;i="6.25,203,1779174000"; d="scan'208";a="88878054" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by fmvoesa107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Aug 2026 18:15:10 -0700 X-CSE-ConnectionGUID: LtpViURnTYWc1FgSFlVBGg== X-CSE-MsgGUID: GWP1/tFJRHiGzNtivPRhXA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.25,203,1779174000"; d="scan'208";a="258022042" Received: from schen9-mobl4.amr.corp.intel.com (HELO [10.125.108.217]) ([10.125.108.217]) by fmviesa007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Aug 2026 18:15:08 -0700 Message-ID: <911d52f3a1a3040ffe447dde3f4a71b68da9f9f0.camel@linux.intel.com> Subject: Re: [PATCH] sched/topology: Free NUMA masks on topology allocation failure From: Tim Chen To: Fengyu Wang , Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot Cc: Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Valentin Schneider , K Prateek Nayak , Chen Yu , Shrikanth Hegde , linux-kernel@vger.kernel.org, wujianyong@hygon.cn, zhongyuan@hygon.cn, huangsj@hygon.cn Date: Mon, 03 Aug 2026 18:15:08 -0700 In-Reply-To: <20260731081413.5505-1-wangfengyu@hygon.cn> References: <20260731081413.5505-1-wangfengyu@hygon.cn> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.58.1 (3.58.1-1.fc43) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 On Fri, 2026-07-31 at 16:14 +0800, Fengyu Wang wrote: > sched_init_numa() publishes sched_domains_numa_masks before it > allocates the topology array. When that allocation fails, the early > return leaves the masks published while sched_domains_numa_levels is > still zero: nothing dereferences them, but nothing can free them > either, and the topology they were built for is never installed. > Unpublish and free them instead. >=20 > Fixes: cb83b629bae0 ("sched/numa: Rewrite the CONFIG_NUMA sched domain su= pport") > Signed-off-by: Fengyu Wang > --- > Tested by hardcoding tl to NULL right after the kzalloc() to force the > failure path; the masks are released and the machine boots normally. >=20 > kernel/sched/topology.c | 11 ++++++++++- > 1 file changed, 10 insertions(+), 1 deletion(-) >=20 > diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c > index 622e2e01974c..208fdc52f52d 100644 > --- a/kernel/sched/topology.c > +++ b/kernel/sched/topology.c > @@ -2403,8 +2403,17 @@ void sched_init_numa(int offline_node) > =20 > tl =3D kzalloc((i + nr_levels + 1) * > sizeof(struct sched_domain_topology_level), GFP_KERNEL); > - if (!tl) > + if (!tl) { > + rcu_assign_pointer(sched_domains_numa_masks, NULL); > + synchronize_rcu(); > + for (i =3D 0; i < nr_levels; i++) { > + for_each_node(j) > + kfree(masks[i][j]); > + kfree(masks[i]); > + } > + kfree(masks); > return; > + } The code is cleaner without the synchronize_rcu() and set to null dance if = we do rcu_assign_pointer(sched_domains_numa_masks, masks); after the tl check. Thanks. Tim > =20 > /* > * Copy the default topology bits..