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.133.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 F3FEC2571DD for ; Fri, 8 May 2026 02:26:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778207204; cv=none; b=GY0pF+5MRlqfNhT4sYEtUjfoBLJ8PN8m4ldounKs9FYFdv7Sg8rd8+aQHHMaMc+hQjIcphhIEofqK+xbA04Nsta4TctY4IHgldQBmdeVmM5CKNFpxUnUKwNPEsWd11npK7DbdZEr2ogiTfrGE8wrv0V7aOkm7+pgXpDpTwuSfs0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778207204; c=relaxed/simple; bh=6/RSalBHI0pfI6AbtPBYxQtCmMkyokNiv6ItsHzwFg4=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=T94Rrx8Cf+kTQWDah9kQO/zojJ9zIi7PGQ+UzCtMiXPfgDM9FzGyIFuNJY88kUz9SMaXzQjo8DUbqspwZ6133Prgbdc1a7ylOdZHLiV/TY3tLVOryOwqV3Isdj9CYvyGhtvEPggVhqGnT6/Daj0sdsnVSc6LGzbzaKBLS1bcFNQ= 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=ARHhdcA8; arc=none smtp.client-ip=170.10.133.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="ARHhdcA8" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1778207202; 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=N3U2igDBUZJtz/ZfFX4rmmix0sPx+03wNhxS/hhCrnU=; b=ARHhdcA83Bp6FQpDeGk5Pyuyh9nkfb4cursnSv4Uk/atPJxLTzMmufSQNDq0qTnI9T43pV ePF9N+XvqFACQ9xIwaEgDZJxCwnRiCJOq0O3LOjAyU59s+YR20aVGL0lIPzVXFj0ghwgzc VTVq804kBQz67xmbG6tzGukuj6+cryU= Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-216-oVi7TPr5NjuwY388fNUnuA-1; Thu, 07 May 2026 22:26:36 -0400 X-MC-Unique: oVi7TPr5NjuwY388fNUnuA-1 X-Mimecast-MFC-AGG-ID: oVi7TPr5NjuwY388fNUnuA_1778207194 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (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-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 99280180034C; Fri, 8 May 2026 02:26:33 +0000 (UTC) Received: from [10.2.16.15] (unknown [10.2.16.15]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 803F418004A3; Fri, 8 May 2026 02:26:27 +0000 (UTC) Message-ID: Date: Thu, 7 May 2026 22:26:26 -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 v2 1/2] cgroup/cpuset: reset DL migration state on can_attach() failure To: Chen Ridong , Guopeng Zhang , Tejun Heo , =?UTF-8?Q?Michal_Koutn=C3=BD?= , Ingo Molnar , Peter Zijlstra , Juri Lelli Cc: Johannes Weiner , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Valentin Schneider , K Prateek Nayak , Gabriele Monaco , Will Deacon , linux-kernel@vger.kernel.org, cgroups@vger.kernel.org References: <20260507103310.35849-1-zhangguopeng@kylinos.cn> <20260507103310.35849-2-zhangguopeng@kylinos.cn> <6410d11c-1d8a-4e72-ac22-43058027b304@redhat.com> <5d69e8bb-c925-4de2-8d50-0880b23864e0@huaweicloud.com> Content-Language: en-US From: Waiman Long In-Reply-To: <5d69e8bb-c925-4de2-8d50-0880b23864e0@huaweicloud.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 On 5/7/26 10:14 PM, Chen Ridong wrote: > > On 2026/5/7 22:31, Waiman Long wrote: >> On 5/7/26 6:33 AM, Guopeng Zhang wrote: >>> cpuset_can_attach() accumulates temporary SCHED_DEADLINE migration >>> state in the destination cpuset while walking the taskset. >>> >>> If a later task_can_attach() or security_task_setscheduler() check >>> fails, cgroup_migrate_execute() treats cpuset as the failing subsystem >>> and does not call cpuset_cancel_attach() for it. The partially >>> accumulated state is then left behind and can be consumed by a later >>> attach, corrupting cpuset DL task accounting and pending DL bandwidth >>> accounting. >>> >>> Reset the pending DL migration state before returning from those >>> per-task failure paths. >>> >>> Fixes: 2ef269ef1ac0 ("cgroup/cpuset: Free DL BW in case can_attach() fails") >>> Signed-off-by: Guopeng Zhang >>> --- >>>   kernel/cgroup/cpuset.c | 8 ++++++-- >>>   1 file changed, 6 insertions(+), 2 deletions(-) >>> >>> diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c >>> index e3a081a07c6d..ae41736399a1 100644 >>> --- a/kernel/cgroup/cpuset.c >>> +++ b/kernel/cgroup/cpuset.c >>> @@ -3029,12 +3029,12 @@ static int cpuset_can_attach(struct cgroup_taskset *tset) >>>       cgroup_taskset_for_each(task, css, tset) { >>>           ret = task_can_attach(task); >>>           if (ret) >>> -            goto out_unlock; >>> +            goto out_reset_dl_data; >>>             if (setsched_check) { >>>               ret = security_task_setscheduler(task); >>>               if (ret) >>> -                goto out_unlock; >>> +                goto out_reset_dl_data; >>>           } >>>             if (dl_task(task)) { >>> @@ -3070,6 +3070,10 @@ static int cpuset_can_attach(struct cgroup_taskset *tset) >>>        * changes which zero cpus/mems_allowed. >>>        */ >>>       cs->attach_in_progress++; >>> +    goto out_unlock; >>> + >>> +out_reset_dl_data: >>> +    reset_migrate_dl_data(cs); >>>   out_unlock: >>>       mutex_unlock(&cpuset_mutex); >>>       return ret; >> I would prefer the likely success path be a straight line instead of doing a >> goto. IOW, move out_reset_dl_data below return. Other than that, this patch >> looks good to me. >> > I've read the code and found several places that call reset_migrate_dl_data(cs). > > I think it would be better to call reset_migrate_dl_data(cs) only when we > encounter an error, for example: > > ``` > static int cpuset_can_attach(struct cgroup_taskset *tset) > { > ... > out_unlock: > if (ret) > reset_migrate_dl_data(cs); > mutex_unlock(&cpuset_mutex); > return ret; > } > ``` > After that, no other places would need to call reset_migrate_dl_data(cs), right? > Yes, that should work too. Cheers, Longman