Skip to content

mm/damon: refactor damon_{start,stop,commit}() for simple error handling

SJ Park damon linux-mm lkml 1 version Applied

Status from this message: [merged mm-stable] samples-damon-prcl-do-not-stop-damon-for-damon_call-failure.patch removed from -mm tree

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest11 patches 1 replyApplied 11/11

Changes from RFC v1 from the cover letter

- RFC v1: https://lore.kernel.org/[email protected]
- Fix ABBA deadlock in damon_start().
- Wait instead of doing racy-stop in damon_call().

Patches in v1 All 11 applied

#Subject and filesSizeRepliesApplied
1/11mm/damon/core: stop ctxs in damon_start() before returning an errormm/damon/core.c+3 -00 repliesApplied
2/11samples/damon/mtier: do not stop first context for damon_start() failuresamples/damon/mtier.c+0 -20 repliesApplied
3/11mm/damon/core: make damon_stop() never failsmm/damon/core.c+6 -150 repliesApplied
4/11mm/damon/sysfs: ignore damon_stop() return valuemm/damon/sysfs.c+2 -10 repliesApplied
5/11mm/damon/reclaaim: ignore damon_stop() return valuemm/damon/reclaim.c+4 -20 repliesApplied
6/11mm/damon/lru_sort: ignore damon_stop() return valuemm/damon/lru_sort.c+4 -20 repliesApplied
7/11mm/damon/core: change damon_stop() return type to voidinclude/linux/damon.h mm/damon/core.c+2 -30 repliesApplied
8/11samples/damon/mtier: stop all contexts with single damon_stop() callsamples/damon/mtier.c+1 -21 replyApplied
9/11mm/damon/core: wait ctx stop in damon_call() before reruning an errormm/damon/core.c+10 -20 repliesApplied
10/11samples/damon/wsse: do not stop ctx for damon_call() failuresamples/damon/wsse.c+1 -30 repliesApplied
11/11samples/damon/prcl: do not stop DAMON for damon_call() failuresamples/damon/prcl.c+1 -30 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/11] mm/damon: refactor damon_{start,stop,commit}() for simple error handling

damon_start() and damon_stop() could leave a few of requested DAMON contexts running when they return an error. damon_commit() failure stops the DAMON context, but in an asynchronous way. Callers should stop the left-over DAMON contexts. It is easy to make mistakes, and indeed a few bugs from such mistakes were found and fixed.

Refactor the core API functions to guarantee contexts are completely stopped under failures. Remove the caller side error handlers that are no longer needed due to the refactoring.

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

Patch 1 refactors damon_start() to ensure all contexts are stopped for failures. Patch 2 updates unnecessary damon_start() error handling from mtier sample module.

Patch 3 refactors damon_stop() to always success. Patches 4-6 updates callers (damon_{sysfs,reclaim lru_sort}) to ignore the return value. Patch 7 update damon_stop() return value to void. Patch 8 simplifies damon_stop() error handling in mtier sample module.

Patch 9 refactors damon_call() to return errors only after the context is completely stopped. Patches 10 and 11 remove unnecessary error handlings from callers (wsse and prcl sample modules).

Changelog
=========

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 ABBA deadlock in damon_start().
- Wait instead of doing racy-stop in damon_call().

SJ Park (11):
mm/damon/core: stop ctxs in damon_start() before returning an error samples/damon/mtier: do not stop first context for damon_start()
failure
mm/damon/core: make damon_stop() never fails mm/damon/sysfs: ignore damon_stop() return value mm/damon/reclaaim: ignore damon_stop() return value mm/damon/lru_sort: ignore damon_stop() return value mm/damon/core: change damon_stop() return type to void samples/damon/mtier: stop all contexts with single damon_stop() call mm/damon/core: wait ctx stop in damon_call() before reruning an error samples/damon/wsse: do not stop ctx for damon_call() failure samples/damon/prcl: do not stop DAMON for damon_call() failure

 include/linux/damon.h |  2 +-
 mm/damon/core.c       | 37 +++++++++++++++++++------------------
 mm/damon/lru_sort.c   |  6 ++++--
 mm/damon/reclaim.c    |  6 ++++--
 mm/damon/sysfs.c      |  3 ++-
 samples/damon/mtier.c |  5 +----
 samples/damon/prcl.c  |  4 +---
 samples/damon/wsse.c  |  4 +---
 8 files changed, 33 insertions(+), 34 deletions(-)

base-commit: 3fc9ce1db037091d433cb95dff0ce1cb6815fffe

Signature · 1 line
2.47.3