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 DAB403DBD76 for ; Tue, 30 Jun 2026 17:56:43 +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=1782842206; cv=none; b=uDv6WG+Pa41M4Aue0pDAVA5c5Z+9WJ6IRJ4ta+nyLVUQISu2sADKuicwr1LKuiwNIZg6FMcqJngkvvAm1ZyHWorRfSpGqTTBIRYIVpZ1ns+ZKwLwl2eRQDhXDZV7l8x2L6dIOaD6rNYmomeQoOhU7wsajglWaC8UJbdLmU5uKIg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782842206; c=relaxed/simple; bh=z64Zvugew+P1MInglJmh7Jam4FjCF1L/n6yrx55KL8c=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=YZXjcoe7fg8xSyfr0n0Ek9ppwSeMvZAxurHDCaftHf3jy3E9j0fNZVP+CDvJ//oqzi4sNJLFRMrHzB5kgPGCDX1q21iFnx0eu2WteYGqVeKQGkb1fx3WE1OqGuF+fLR+u17N/wtvKqieVMi96qHMA8DHRe8mN3AH+yymaSBiYXg= 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=SP14efyY; 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="SP14efyY" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1782842202; 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=Y5XIm2s2oESgGUDdl7rh3Y8K1wz6Jr9u+0+fQyisStw=; b=SP14efyY/NUoEL1qOleDQ4uSy1Xiy8/ehYsXhMr+f19FAX0oTbkO7qwWdnL9z8HZrn0+AZ uoScmJE0MZRlTgRj1pxBbzXViIrJ0Id9zwtb27Wp9CnlRoAO7WrvDw6HbaRqmersVQRH08 8I+acdwXaWK2lNg7Q7j/WCoALssYdLA= Received: from mx-prod-mc-06.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-657-IM9iqbr9OZuDB3leHEwJKw-1; Tue, 30 Jun 2026 13:56:39 -0400 X-MC-Unique: IM9iqbr9OZuDB3leHEwJKw-1 X-Mimecast-MFC-AGG-ID: IM9iqbr9OZuDB3leHEwJKw_1782842197 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (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-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 01DFE18009E3; Tue, 30 Jun 2026 17:56:37 +0000 (UTC) Received: from [10.2.17.12] (unknown [10.2.17.12]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id C00E21956088; Tue, 30 Jun 2026 17:56:33 +0000 (UTC) Message-ID: Date: Tue, 30 Jun 2026 13:56:32 -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-next v9 01/11] cgroup/cpuset: Make nr_deadline_tasks an atomic_t To: Juri Lelli Cc: Ridong Chen , Tejun Heo , Johannes Weiner , =?UTF-8?Q?Michal_Koutn=C3=BD?= , Shuah Khan , cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Aaron Tomlin , Guopeng Zhang References: <20260630033344.352702-1-longman@redhat.com> <20260630033344.352702-2-longman@redhat.com> Content-Language: en-US From: Waiman Long In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 On 6/30/26 10:01 AM, Juri Lelli wrote: > Hi Waiman, > > On 29/06/26 23:33, Waiman Long wrote: >> The nr_deadline_tasks variable in the cpuset structure was introduced by >> commit 6c24849f5515 ("sched/cpuset: Keep track of SCHED_DEADLINE task >> in cpusets"). It is reported by sashiko [1] that nr_deadline_tasks >> can currently be modified by inc_dl_tasks_cs() under rq->lock and >> by cpuset_attach() under cpuset_mutex. So if both updates happen >> simultaneously, the nr_deadline_tasks variable can be corrupted leading >> to incorrect operations down the road. >> >> Fix that by changing its type to atomic_t so that nr_deadline_tasks are >> always atomically updated. >> >> [1] https://sashiko.dev/#/patchset/20260626181923.133658-1-longman%40redhat.comk >> >> Fixes: 6c24849f5515 ("sched/cpuset: Keep track of SCHED_DEADLINE task in cpusets") >> Signed-off-by: Waiman Long >> --- > Looks like Sashiko is yet not completely happy with this: > > https://sashiko.dev/#/patchset/20260630033344.352702-1-longman%40redhat.com > > I actually wondered the same and couldn't convince myself we don't > actually have that problem with the window between sched_setscheduler() > and cpuset_attach(). If issue is confirmed, not sure if wait_attach_ > done_lock() could help here as well? It's kind of a big lock for the > scheduler, but maybe only affecting DEADLINE tasks and if migrations > are ongoing. Yes, I am aware of that. This patch can only partially close the race window. It doesn't completely eliminate it. My current thought is for inc_dl_tasks_cs() to check if the in_progress flag is set. If so, it sets another flag for cpuset_attach() to double check the DL data for consistency. It will be a rather complicated solution in order to eliminate the race window. So I am postponing it to a later time when I have more free time to think about it. Cheers, Longman