From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (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 5F82A3FE34B for ; Fri, 29 May 2026 18:07:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780078036; cv=none; b=rjABOG6MLicL02rcHZiaMcEYFmFGJvVpj/ogqd5HHsQ4UPEddBXSTWDCUaM8HXB5gwIcoi1pXJjdjA8sIH0TcvsJKoSbwEqhFyAzOFL2kKFsowghrxNAqNjs6DIvh9UTVNbJucMMFlmqz4/obH1AVqsMY+RznKTSR4pMcCK4ssE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780078036; c=relaxed/simple; bh=ZORxc4n+KTH/i6FIqCuHy9fzYjBBMWfKZ1IrOukTMow=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=EAWlVa40nJabW4semTxcaCFwFhg5zaOiHtLJAs3Yitnpu8V/1/qCDZ80bMF+rEDHXFjl07ciGy/6M1ppB0EsI79YLY1iIMfKrWXIJazFlbwAkqv+rgmTMhNG22/cvbo/aoLjNCJzbGuNadE3T7hCvI8pG2Y6oxOwfkie9bVX7CA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=NXlZEheu; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="NXlZEheu" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1780078034; h=from:from: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=6Yp5Z0v+vy9bAYL3uaXwsU8QnQUu67HN+KCDUZVXtOo=; b=NXlZEheuMJ4xzI+HLcxdc3m534CM05FXdeWw0MYmJa8UQ51o6pf0p7meNCRTdpzPHBv3xC WDkn13UskewnyjynO4HlD8qkyLLsKjrEnBb1D14Nzn/TMDvkQITDYesdOl9Obv5TgjrUMt khLtTLUCwnXMOYTK3Chouzqf1rO2z0s= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-283-QpAdufHnMS-hShS-r71XAw-1; Fri, 29 May 2026 14:07:09 -0400 X-MC-Unique: QpAdufHnMS-hShS-r71XAw-1 X-Mimecast-MFC-AGG-ID: QpAdufHnMS-hShS-r71XAw_1780078027 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 5E46A1956059; Fri, 29 May 2026 18:07:07 +0000 (UTC) Received: from [10.22.64.54] (unknown [10.22.64.54]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id A80651945110; Fri, 29 May 2026 18:07:05 +0000 (UTC) Message-ID: Date: Fri, 29 May 2026 14:07:04 -0400 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] cgroup/cpuset: Free sched domains on rebuild guard failure To: Guopeng Zhang , Tejun Heo , Johannes Weiner , =?UTF-8?Q?Michal_Koutn=C3=BD?= Cc: Chen Ridong , cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, Guopeng Zhang References: <20260528093742.1792456-1-guopeng.zhang@linux.dev> Content-Language: en-US From: Waiman Long In-Reply-To: <20260528093742.1792456-1-guopeng.zhang@linux.dev> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 On 5/28/26 5:37 AM, Guopeng Zhang wrote: > From: Guopeng Zhang > > generate_sched_domains() returns sched-domain masks and optional > attributes that are normally handed to partition_sched_domains(), which > takes ownership of them. > > rebuild_sched_domains_locked() has a WARN guard after > generate_sched_domains() and before partition_sched_domains() to avoid > passing offline CPUs into the scheduler domain rebuild path. If that > guard fires, the function currently returns directly without freeing > the generated doms and attr. > > Free the generated sched-domain masks and attributes before returning > from the guard failure path. > > Signed-off-by: Guopeng Zhang > --- > kernel/cgroup/cpuset.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c > index 51327333980a..c5fdebc205d8 100644 > --- a/kernel/cgroup/cpuset.c > +++ b/kernel/cgroup/cpuset.c > @@ -1004,8 +1004,11 @@ void rebuild_sched_domains_locked(void) > * prevent the panic. > */ > for (i = 0; doms && i < ndoms; i++) { > - if (WARN_ON_ONCE(!cpumask_subset(doms[i], cpu_active_mask))) > + if (WARN_ON_ONCE(!cpumask_subset(doms[i], cpu_active_mask))) { > + free_sched_domains(doms, ndoms); > + kfree(attr); > return; > + } > } > > /* Have scheduler rebuild the domains */ This WARN_ON_ONCE() is mainly used to catch bug during code update. It shouldn't be triggered in normal use. Anyway, it is a nice-to-have fix. Reviewed-by:  Waiman Long