Public bug reported:
== Summary ==
With updated stress-ng (v0.22.2), a new pinmem stressor was added (commit
834610b21 stress-pinmem: add memory pinning stressor)
It failed on focal 5.4.0-248.268 generic s390x (z/VM guest):
- stress-ng --pinmem 4 (io_uring buffer registration inside a memory cgroup)
ended with a kernel Oops
- the Oops happens in __gup_longterm_locked() called from
io_sqe_buffer_register(), in the task that was just killed by the memcg OOM
killer
- the register dump and the 5.4 source point at an unsigned/signed type bug in
check_and_migrate_cma_pages(), already fixed upstream by commit b96cc65515bb
("mm/gup.c: allow CMA migration to propagate errors back to caller", in v5.5,
not in v5.4)
== Test Information ==
* SRU Cycle: sru-20261123
* Series: focal
* Package: linux
* Kernel Version: 5.4.0-248.268
* Arch: s390x (z/VM guest, 8 CPUs, ~3.7 GiB RAM, 3 GiB swap, zswap enabled,
cgroup v1)
* Cloud / Target: metal
* Test Suite: ubuntu_stress_smoke_test
* Test Case: pinmem
== Failure Log ==
pinmem STARTING
pinmem RETURNED 0
pinmem FAILED (kernel oopsed)
[ 593.876329] stress-ng-pinme invoked oom-killer: gfp_mask=0xcc0(GFP_KERNEL),
order=0, oom_score_adj=1000
[ 593.876334] CPU: 3 PID: 208896 Comm: stress-ng-pinme Not tainted
5.4.0-248-generic #268-Ubuntu
[ 593.876335] Hardware name: IBM 2964 N63 400 (z/VM 6.4.0)
[ 593.876363] [<000000008425c1dc>] try_charge+0x73c/0x820
[ 593.876368] [<00000000841eee98>] do_swap_page+0x2b8/0x880
[ 593.876376] [<00000000841e9b18>] __gup_longterm_locked+0xb8/0x590
[ 593.876381] [<00000000842e3c1c>] io_sqe_buffer_register+0x22c/0x610
[ 593.876382] [<00000000842e41fa>] __io_uring_register+0x1fa/0x370
[ 593.876387] memory: usage 2172948kB, limit 2172948kB, failcnt 258937
[ 593.876420]
oom-kill:constraint=CONSTRAINT_MEMCG,...,oom_memcg=/stress-ng-test,task_memcg=/stress-ng-test,task=stress-ng-pinme,pid=208895,uid=0
[ 593.876428] Memory cgroup out of memory: Killed process 208895
(stress-ng-pinme) total-vm:685008kB, anon-rss:417172kB, ...
[ 593.940066] Unable to handle kernel pointer dereference in virtual kernel
address space
[ 593.940071] Failing address: 000003e00323c000 TEID: 000003e00323c803
[ 593.940073] Fault in home space mode while using kernel ASCE.
[ 593.940129] Oops: 0011 ilc:3 [#1] SMP
[ 593.940236] CPU: 4 PID: 208895 Comm: stress-ng-pinme Not tainted
5.4.0-248-generic #268-Ubuntu
[ 593.940238] Krnl PSW : 0704e00180000000 00000000841e9cca
(__gup_longterm_locked+0x26a/0x590)
[ 593.940248] Krnl GPRS: 000000000000003f 0000000000149000 0000000000000000
0000000000000000
[ 593.940248] 0000000000000002 0000000000000007 0000000085354260
fffffffffffffe00
[ 593.940249] 0000000000029200 0000000000000001 000003e0030f3000
0000000000000000
[ 593.940258] Krnl Code: ... sllg %r1,%r8,3 / >lg %r11,0(%r1,%r10) / lg
%r1,8(%r11)
[ 593.940275] Call Trace:
[ 593.940278] ([<00000000841e9d48>] __gup_longterm_locked+0x2e8/0x590)
[ 593.940280] [<00000000841ea046>] get_user_pages+0x56/0x70
[ 593.940282] [<00000000842e3c1c>] io_sqe_buffer_register+0x22c/0x610
[ 593.940346] [<00000000842e41fa>] __io_uring_register+0x1fa/0x370
[ 593.940349] [<00000000842e8dc0>] __s390x_sys_io_uring_register+0xb0/0xd0
[ 593.940352] [<00000000848a2b78>] system_call+0xdc/0x2c8
Summary:
Oopsed: 1, pinmem
Tests took 125 seconds to run
== Analysis ==
Test setup (ubuntu_stress_single_smoke_test.sh, checkbox-kernel-tests):
- stress-ng runs in a memory cgroup limited to min(90% of free memory, free
memory - 512 MiB) (2122 MB here) and "stress-ng --pinmem 4 --pinmem-ops 3000 -t
5 --oomable" is started. pinmem pins all physical memory by default, which is
more than the cgroup allows, so workers get OOM killed. On this stress-ng build
pinning is done with io_uring IORING_REGISTER_BUFFERS (FOLL_LONGTERM
get_user_pages).
Facts from the log:
- The task that oopsed (PID 208895) is the task the memcg OOM killer had picked
about 64 ms earlier. It was still inside io_uring_register ->
io_sqe_buffer_register -> get_user_pages -> __gup_longterm_locked.
- In the register dump, r7 = 0xfffffffffffffe00 (= -512, i.e. -ERESTARTSYS) and
the faulting instruction is "lg %r11,0(%r1,%r10)" with r1 = r8*8 and r10 = base
of an array, after an unsigned compare of r8 against r7 (clgrj). Address check:
r10 + r1 = 0x3e0030f3000 + 0x149000 = 0x3e00323c000 = the failing address. This
is my reading of the disassembly; I did not use debug symbols.
Source reading (Ubuntu-5.4.0-248.268, mm/gup.c; I did not reproduce on a
running kernel):
- check_and_migrate_cma_pages() takes "unsigned long nr_pages" and, when
cma_page_list is not empty, does "nr_pages = __get_user_pages_locked(...); if
((nr_pages > 0) && migrate_allow) goto check_again;".
- __get_user_pages_locked() returns a signed long that can be a negative errno.
For a task with a fatal signal pending (the OOM victim) this is -ERESTARTSYS
(-512) in 5.4. Stored in the unsigned variable it becomes 0xfffffffffffffe00,
"> 0" is true, and the "for (i = 0; i < nr_pages;)" loop at check_again walks
far beyond the end of pages[], which matches the Oops.
- Upstream fixed exactly this in commit
b96cc65515bb16f90a361c01da088ce09ad3cf92 ("mm/gup.c: allow CMA migration to
propagate errors back to caller", zhong jiang, 2019-12), whose message says
"check_and_migrate_cma_pages() was recording the result of
__get_user_pages_locked() in an unsigned nr_pages variable ... this had the
effect of hiding errors". v5.5 mm/gup.c has "long ret = nr_pages;" and "(ret >
0) && migrate_allow"; v5.4 and the current linux-5.4.y stable tip (checked at
9e3157c56ec7) still have the old code.
** Affects: ubuntu-kernel-tests
Importance: Undecided
Status: New
** Affects: linux (Ubuntu)
Importance: Undecided
Status: New
** Tags: 5.4 focal generic metal s390x sru-20261123 ubuntu-stress-smoke-test
--
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/2178215
Title:
pinmem in ubuntu_stress_smoke_test failed on focal (5.4.0-248.268)
generic s390x (kernel Oops in __gup_longterm_locked)
To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu-kernel-tests/+bug/2178215/+subscriptions
--
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs