kunit_attach_mm() leaks an mm_struct (verified with dumb printf
debugging). Fix that. In the process, add a new kthread mm operation,
and clean up some nearby cleanup code in the KUnit lib.
---
Here's how I understand mm refcounts:
funcs | counter | manages lifecycle of...
--------------------------------------------------------
mmgrab()/mmdrop() | mm_count | mm_struct and PGD
--------------------------------------------------------
mmget()/mmput() | mm_users | userspace address space
All mm_users references share a single reference to the mm_struct.
---
Brendan Jackman (3):
kunit: test: Delete pointless resource API usage
kthread: Add kthread_take_mm()
kunit: test: fix mm_struct leak in kunit_attach_mm()
include/linux/kthread.h | 1 +
kernel/fork.c | 3 +-
kernel/kthread.c | 36 +++++++++++++++++------
lib/kunit/user_alloc.c | 78 +++++--------------------------------------------
4 files changed, 37 insertions(+), 81 deletions(-)
---
base-commit: 9448598b22c50c8a5bb77a9103e2d49f134c9578
change-id: 20251223-b4-kunit-user-alloc-6ae8df0b8a92
Best regards,
--
Brendan Jackman <[email protected]>