From: sashiko-bot@kernel.org
To: "Weiming Shi" <bestswngs@gmail.com>,
"Ingo Molnar" <mingo@redhat.com>,
"Peter Zijlstra" <peterz@infradead.org>,
"Juri Lelli" <juri.lelli@redhat.com>,
"Vincent Guittot" <vincent.guittot@linaro.org>,
"Dietmar Eggemann" <dietmar.eggemann@arm.com>,
"Steven Rostedt" <rostedt@goodmis.org>,
"Ben Segall" <bsegall@google.com>, "Mel Gorman" <mgorman@suse.de>,
"Valentin Schneider" <vschneid@redhat.com>,
"K Prateek Nayak" <kprateek.nayak@amd.com>,
"Andrew Morton" <akpm@linux-foundation.org>,
"David Hildenbrand" <david@kernel.org>,
"Lorenzo Stoakes" <ljs@kernel.org>,
"Liam R . Howlett" <liam@infradead.org>,
"Vlastimil Babka" <vbabka@kernel.org>,
"Mike Rapoport" <rppt@kernel.org>,
"Suren Baghdasaryan" <surenb@google.com>,
"Michal Hocko" <mhocko@suse.com>, "Kees Cook" <kees@kernel.org>
Cc: linux-mm@kvack.org, "Xiang Mei" <xmei5@asu.edu>
Subject: Re: [PATCH] sched/mmcid: Defer affinity updates until schedule-in
Date: Sat, 07 Nov 2026 12:09:08 +0000 [thread overview]
Message-ID: <sashiko-outbox-202871@kernel.org> (raw)
In-Reply-To: <20261106120846.2405936-1-bestswngs@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] sched/mmcid: affinity expansions lost or delayed by
mm_cid_schedin() deferral
--
commit 8130aa795d763d1b0e9fc8f80bab96df5fedde9e
Author: Weiming Shi <bestswngs@gmail.com>
sched/mmcid: Defer affinity updates until schedule-in
This commit defers MM-CID allowed-CPU mask updates from
set_cpus_allowed_common() to mm_cid_schedin() and sched_mm_cid_fork() to
avoid accessing a remote task's mm while it may be replaced and freed
during exec.
> diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
> index 7d2ec527b8a25..8e8934376e340 100644
> --- a/kernel/sched/sched.h
> +++ b/kernel/sched/sched.h
[ ... ]
> @@ -4132,6 +4139,10 @@ static __always_inline void mm_cid_schedin(struct task_struct *next)
>
> if (!next->mm_cid.active)
> return;
> + if (unlikely(next->mm_cid.cpus_allowed_changed)) {
> + mm_update_cpus_allowed(mm, &next->cpus_mask);
> + next->mm_cid.cpus_allowed_changed = false;
> + }
>
> cpu_cid = __this_cpu_read(mm->mm_cid.pcpu->cid);
> mode = READ_ONCE(mm->mm_cid.mode);
[Severity: Medium]
Can deferring mm_update_cpus_allowed() solely to mm_cid_schedin() delay or
lose affinity expansions in mm_cpus_allowed(mm)?
When a running task widens its affinity mask, task_cpu(p) remains in
p->cpus_mask, so affine_move_task() returns without migrating or
context-switching p. Until p is later preempted and scheduled back in,
mm->mm_cid.nr_cpus_allowed, max_cids, and pcpu_thrs stay stale for all
threads sharing the mm.
Because p->cpus_mask only holds the latest mask, any intermediate
expansion that is narrowed again before the next mm_cid_schedin() (or if
the task exits via sched_mm_cid_exit() before scheduling in again) is
never folded into the growth-only mm_cpus_allowed(mm) mask, leaving
max_cids capped too low or triggering wrong per-CPU mode transitions.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261106120846.2405936-1-bestswngs@gmail.com?part=1
prev parent reply other threads:[~2026-11-07 12:09 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-06 12:08 [PATCH] sched/mmcid: Defer affinity updates until schedule-in Weiming Shi
2026-11-07 12:09 ` sashiko-bot [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=sashiko-outbox-202871@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=bestswngs@gmail.com \
--cc=bsegall@google.com \
--cc=david@kernel.org \
--cc=dietmar.eggemann@arm.com \
--cc=juri.lelli@redhat.com \
--cc=kees@kernel.org \
--cc=kprateek.nayak@amd.com \
--cc=liam@infradead.org \
--cc=linux-mm@kvack.org \
--cc=ljs@kernel.org \
--cc=mgorman@suse.de \
--cc=mhocko@suse.com \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=rppt@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=surenb@google.com \
--cc=vbabka@kernel.org \
--cc=vincent.guittot@linaro.org \
--cc=vschneid@redhat.com \
--cc=xmei5@asu.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.