Skip to content

mm/damon: validate all parameters in the core

SJ Park damon linux-mm lkml 1 version Applied

Status from this message: [merged mm-stable] mm-damon-sysfs-remove-region-size-validation.patch removed from -mm tree

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest8 patches 6 repliesApplied 8/8

Changes from RFC v1 from the cover letter

- RFC v1: https://lore.kernel.org/[email protected]
- Fix wrong dst testing of damon_commit_ctx().
- Use fresh test_ctx for each ctx in damon_start().

Patches in v1 All 8 applied

#Subject and filesSizeRepliesApplied
1/8mm/damon/core: safely validate src on damon_commit_ctx()mm/damon/core.c+47 -140 repliesApplied
2/8mm/damon/core: do parameter testing commit on damon_start()mm/damon/core.c+12 -20 repliesApplied
3/8mm/damon/sysfs: remove duplicated commit input validity checkmm/damon/sysfs.c+1 -310 repliesApplied
4/8mm/damon/reclaim: remove duplicated min_region_sz power of 2 checkmm/damon/reclaim.c+0 -51 replyApplied
5/8mm/damon/lru_sort: remove duplicated min_region_sz power_of_2() checkmm/damon/lru_sort.c+0 -50 repliesApplied
6/8mm/damon: document region size validation in damon_set_regions()include/linux/damon.h+2 -10 repliesApplied
7/8mm/damon/core: remove start, end check in damon_set_region_system_rams()mm/damon/core.c+0 -31 replyApplied
8/8mm/damon/sysfs: remove region size validationmm/damon/sysfs.c+0 -31 replyApplied

Reviews trailers per patch

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

Read the v1 thread

Cover letter [PATCH 0/8] mm/damon: validate all parameters in the core

DAMON has a number of parameters. Some of the parameters are validated by DAMON, while some are validated by DAMON API callers. Each caller has their own set of parameters that are exposed to users. Hence each caller has their own ways to do the validation. There is no clear lines for the responsibilities. It is confusing and easy to make mistakes at validations. Actually we found a few bugs in the class.

Define DAMON core as the place to do all the validations and implement those. damon_set_regions(), damon_start() and damon_commit_ctx() are the three main DAMON core API functions for setup of DAMON parameters. Make the three functions to do safe and holistic parameter checks. The first one is already providing the validation, so changes are only for the last two functions.

This might add unnecessary validations for some use cases. The overhead should be negligible as parameters update is expected to only rarely happen. It reduces the number of places to check and fix for bugs of the class from all callers to the single component. The maintenance efficiency gain is obvious.

Further cleanup documents and caller code. Make the lines of validation duties clearer. Remove validations that are no more needed owing to the core validations.

Patches Sequence
================

Patch 1 implements the core holistic parameters validation for damon_commit_ctx(). Patch 2 extends the validation to damon_start(). Patch 3 removes the duplicated holistic parameters validation in DAMON sysfs interface, which is now embedded into the core layer. Patches 4 and 5 remove duplicated min_region_sz validation in DAMON modules. Patches 6 updates kernel doc to clarify damon_set_regions() is doing the range validation. Patches 7 and 8 remove monitoring target range validations that doesn't necessary thanks to the validation in damon_set_regions().

Note that the patch for providing the validation from damon_set_regions() is separately posted as a hotfix [1] but not yet picked into mm.git as of this writing.

[1] https://lore.kernel.org/[email protected]

Changes from RFC v1.1
- RFC v1.1: https://lore.kernel.org/[email protected]
- Drop RFC tag.
- Rebase to latest mm-new.
Changes from RFC v1
- RFC v1: https://lore.kernel.org/[email protected]
- Fix wrong dst testing of damon_commit_ctx().
- Use fresh test_ctx for each ctx in damon_start().

SJ Park (8):
mm/damon/core: safely validate src on damon_commit_ctx() mm/damon/core: do parameter testing commit on damon_start() mm/damon/sysfs: remove duplicated commit input validity check mm/damon/reclaim: remove duplicated min_region_sz power of 2 check mm/damon/lru_sort: remove duplicated min_region_sz power_of_2() check mm/damon: document region size validation in damon_set_regions() mm/damon/core: remove start, end check in
damon_set_region_system_rams()
mm/damon/sysfs: remove region size validation

 include/linux/damon.h |  3 +-
 mm/damon/core.c       | 78 ++++++++++++++++++++++++++++++++-----------
 mm/damon/lru_sort.c   |  5 ---
 mm/damon/reclaim.c    |  5 ---
 mm/damon/sysfs.c      | 35 +------------------
 5 files changed, 62 insertions(+), 64 deletions(-)

base-commit: 372482a3e74023a5c23b427ef5c6e7a057b46e6d

Signature · 1 line
2.47.3