From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796154076; b=A/lkpxLyp6wRFF9OEZgnukiWiLNCVHcn+7nbE/JfQ8wHjKf4b4YX5jfMkNRpz/56p1Vs P3ZheO2ivD4CBDUTIhXEh7YgYKC19HfraoypRDQ0ga2MnRUOebc4bdPr+SL9/Fbbf85tP n4V8Myf93FLbPBShgGwmxveKzf62PavwKsdHDg1CWjRix90RCgXU+Qy2O7IWFvSLIyn9h ujd7ERsaqIQycXXnLeD+SciWgxzXnFCbYfoLoKrop+iNyFUrVN3I9bjZpd0mUwpIAERmK srGHMlRDuCYbhLoM9YIV3bcwsWjKfGUnMsQ+0izO9vLiM+SPS0tgCQo7PlKRXdRZnyQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796154076; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=Uje2zKFk9/eoke/GgdMnI0V+fnwoWG9iFhWQ3ohV+Xg=; b=aAD7kpQ0n7u7hu6xXdqijWUd6VrS2W7ZVt4ZPhuneBdkIC3Bkb348ClASgzR3JI1d/6d Eeeyk93D8YlIUjuvQ+9j2rb22acYnd/hRSieEh2niIHIn9zGEsmZdtB3AwgyoeZv90J4A plY1rILLDG09D2QlsjmHBoG97/1GEYdRttFK7X888Ju9JYTkwK+bje6+u3N8xVLEZvcWn 8vvmO8HvVw1+aVUpzkWAIZWkNzN/GGX4VkV0iZZ5034DoAJx0iqByHZKtruvuVXUZJc+w S3sTBTZEvHW85u010mHRUepV5KqwghckDTamAfGcpVD+nWgrkjVWnqhDbl1WcxQxCeg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=lrsJqcbC; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5B8E8606A690; Tue, 1 Dec 2026 19:41:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=lrsJqcbC Received: by smtp.kernel.org (Postfix) with ESMTPSA id DB6CC1F000C1; Tue, 1 Dec 2026 19:41:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796154076; bh=Uje2zKFk9/eoke/GgdMnI0V+fnwoWG9iFhWQ3ohV+Xg=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=lrsJqcbC5NHr1hsjxA02EWN3tIXs5rF0cFXJse82ZM3W00gPO+qFgS2BqmlsyXiEn JEIz1v6OZZM4caU1m1OOdZpC89zXj5RqsofQm1avt3RvVPetK9EKWIEu1ZDCmApaYJ vB8FKRccfqgeYwRZPZ/bN8lBx19oaAfk78WJcGRNfIF8H8JD9VdtGzlQr94p0UFrqh Q2uJ2s3oxMFh6JO0AA2h6JXGi4aJo4WFro+zRO9eDR0a3Lf/tMlZbldzqnDVaq1jga rZJhdDQDtiOYHuDeJo1l2kq+nZYY6tEHWqodOnS1ZcCCHKPlWkHY8JAE1C25nUzVV+ ESHBZZW8aK98A== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v13 31/36] sched/deadline: Count a task that departs while a rebuild walks the tasks Reply-To: sashiko-reviews@lists.linux.dev To: "Mathieu Desnoyers" Cc: linux-rt-devel@lists.linux.dev, tj@kernel.org, hannes@cmpxchg.org, mkoutny@suse.com, linux-kernel@vger.kernel.org In-Reply-To: References: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Tue, 01 Dec 2026 19:41:15 +0000 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Medium] sched/deadline: dl_task_depart() ignores cpus_mask and dl_bw_def during walk -- commit 7998428425c31015887f4856ff0afd652b3061f2 Author: Mathieu Desnoyers sched/deadline: Count a task that departs while a rebuild walks the tasks This commit counts the bandwidth of a task in dl_task_depart() when it leaves SCHED_DEADLINE during a root domain accounting rebuild after dl_clear_root_domains() has run and before the task-list walk reaches it. > diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c > index 7aa6c3f7e99d2..ef97b07c0aa21 100644 > --- a/kernel/sched/deadline.c > +++ b/kernel/sched/deadline.c [ ... ] > @@ -400,6 +419,24 @@ static void dl_task_depart(struct task_struct *p) > if (dl_se->dl_bw_gen =3D=3D dl_bw_gen && !dl_bw_rebuilding() && cpu_act= ive(cpu) && > cpu_rq(cpu)->rd =3D=3D cpu_rq(dl_se->dl_bw_cpu)->rd) > dl_record_bw_cpu(dl_se, cpu); > + /* > + * dl_clear_root_domains() counted the departed tasks, and the walk > + * of the task list counts the deadline tasks. A task that departs > + * after the clear, before the walk reaches it, would be counted by > + * neither. Count it here, as the walk would have. Use the CPU it > + * departs from, or else the CPU recorded, or else an active CPU of > + * its mask. If none is active, leave it out. While the sched domains > + * are rebuilt, the clear is still ahead, and finds the task on the > + * list. > + */ > + if (dl_bw_move_blocked(p) && !dl_bw_rebuilding()) { > + if (!cpu_active(cpu)) > + cpu =3D dl_se->dl_bw_cpu; > + if (!cpu_active(cpu)) > + cpu =3D cpumask_first_and(cpu_active_mask, &p->cpus_mask); > + if (cpu < nr_cpu_ids) > + dl_task_count_bw(p, cpu); > + } > list_add(&dl_se->dl_departed_node, &dl_departed_list); > } [Severity: Medium] Can dl_task_depart() charge the departing task's bandwidth to the wrong root domain when task_cpu(p) or dl_se->dl_bw_cpu is still active but no longer in p->cpus_mask? When p is sleeping while holding an rt_mutex, a cpuset partition change updates p->cpus_mask without migrating p off task_cpu(p). Unlike dl_task_rebuild_cpu(), which intersects candidate CPUs for a non-queued task with p->cpus_mask and matches dl_se->dl_bw_def, dl_task_depart() only checks cpu_active(cpu): kernel/sched/deadline.c:dl_task_rebuild_cpu() { ... cpumask_and(msk, &p->cpus_mask, cpu_active_mask); cpu =3D task_cpu(p); if (cpu_active(cpu) && task_on_rq_queued(p) && (cpu =3D=3D recorded || !cpumask_test_cpu(cpu, &p->cpus_mask))) return cpu; ... if (recorded >=3D 0) { bool def =3D READ_ONCE(p->dl.dl_bw_def); unsigned int same; if (cpumask_test_cpu(cpu, msk) && dl_cpu_in_def(cpu) =3D=3D def) return cpu; if (cpumask_test_cpu(recorded, msk) && dl_cpu_in_def(recorded) =3D=3D def) return recorded; ... } If the partition update that triggered dl_rebuild_rd_accounting() moved task_cpu(p) into another partition and removed it from p->cpus_mask, task_cpu(p) remains active in that other root domain. If p is deboosted before the task-list walk reaches it, dl_task_depart() picks task_cpu(p) and adds p->dl.dl_bw to the old CPU's new root domain instead of p's root domain until the 0-lag timer fires, leaving p's root domain under-counted for sched_setattr() admission and the other root domain over-counted. When no active CPU is found (cpu >=3D nr_cpu_ids), this hunk also leaves dl_se->dl_bw_skip_gen unset, though commit "sched/deadline: Count again a departed task that a boost brings back" later in this series updates that case. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/cover.1796146461.gi= t.mathieu.desnoyers@efficios.com?part=3D31