From mboxrd@z Thu Jan 1 00:00:00 1970 From: Vasileios Almpanis Date: Tue, 18 Aug 2026 15:10:18 +0000 Subject: [Devel] [PATCH VZ10 v2 0/4] connector: do not lose exit events for in-CT listeners Message-ID: <20260818-connectors-v2-0-88c5d9049e6f@virtuozzo.com> List-Id: The proc connector reports the exit event after exit_notify(), so the parent may already have reaped the exiting task. release_task() -> exit_ve_namespace() then resets tsk->task_ve to ve0, and if that wins the race the event is delivered to the host listeners only. A listener inside the container never sees the exit event. LTP catches this as the flaky cn_pec exit-test failure causing the test to hang for as long as 8 hours on GCOV kernels. Patch 4 fixes this by pinning the task's VE for the exit notification before exit_notify(). This means the delivery path can now run against a VE whose last task is already reaped, i.e. concurrently with the per-VE connector teardown, which was impossible before. Patches 1-3 prepare for that: annotate ve->cn with __rcu, free the per-VE connector state only after an RCU grace period, and deliver per-VE events under rcu_read_lock(). Testing: KASAN, PROVE_LOCKING/PROVE_RCU, DEBUG_OBJECTS, kmemleak=on; HCI VM with one container): - LTP cn_pec inside a CT: unpatched kernel loses exit events in 3 of 10 runs (-n 50); patched kernel passes 30 of 30 runs. - Teardown stress: 15 cycles of an active in-CT pec_listener plus a 200-process exit storm with vzctl stop/start while events are in flight: no KASAN/lockdep/RCU splats, kmemleak scans report 0 unreferenced objects. https://virtuozzo.atlassian.net/browse/VSTOR-140421 --- Changes in v2: - Turned the single patch into a series: with the exit event now delivered for a possibly already-reaped task, the per-VE delivery path can race with the connector teardown in cn_fini_ve(). New patches 1-3 make that safe: annotate ve->cn with __rcu, free the per-VE connector state only after an RCU grace period, and run the delivery under rcu_read_lock(). - cn_proc.h: forward-declare struct ve_struct instead of including linux/ve.h. - Link to v1: https://lists.openvz.org/pipermail/devel/2026-August/084581.html --- Vasileios Almpanis (4): connector: annotate ve->cn with __rcu connector: free the per-VE connector state after an RCU grace period connector: deliver per-VE proc events under an RCU read lock proc connector: pin task VE for the exit event notification drivers/connector/cn_proc.c | 105 ++++++++++++++++++++++++++++++++++-------- drivers/connector/connector.c | 47 +++++++++++++------ include/linux/cn_proc.h | 8 +++- include/linux/ve.h | 2 +- kernel/exit.c | 5 +- 5 files changed, 131 insertions(+), 36 deletions(-) --- base-commit: 209f11f2c454a88761fb8f0a820fa22b6feae720 change-id: 20260813-connectors-3571be4ae57b -- Best regards, Vasileios Almpanis Software Developer, Virtuozzo.