From mboxrd@z Thu Jan 1 00:00:00 1970 From: Konstantin Khorenko Date: Fri, 21 Aug 2026 18:36:46 +0200 Subject: [Devel] [PATCH vz10 00/32] Fix the VZ kernel build so that KUnit can run Message-ID: <20260821163718.187766-1-khorenko@virtuozzo.com> List-Id: This supersedes the 14-patch series [PATCH vz10 01/14] sched: fix VZ build errors with CONFIG_CGROUP_SCHED=n by Eva Kurchatova (VSTOR-134732). The goal is the same - make the in-tree KUnit tests runnable - and most of the code is hers, but the series is split per feature, several patches are reworked, two are dropped and nine are new, so it is easier to review as a fresh series than as a v2. The goal is reached end to end now: $ ./tools/testing/kunit/kunit.py run Testing complete. Ran 408 tests: passed: 397, skipped: 11 Of the 32 patches, 21 come from the old series (18 with Eva as author, 3 reworked to the point where I took authorship and left her a Reported-by), 9 are new, and 3 are upstream cherry-picks. What changed compared to the old series ======================================= 1. struct ve_struct stays defined for CONFIG_VE=n. The old series moved it, and all the heavy includes, under #ifdef CONFIG_VE. That made the type incomplete for CONFIG_VE=n and broke roughly 80 places - the per-Container connector alone accounts for 79 - of which the series fixed about 15. Measured on this tree: a CONFIG_VE=n build had 5 errors before the series and about 95 after it. Nor is it needed for UML: there CONFIG_VE=y, so those includes are compiled anyway. The only real UML problem in that header was asm/vdso.h, which is now a 14-line guard (patch 19). 2. No silent behaviour changes in the CONFIG_VE=n stubs. The old one turned current_user_ns_initial() and is_ve_init_net() into "return true". The first one is used by sget_fc() to decide whether to set SB_I_NODEV, so on a CONFIG_VE=n kernel that drops SB_I_NODEV for mounts from a non-initial user namespace; the second one changes nf_log_syslog behaviour for non-init netns. Both are dropped. 3. Every patch carries a real Fixes: and the Feature: of the code it fixes, instead of "Feature: fix KUnit tests" on all 14. Only the five patches that fix nothing pre-existing - pure enablement - have no Fixes: line. 4. One patch per feature and per config option. The old "fix VZ build errors with CONFIG_MEMCG=n" alone touched four different config options (MEMCG, MEMCG_V1, NUMA, VE) and five different VZ features; it is now seven patches. 5. Bugs in the old patches themselves, fixed here: - meminfo_proc_show_mi() was left unguarded while its only caller was guarded, so CONFIG_VE=n did not build (-Werror=unused-function); - the fdput label in syncfs() and the local variables in kernfs_ioctl() were left behind by their guards, same class of breakage; - the guard in proc_oom_score() was placed so that #ifdef/#else split a scoped_guard(rcu) block in half, leaving an empty rcu section; - two of the three guards in oom_kill.c were unnecessary and only forced each other: oom_kill_memcg_member() touches no memcg field at all, and every function in the "if (oom_group)" block has a !MEMCG stub; - mem_cgroup_per_node::nid was derived from lruvec_pgdat(&pn->lruvec), which relies on pgdat being filled in lazily by mem_cgroup_lruvec(), and did so on the hottest memcg accounting path. The field is now simply declared in the CONFIG_MEMCG_V1=n branch as well, so no .c file changes at all. 6. Two patches dropped as unnecessary: - "mm: page_alloc: guard update_maxlat() with CONFIG_VE": page_alloc.o builds fine without it, verified; the types it claimed were undefined are defined unconditionally in kstat.h; - "ve: vzstat: guard wait_start access with CONFIG_SCHEDSTATS": dead code once CONFIG_VE selects SCHEDSTATS, and vzstat.c is only built with CONFIG_VE_CALLS, which depends on VE. 7. Nine places the old series left broken are fixed here: mm/shmem.c (the CONFIG_MEMCG=n patch missed it, so that config still did not build), fs/fs_context.c, net/unix/af_unix.c, include/linux/rh_flags.h, include/linux/rh_waived.h, fs/ext4/Kconfig, drivers/pcmcia/cistpl.c, kernel/sched/cpuacct.c and tools/testing/kunit/. The last one matters most: with the RHEL10 -sP shebang, kunit.py cannot import the modules next to it and does not start at all, so the old series could not have been tested end to end. 8. Upstream commits instead of local workarounds: - the !SMP build is fixed by cherry-picking the missing prerequisite, PERCPU_PTR() (patches 15 and 16), so include/linux/sched.h carries no local delta and this_rq_raw() stays identical to upstream. UML is always UP, so this is on the KUnit path, not just an x86 curiosity; - the pcmcia constification is the upstream commit (patch 29) rather than a hand-written const. 9. One patch fixes a runtime bug in the shipped kernel: ve0.css without CSS_NO_REF (patch 22). net_ns_init() takes a reference on ve0 before cgroup_init() has set up the percpu_ref, so css_get() increments *(unsigned long __percpu *)NULL - whatever lives at the start of the percpu area - on every boot. The old series had the same one-line fix but described it as a UML build issue. Verification ============ production config (redhat/configs/build_configs.sh kernel rhel), full vmlinux, at every one of the 33 checkpoints (base commit plus all 32 patches) 33 OK, 0 FAIL x86_64 defconfig, full build OK (5 compile errors and 2 undefined references before) x86_64 defconfig with SMP=n, full build OK (never built before) ARCH=um defconfig, full build OK kunit.py run 408 tests, 397 passed, 11 skipped, 0 failed VE=n; MEMCG=n; MEMCG_V1=n; NUMA=n; CGROUP_SCHED=n + CGROUP_CPUACCT=n 0 errors Notes ===== - "select POSIX_MQUEUE" in patch 7 is the one select I cannot justify by build failure: it is about the environment a Container expects, not about compiling. Say the word and it goes. - CONFIG_CGROUPS=n still does not build, and patch 24 says so explicitly: struct ve_struct embeds a struct cgroup_subsys_state, so ve.h needs the cgroup core in any case. - CONFIG_VE=n compiles but is not functional - get_exec_env() returns NULL there, so such a kernel would crash on the first aio or coredump path. Making it work is separate work: 15 patches for the global aio counters, core_pattern, sync, printk and the per-Container connector, none of which is needed for KUnit. Eva Kurchatova (18): sched/loadavg: fix build with CONFIG_CGROUP_SCHED=n sched/core: guard cpu_cgrp_subsys.depends_on with CONFIG_CGROUP_CPUACCT ve: source Kconfig.openvz from arch/um/Kconfig ve: select CGROUP_PERF only if PERF_EVENTS ve: add missing Kconfig selects for CONFIG_VE mm/oom: build the berserker mode only with CONFIG_MEMCG proc: build the per-Container oom_score limit lookup only with CONFIG_MEMCG mm, proc: build the /proc/meminfo virtualization only with CONFIG_VE mm/vmstat: build the /proc/vmstat virtualization only with CONFIG_VE mm/memcontrol: build memory.numa_migrate only with CONFIG_NUMA mm/memcontrol: add missing inline to the mem_cgroup_fill_meminfo() stub block: guard the cbt_list initialization with CONFIG_BLK_DEV_CBT ve: compile the per-Container VDSO copies only on x86 ve: compile the CPUID override propagation only on x86 ve: mark ve0.css with CSS_NO_REF mm/memory: build the page fault latency accounting for x86 only sched/core: include cgroup-internal.h only where it is used kernfs: build the KERNFS_GET_NS ioctl only with CONFIG_NET Konstantin Khorenko (11): sched: move MAX_CPU_RATE out of CONFIG_CFS_CPULIMIT sched/cpuacct: guard ve_root_tg() with CONFIG_CFS_CPULIMIT mm/shmem: build the tmpfs size virtualization only with CONFIG_VE mm/memcg: keep mem_cgroup_per_node::nid available with CONFIG_MEMCG_V1=n ve: include asm/vdso.h on x86 only fs/fs_context: build the mount option formatting only with CONFIG_VE net/unix: fix unix_stream_recvmsg() build with CONFIG_BPF_SYSCALL=n redhat: rh_flags: make the !CONFIG_RHEL_DIFFERENCES stubs inline redhat: rh_waived: add a stub for CONFIG_RHEL_DIFFERENCES=n ext4: select LIBCRC32C kunit: add the script dir to sys.path for PYTHONSAFEPATH compatibility Thomas Wei?schuh (1): ms/pcmcia: cistpl: Constify 'struct bin_attribute' Uros Bizjak (2): ms/percpu: introduce PERCPU_PTR() macro ms/percpu: cast percpu pointer in PERCPU_PTR() via unsigned long arch/um/Kconfig | 2 ++ block/blk-core.c | 2 ++ drivers/pcmcia/cistpl.c | 8 ++++---- fs/ext4/Kconfig | 1 + fs/fs_context.c | 2 ++ fs/kernfs/file.c | 8 ++++---- fs/proc/base.c | 2 ++ fs/proc/meminfo.c | 4 ++++ include/linux/memcontrol.h | 8 +++++++- include/linux/percpu-defs.h | 15 ++++++++++----- include/linux/rh_flags.h | 4 ++-- include/linux/rh_waived.h | 7 +++++++ include/linux/sched/loadavg.h | 11 ++++++++++- include/linux/ve.h | 14 ++++++++++++-- kernel/Kconfig.openvz | 9 ++++++++- kernel/sched/core.c | 4 ++++ kernel/sched/cpuacct.c | 2 ++ kernel/sched/loadavg.c | 6 ++++-- kernel/sched/sched.h | 9 ++++++++- kernel/ve/ve.c | 13 +++++++++++++ mm/memcontrol.c | 2 +- mm/memory.c | 7 +++++++ mm/oom_kill.c | 4 ++++ mm/shmem.c | 23 +++++++++++++---------- mm/show_mem.c | 2 ++ mm/vmstat.c | 19 +++++++++++++------ net/unix/af_unix.c | 2 +- tools/testing/kunit/kunit.py | 1 + tools/testing/kunit/kunit_tool_test.py | 2 ++ 29 files changed, 152 insertions(+), 41 deletions(-) -- 2.47.1