Skip to content

mm/damon/tests: fix memory bugs in kunit tests

SeongJae Park damon linux-kselftest linux-mm lkml stable 1 version Applied

Status from this message: [merged mm-stable] mm-damon-tests-core-kunit-remove-unused-ctx-in-damon_test_split_regions_of.patch removed from -mm tree

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest22 patches 0 repliesApplied 22/22

Patches in v1 All 22 applied

#Subject and filesSizeRepliesApplied
1/22mm/damon/tests/core-kunit: fix memory leak in damon_test_set_filters_default_reject()mm/damon/tests/core-kunit.h+3 -00 repliesApplied
2/22mm/damon/tests/core-kunit: handle allocation failures in damon_test_regions()mm/damon/tests/core-kunit.h+6 -00 repliesApplied
3/22mm/damon/tests/core-kunit: handle memory failure from damon_test_target()mm/damon/tests/core-kunit.h+7 -00 repliesApplied
4/22mm/damon/tests/core-kunit: handle memory alloc failure from damon_test_aggregate()mm/damon/tests/core-kunit.h+11 -00 repliesApplied
5/22mm/damon/tests/core-kunit: handle alloc failures on damon_test_split_at()mm/damon/tests/core-kunit.h+11 -00 repliesApplied
6/22mm/damon/tests/core-kunit: handle alloc failures on damon_test_merge_two()mm/damon/tests/core-kunit.h+10 -00 repliesApplied
7/22mm/damon/tests/core-kunit: handle alloc failures on dasmon_test_merge_regions_of()mm/damon/tests/core-kunit.h+6 -00 repliesApplied
8/22mm/damon/tests/core-kunit: handle alloc failures on damon_test_split_regions_of()mm/damon/tests/core-kunit.h+20 -00 repliesApplied
9/22mm/damon/tests/core-kunit: handle alloc failures in damon_test_ops_registration()mm/damon/tests/core-kunit.h+3 -00 repliesApplied
10/22mm/damon/tests/core-kunit: handle alloc failures in damon_test_set_regions()mm/damon/tests/core-kunit.h+15 -20 repliesApplied
11/22mm/damon/tests/core-kunit: handle alloc failures in damon_test_update_monitoring_result()mm/damon/tests/core-kunit.h+3 -00 repliesApplied
12/22mm/damon/tests/core-kunit: handle alloc failure on damon_test_set_attrs()mm/damon/tests/core-kunit.h+3 -00 repliesApplied
13/22mm/damon/tests/core-kunit: handle alloc failres in damon_test_new_filter()mm/damon/tests/core-kunit.h+2 -00 repliesApplied
14/22mm/damon/tests/core-kunit: handle alloc failure on damos_test_commit_filter()mm/damon/tests/core-kunit.h+10 -50 repliesApplied
15/22mm/damon/tests/core-kunit: handle alloc failures on damos_test_filter_out()mm/damon/tests/core-kunit.h+11 -00 repliesApplied
16/22mm/damon/tests/core-kunit: handle alloc failures on damon_test_set_filters_default_reject()mm/damon/tests/core-kunit.h+6 -00 repliesApplied
17/22mm/damon/tests/vaddr-kunit: handle alloc failures on damon_do_test_apply_three_regions()mm/damon/tests/vaddr-kunit.h+6 -00 repliesApplied
18/22mm/damon/tests/vaddr-kunit: handle alloc failures in damon_test_split_evenly_fail()mm/damon/tests/vaddr-kunit.h+10 -10 repliesApplied
19/22mm/damon/tests/vaddr-kunit: handle alloc failures on damon_test_split_evenly_succ()mm/damon/tests/vaddr-kunit.h+8 -10 repliesApplied
20/22mm/damon/tests/sysfs-kunit: handle alloc failures on damon_sysfs_test_add_targets()mm/damon/tests/sysfs-kunit.h+25 -00 repliesApplied
21/22mm/damon/tests/core-kunit: remove unnecessary damon_ctx variable on damon_test_split_at()mm/damon/tests/core-kunit.h+1 -80 repliesApplied
22/22mm/damon/tests/core-kunit: remove unused ctx in damon_test_split_regions_of()mm/damon/tests/core-kunit.h+2 -120 repliesApplied

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 00/22] mm/damon/tests: fix memory bugs in kunit tests

DAMON kunit tests were initially written assuming those will be run on environments that are well controlled and therefore tolerant to transient test failures and bugs in the test code itself. The user-mode linux based manual run of the tests is one example of such an environment. And the test code was written for adding more test coverage as fast as possible, over making those safe and reliable.

As a result, the tests resulted in having a number of bugs including real memory leaks, theoretical unhandled memory allocation failures, and unused memory allocations. The allocation failures that are not handled well are unlikely in the real world, since those allocations are too small to fail. But in theory, it can happen and cause inappropriate memory access.

It is arguable if bugs in test code can really harm users. But, anyway bugs are bugs that need to be fixed. Fix the bugs one by one. Also Cc stable@ for the fixes of memory leak and unhandled memory allocation failures. The unused memory allocations are only a matter of memory efficiency, so not Cc-ing stable@.

The first patch fixes memory leaks in the test code for the DAMON core layer.

Following fifteen, three, and one patches respectively fix unhandled memory allocation failures in the test code for DAMON core layer, virtual address space DAMON operation set, and DAMON sysfs interface, one by one per test function.

Final two patches remove memory allocations that are correctly deallocated at the end, but not really being used by any code.

SeongJae Park (22):
mm/damon/tests/core-kunit: fix memory leak in
damon_test_set_filters_default_reject()
mm/damon/tests/core-kunit: handle allocation failures in
damon_test_regions()
mm/damon/tests/core-kunit: handle memory failure from
damon_test_target()
mm/damon/tests/core-kunit: handle memory alloc failure from
damon_test_aggregate()
mm/damon/tests/core-kunit: handle alloc failures on
damon_test_split_at()
mm/damon/tests/core-kunit: handle alloc failures on
damon_test_merge_two()
mm/damon/tests/core-kunit: handle alloc failures on
dasmon_test_merge_regions_of()
mm/damon/tests/core-kunit: handle alloc failures on
damon_test_split_regions_of()
mm/damon/tests/core-kunit: handle alloc failures in
damon_test_ops_registration()
mm/damon/tests/core-kunit: handle alloc failures in
damon_test_set_regions()
mm/damon/tests/core-kunit: handle alloc failures in
damon_test_update_monitoring_result()
mm/damon/tests/core-kunit: handle alloc failure on
damon_test_set_attrs()
mm/damon/tests/core-kunit: handle alloc failres in
damon_test_new_filter()
mm/damon/tests/core-kunit: handle alloc failure on
damos_test_commit_filter()
mm/damon/tests/core-kunit: handle alloc failures on
damos_test_filter_out()
mm/damon/tests/core-kunit: handle alloc failures on
damon_test_set_filters_default_reject()
mm/damon/tests/vaddr-kunit: handle alloc failures on
damon_do_test_apply_three_regions()
mm/damon/tests/vaddr-kunit: handle alloc failures in
damon_test_split_evenly_fail()
mm/damon/tests/vaddr-kunit: handle alloc failures on
damon_test_split_evenly_succ()
mm/damon/tests/sysfs-kunit: handle alloc failures on
damon_sysfs_test_add_targets()
mm/damon/tests/core-kunit: remove unnecessary damon_ctx variable on
damon_test_split_at()
mm/damon/tests/core-kunit: remove unused ctx in
damon_test_split_regions_of()

 mm/damon/tests/core-kunit.h  | 125 ++++++++++++++++++++++++++++++++---
 mm/damon/tests/sysfs-kunit.h |  25 +++++++
 mm/damon/tests/vaddr-kunit.h |  26 +++++++-
 3 files changed, 163 insertions(+), 13 deletions(-)

base-commit: 75f0c76bb8c01fdea838a601dc3326b11177c0d8

Signature · 1 line
2.47.3