From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D68A3606A31A for ; Mon, 30 Nov 2026 20:36:46 +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=Mt8n8RA8 Received: by kanga.kvack.org (Postfix) id 025856B05B3; Mon, 30 Nov 2026 15:36:41 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id EF1CE6B05B4; Mon, 30 Nov 2026 15:36:40 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DB9C76B05B5; Mon, 30 Nov 2026 15:36:40 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 7793F6B05B3 for ; Mon, 30 Nov 2026 15:36:40 -0500 (EST) Received: from smtpin14.hostedemail.com (lb01a-stub [10.200.18.249]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 216B640C3D for ; Mon, 30 Nov 2026 20:36:40 +0000 (UTC) X-FDA: 85492943760.14.EC0DA56 Received: from sea.source.kernel.org (sea.source.kernel.org [172.234.252.31]) by imf02.hostedemail.com (Postfix) with ESMTP id 76A4D8000C for ; Mon, 30 Nov 2026 20:36:38 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20260515 header.b=Mt8n8RA8; spf=pass (imf02.hostedemail.com: domain of tglx@kernel.org designates 172.234.252.31 as permitted sender) smtp.mailfrom=tglx@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Seal: i=1; a=rsa-sha256; d=hostedemail.com; s=arc-20220608; cv=none; t=1796070998; b=euoTy1BmdTGYsAPJxgAnatonWdFEsPy+Qkh8DxIu7E17BFYgef/fQ8bVRTQbYGZQhWThL0 cXi2NIbVnMJNeIqAzDCLLRgh6tC+MHa7sET2Crko94xK8bBVBO992p+i+dZueq/uztm38/ yHd2CZbxd9T4s5vmibVmTtQG9iQMdQw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1796070998; h=from:from:sender: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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=jUFDczjhIG78DJqAFUdUgdLkDZnLFycIVi7lHVnvr9M=; b=di3nKBuShKJzlFfS94fo1SC1YkXy6aJiJmdT4GHYPRKeRU/C4dzmFvyKOLIwMWK6uIEqt2 +j7G7nD4ZIcaMlCE0cGcNEaO3zR6P+YxlVuKfUGUT1hAJEh52t7G2NLEQL9Ev8+MZL1WQD aZNKyxZ5FREJYqQX8Kfa98nCy/n4ki4= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20260515 header.b=Mt8n8RA8; spf=pass (imf02.hostedemail.com: domain of tglx@kernel.org designates 172.234.252.31 as permitted sender) smtp.mailfrom=tglx@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id 834BA43B84; Mon, 30 Nov 2026 20:36:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 968111F000C1; Mon, 30 Nov 2026 20:36:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796070997; bh=jUFDczjhIG78DJqAFUdUgdLkDZnLFycIVi7lHVnvr9M=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=Mt8n8RA8ih9PkFiJASq6adaGp1uaKCuPJoisRv+JU1Wy0M2FMM72V53GSV7MoteUg lz/Ucaskp0obaEeKjiIRwgLM+q1K/7P/mkhFo/GumeSkzIZb/cHjKIaHERRXqIICa7 UaX3aRCCivj5oxoP0afFk1feJzPM7TV6hDuRqu+r3cqAsiVZlg59i4VnSmTZXSXh6g bYpzF39cdtSaEdoFv6nY0o0v/GPc6n6KNy96gReJxTfXhZltZ1L8Asxx72NStBSMQ8 yL8dpvwkBTtIc2WSQ8vVSHy0lMPM3FcInu2bNz+F4bYJ4Rffv38DQaSWyE/2Q28Atn Z9I8IdslHXaHA== From: Thomas Gleixner To: Mathieu Desnoyers , Karl Mehltretter Cc: peterz@infradead.org, linux-kernel@vger.kernel.org, mingo@redhat.com, juri.lelli@redhat.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de, vschneid@redhat.com, kprateek.nayak@amd.com, paulmck@kernel.org, boqun@kernel.org, shuah@kernel.org, kees@kernel.org, viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz, oleg@redhat.com, bestswngs@gmail.com, xmei5@asu.edu, xujiakai24@mails.ucas.ac.cn, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-kselftest@vger.kernel.org, Dominik Maier Subject: Re: [PATCH 00/17] sched/mmcid: fixes for execve, mode switches and affinity In-Reply-To: References: <87bj79s11m.ffs@fw13> <20261128192202.93895-1-kmehltretter@gmail.com> <875wxgshou.ffs@fw13> <8733sjs408.ffs@fw13> <87ecc2qs9i.ffs@fw13> Date: Mon, 30 Nov 2026 21:36:33 +0100 Message-ID: <87bj76qcoe.ffs@fw13> X-Archived-By: MIME-Version: 1.0 Content-Type: text/plain X-Rspam-User: X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 76A4D8000C X-Stat-Signature: makfbz9d14zy99upicdmcsife489n81z X-Spam-Status: No, score=-10.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAIL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ctvecYrIwSNJqbDgYfxi1wU3fv5c+R6lw+/tW1NiNMo5WrJL0Iv7oiInkngFSBgcfl91BZbNH+ahuxZylLjMNzW/1Mwqf7C70Gqqoa9gh3/yGCc2XcJa8/Kh6pQInH6qcZ3dx9J7z2Qg4aZxqxFA/VIUv3BHZE3R/lTmprXRX8rs010on+ld1VUYmlUEmjxDFNDDNNC2OqBhIKVCi/MmTYgpsI8RAqlWYGjsQxtQutONcQhQyignO1Sw1Rovj2L8FGI/hrKjZBZcan24IlM6UFTxOOQZr4txuGZgBO7fsdACk5W6KxOYAweR7wgmMN8mmnF69sgKYBhDlAtTJgpUS/qRX8xpOX51IloEqHO27VyPR/OY8qOY6CGpCWeRmwjmc60MtkTSuvsWwSSM9Sj98l/lz+EdaYvwl82kKzI5R/c8H1vnCG5JiZyBfH6LvvA4dAtgjFVw5w7DaEs56x/RQ== Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 On Mon, Nov 30 2026 at 13:59, Mathieu Desnoyers wrote: > Two small things: > > - In the affinity patch, the !CONFIG_SCHED_MM_CID stub of > mm_update_cpus_allowed() has no body: "{ }" is missing. I added it > in my split. > > - In this patch, the new comment in the last user branch of > sched_mm_cid_exit() says that sched_mm_cid_after_execve() handles > a stale transit. That function has no such code in this version. > It does not need it: with the hooks in exec_mmap(), a task never > rejoins the old mm. So the last sentence of the comment can go. Correct. I missed that one. > I also checked your two patches with the Spin model I mentioned in the > cover letter. It runs up to 3 tasks on 2 or 3 CPUs, with up to 6 > possible CPUs. No run found a violation of these: > > - The CIDs stay unique and below the number of possible CPUs. > - mm_get_cid() never waits. > - No affinity change is lost. > - The affinity update never reads a freed mm. > > Without your patches, the model finds the known bugs, the 0x80000000 > CID among them. > > The model found one new case with your affinity patch. It needs 4 > possible CPUs or more. The mm starts in per CPU mode, and pcpu_thrs > was computed for the allowed CPUs of its threads. Then: > > - A new child gets more allowed CPUs before sched_post_fork(). > Another task can do this with sched_setaffinity() on the new pid. > With CLONE_INTO_CGROUP, cpuset_fork() does it with the CPUs of the > target cpuset. > - mm_update_cpus_allowed() skips the child, which is not active yet. > - sched_mm_cid_add_user() adds the child's CPUs to the mm. It drops > the return value of __mm_update_cpus_allowed(), so pcpu_thrs is not > recomputed. > pcpu_thrs keeps the value of the smaller mask. So the mm stays in per > CPU mode when its user count drops below the threshold of the new > mask. Only an affinity change which adds a CPU to the mm recomputes > pcpu_thrs later. For example, a process left with 2 threads allowed on > 6 CPUs would use CIDs up to 5 instead of 0 and 1. The CIDs stay unique > and in bounds. Indeed. > This change on top of your affinity patch passes in the model. The > selftests give the same results with it: > > --- a/kernel/sched/core.c > +++ b/kernel/sched/core.c > @@ -11007,8 +11007,12 @@ static bool sched_mm_cid_add_user(struct task_struct *t, struct mm_struct *mm) > /* > * Update allowed CPUs to take any affinity change, which happened > * before sched_mm_cid_fork() acquired the locks, into account. > + * Adjust the threshold to a wider set, as mm_update_cpus_allowed() > + * does. > */ > - __mm_update_cpus_allowed(mm, &t->cpus_mask); > + if (__mm_update_cpus_allowed(mm, &t->cpus_mask) && > + cid_on_cpu(mm->mm_cid.mode)) > + mm->mm_cid.pcpu_thrs = mm_cid_calc_pcpu_thrs(&mm->mm_cid); > > t->mm_cid.active = 1; > hlist_add_head(&t->mm_cid.node, &mm->mm_cid.user_list); > > How do you want to route your patches? You can take them yourself. > Or I can carry them in the next version of this series, if you give me > your Signed-off-by for them. The selftests would come on top. Sure, pick them up and fold the fixes in. Just add a Suggested-by: tglx tag. That's good enough. Thanks, tglx