PID 1 hung again on the host running the test kernel (7.0.0-1014-aws
#14+TEST2165410v20261027b1), but through a path the series does not touch. No 
isolated
CPU and no memory-node change is involved. It reproduces in a VM on the source 
of that
test kernel from the PPA (7.0.14 plus patches 1-5, unchanged), and two small 
patches fix
it there. Mainline already has the main part of the fix since 7.3-rc1.

WHAT WE SAW (the test-kernel host, isolcpus=domain,nohz,managed_irq,4-75
nohz_full=4-75)

* PID 1 in D state from about 18:50 UTC on 2026-11-22 until we released it 11 h 
20 min
  later. Hung-task reports for two tasks, identical every two minutes:

    systemd:1                     __flush_workqueue+0x14e/0x430
                                  flush_migrate_mm_task_workfn+0x19/0x30
                                  task_work_run / exit_to_user_mode_loop / 
do_syscall_64
    kworker/u768:1                __flush_work / flush_work
    (cpuset_migrate_mm)           __lru_add_drain_all+0x19c/0x2c0
                                  lru_cache_disable+0x1f/0x30
                                  do_migrate_pages / cpuset_migrate_mm_workfn

* The drain it waited for was on CPU 82, which is NOT isolated. One service 
pinned to that
  CPU kept it busy; kworker/82:1 was runnable and got no CPU time. `renice -20` 
of that
  kworker released PID 1 within 5 seconds.
* PID 1's registers in the report: ORIG_RAX=1, RDX=7, RAX=7. It was returning 
from a
  successful 7-byte write(). A memory-node list on this two-node host is at 
most 4 bytes,
  so this was not a cpuset.mems write; a 6-digit pid plus newline written to 
cgroup.procs
  fits. The test kernel has patch 5, so systemd's O_NONBLOCK cpuset.mems writes 
do not
  wait any more, and cpuset_attach() is the only other place that schedules 
this flush.
* No unit on the host sets AllowedMemoryNodes= (last audited in September). 
system.slice
  has AllowedCPUs=0-3, user.slice is unrestricted (0-191). Scripted SSH logins 
arrive
  every few minutes.

CAUSE (v7.0 kernel/cgroup/cpuset.c)

1. cpuset_fork() does not set cs->old_mems_allowed when a task is cloned into a 
cpuset
   with CLONE_INTO_CGROUP. systemd spawns services that way, so the cpuset of a 
service
   keeps the empty mask it was allocated with.
2. When a task is moved out of such a cpuset into one with different CPUs,
   cpuset_attach() calls cpuset_migrate_mm(mm, &oldcs->old_mems_allowed, to). 
Empty is
   not equal to {0,1}, so a migration "from no nodes" is queued. 
do_migrate_pages() moves
   nothing, but calls lru_cache_disable() first: an LRU drain work item on 
every CPU that
   has folios batched.
3. cpuset_attach() then makes the writer wait for the migration queue. On a 
login that
   writer is PID 1: it moves the sshd session process from ssh.service into a 
session
   scope under user.slice.

So every login costs a system-wide LRU drain that PID 1 waits for, and one CPU 
that cannot
run its kworker hangs PID 1. Patch 5 does not help: it covers cpuset.mems 
writes opened
with O_NONBLOCK, and systemd writes cgroup.procs without it.

Mainline records the nodes in cpuset_fork() since 65e510cd30d0 ("cgroup/cpuset: 
Move
mpol_rebind_mm/cpuset_migrate_mm() calls inside cpuset_attach_task()", 
v7.3-rc1), as part
of the attach rework. 7.0 does not have it.

PATCHES (patches/0006 and 0007, generated on upstream v7.0 + 0001-0005)

They apply to the source of the test kernel (linux-aws 
7.0.0-1014.14+TEST2165410v20261027b1
from the PPA) with line offsets only.

0006  cgroup/cpuset: Record the memory nodes of tasks forked into a cpuset
      One assignment in cpuset_fork(), the same one mainline has.
      Fixes: 42a11bf5c543 ("cgroup/cpuset: Make cpuset_fork() handle 
CLONE_INTO_CGROUP properly")
0007  cgroup/cpuset: Only wait for memory migration on attach when one was 
queued
      cpuset_migrate_mm() reports whether it queued work; cpuset_attach() only 
schedules
      the flush in that case. This is the 7.0 form of what 
patches-mainline/0006 does in
      cpuset_attach_task().

VERIFICATION (QEMU/KVM; vm-test/results/summary-login-path.txt)

A non-isolated CPU is kept busy by a SCHED_FIFO task with the fair server off, 
with three
folios in its LRU batch. A process is moved between two cpusets with the same 
memory nodes
by one cgroup.procs write. Kernel: the test kernel's source from the PPA, as 
shipped and
with 0006 and 0007 applied.

                                              test kernel source   + 0006 + 0007
  source filled by CLONE_INTO_CGROUP,         STALL, 1 migration   0.008 s, 
nothing
    destination has other CPUs                work item queued     queued
  same, source filled by cgroup.procs write   0.003 s              0.004 s
  same, while another cpuset's migration      STALL                0.007 s
    is stuck behind the busy CPU
  source and destination have the same CPUs   0.007 s              0.007 s

The stall has the two stacks above and ends 0.1 s after the busy CPU is freed. 
Upstream
v7.0 with patches 1-5 gives the same results; there 0006 alone clears the first 
row and
0007 is what clears the third. Tests A-C of the earlier harness are unchanged.

To repeat it: vm-test/reproduce-login-path.sh in the tarball does the whole run 
in one
command. It downloads the test kernel's source from the PPA (or takes --source 
DIR), builds
it as it is and with 0006 + 0007, boots both under QEMU/KVM and prints this 
table.

NOT YET CONFIRMED

* I have not yet matched the journal of 18:49-18:51 UTC on the host to one 
login, nor
  traced on the host that a login queues a cpuset_migrate_mm work item. Both 
are in hand
  and I will post the result.
* Why kworker/82:1 got no CPU time for 11 hours is a separate question; I do 
not yet have
  the scheduling class of the threads on that CPU. The patches do not depend on 
how the
  CPU is starved.
* The VM kernels use a defconfig-based config (PREEMPT_LAZY, NO_HZ_FULL, cpuset 
v2 only),
  not the aws config.

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/2165410

Title:
  Ubuntu LTS 26.04 linux-aws: systemd enters D state and blocks SSH
  during cpuset migration on nohz_full CPUs

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/linux-aws/+bug/2165410/+subscriptions


-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to