mm/damon/reclaim,lru_sort: enable/disable synchronously
Subsystems (3)
SeongJae Park
maintainercover mm/damon/reclaim,lru_sort: enable/disable synchronously
Writing a value to DAMON_RECLAIM and DAMON_LRU_SORT's 'enabled' parameters turns on or off DAMON in an ansychronous way. This means the parameter cannot be used to read the current status of them. 'kdamond_pid' parameter should be used instead for the purpose. The documentation is easy to be read as it works in a synchronous way, so it is a little bit confusing. It also makes the user space tooling dirty.
There's no real reason to have the asynchronous behavior, though. Simply make the parameter works synchronously, rather than updating the document.
The first and second patches changes the behavior of the 'enabled' parameter for DAMON_RECLAIM and adds a selftest for the changed behavior, respectively. Following two patches make the same changes for DAMON_LRU_SORT.
SeongJae Park (4):
mm/damon/reclaim: enable and disable synchronously selftests/damon: add tests for DAMON_RECLAIM's enabled parameter mm/damon/lru_sort: enable and disable synchronously selftests/damon: add tests for DAMON_LRU_SORT's enabled parameter
mm/damon/lru_sort.c | 51 ++++++++++------------ mm/damon/reclaim.c | 53 ++++++++++------------- tools/testing/selftests/damon/Makefile | 1 + tools/testing/selftests/damon/lru_sort.sh | 41 ++++++++++++++++++ tools/testing/selftests/damon/reclaim.sh | 42 ++++++++++++++++++ 5 files changed, 129 insertions(+), 59 deletions(-) create mode 100755 tools/testing/selftests/damon/lru_sort.sh create mode 100755 tools/testing/selftests/damon/reclaim.sh
Signature · 1 line
2.25.1
SeongJae Park
maintainerPATCH 1/4 mm/damon/reclaim: enable and disable synchronously
Writing a value to DAMON_RECLAIM's 'enabled' parameter turns on or off DAMON in an ansychronous way. This means the parameter cannot be used to read the current status of DAMON_RECLAIM. 'kdamond_pid' parameter should be used instead for the purpose. The documentation is easy to be read as it works in a synchronous way, so it is a little bit confusing. It also makes the user space tooling dirty.
There's no real reason to have the asynchronous behavior, though. Simply make the parameter works synchronously, rather than updating the document.
--- mm/damon/reclaim.c | 53 ++++++++++++++++++++-------------------------- 1 file changed, 23 insertions(+), 30 deletions(-)
mm/damon/reclaim.c +23 -30
@@ -9,7 +9,6 @@#include <linux/damon.h> #include <linux/module.h> -#include <linux/workqueue.h> #include "modules-common.h"
@@ -181,38 +180,31 @@ static int damon_reclaim_turn(bool on)return 0 ; } -static struct delayed_work damon_reclaim_timer; -static void damon_reclaim_timer_fn (struct work_struct *work) -{ -static bool last_enabled; -bool now_enabled; - - now_enabled = enabled; -if (last_enabled != now_enabled) { -if (!damon_reclaim_turn (now_enabled)) - last_enabled = now_enabled; -else - enabled = last_enabled; - } -} -static DECLARE_DELAYED_WORK(damon_reclaim_timer, damon_reclaim_timer_fn); - -static bool damon_reclaim_initialized; -static int damon_reclaim_enabled_store (const char *val,const struct kernel_param *kp) { -int rc =param_set_bool (val, kp); +bool is_enabled = enabled; +bool enable; +int err; -if (rc <0 ) -return rc; + err =strtobool (val, &enable); +if (err) +return err; -/* system_wq might not initialized yet */ -if (!damon_reclaim_initialized) -return rc; +if (is_enabled == enable) +return 0 ; -schedule_delayed_work (&damon_reclaim_timer,0 ); -return 0 ; +/* Called before init function. The function will handle this. */ +if (!ctx) + goto set_param_out; + + err =damon_reclaim_turn (enable); +if (err) +return err; + +set_param_out: + enabled = enable; +return err; }static const struct kernel_param_ops enabled_param_ops = {
@@ -262,10 +254,11 @@ static int __init damon_reclaim_init(void) ctx->callback.after_wmarks_check = damon_reclaim_after_wmarks_check; ctx->callback.after_aggregation = damon_reclaim_after_aggregation; -schedule_delayed_work (&damon_reclaim_timer,0 ); +/* 'enabled' has set before this function, probably via command line */ +if (enabled) + err =damon_reclaim_turn (true); - damon_reclaim_initialized = true; -return 0 ; +return err; }module_init (damon_reclaim_init);
Signature · 1 line
2.25.1
SeongJae Park
maintainerPATCH 2/4 selftests/damon: add tests for DAMON_RECLAIM's enabled parameter
In reply to SeongJae ParkAdds simple test cases for DAMON_RECLAIM's 'enabled' parameter. Those tests are focusing on the synchronous behavior of DAMON_RECLAIM enabling and disabling.
--- tools/testing/selftests/damon/Makefile | 1 + tools/testing/selftests/damon/reclaim.sh | 42 ++++++++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100755 tools/testing/selftests/damon/reclaim.sh
tools/testing/selftests/damon/Makefile +1 -0
@@ -8,5 +8,6 @@ TEST_PROGS = debugfs_attrs.sh debugfs_schemes.sh debugfs_target_ids.sh TEST_PROGS += debugfs_empty_targets.sh debugfs_huge_count_read_write.sh TEST_PROGS += debugfs_duplicate_context_creation.sh TEST_PROGS += sysfs.sh +TEST_PROGS += reclaim.sh include ../lib.mk
tools/testing/selftests/damon/reclaim.sh new file +42 -0
42 lines not on this page · raw message
Signature · 1 line
2.25.1
SeongJae Park
maintainerPATCH 3/4 mm/damon/lru_sort: enable and disable synchronously
In reply to SeongJae ParkWriting a value to DAMON_RECLAIM's 'enabled' parameter turns on or off DAMON in an ansychronous way. This means the parameter cannot be used to read the current status of DAMON_RECLAIM. 'kdamond_pid' parameter should be used instead for the purpose. The documentation is easy to be read as it works in a synchronous way, so it is a little bit confusing. It also makes the user space tooling dirty.
There's no real reason to have the asynchronous behavior, though. Simply make the parameter works synchronously, rather than updating the document.
--- mm/damon/lru_sort.c | 51 +++++++++++++++++++-------------------------- 1 file changed, 22 insertions(+), 29 deletions(-)
mm/damon/lru_sort.c +22 -29
@@ -9,7 +9,6 @@#include <linux/damon.h> #include <linux/module.h> -#include <linux/workqueue.h> #include "modules-common.h"
@@ -235,38 +234,31 @@ static int damon_lru_sort_turn(bool on)return 0 ; } -static struct delayed_work damon_lru_sort_timer; -static void damon_lru_sort_timer_fn (struct work_struct *work) -{ -static bool last_enabled; -bool now_enabled; - - now_enabled = enabled; -if (last_enabled != now_enabled) { -if (!damon_lru_sort_turn (now_enabled)) - last_enabled = now_enabled; -else - enabled = last_enabled; - } -} -static DECLARE_DELAYED_WORK(damon_lru_sort_timer, damon_lru_sort_timer_fn); - -static bool damon_lru_sort_initialized; -static int damon_lru_sort_enabled_store (const char *val,const struct kernel_param *kp) { -int rc =param_set_bool (val, kp); +bool is_enabled = enabled; +bool enable; +int err; + + err =strtobool (val, &enable); +if (err) +return err; -if (rc <0 ) -return rc; +if (is_enabled == enable) +return 0 ; -if (!damon_lru_sort_initialized) -return rc; +/* Called before init function. The function will handle this. */ +if (!ctx) + goto set_param_out; -schedule_delayed_work (&damon_lru_sort_timer,0 ); + err =damon_lru_sort_turn (enable); +if (err) +return err; -return 0 ; +set_param_out: + enabled = enable; +return err; }static const struct kernel_param_ops enabled_param_ops = {
@@ -320,10 +312,11 @@ static int __init damon_lru_sort_init(void) ctx->callback.after_wmarks_check = damon_lru_sort_after_wmarks_check; ctx->callback.after_aggregation = damon_lru_sort_after_aggregation; -schedule_delayed_work (&damon_lru_sort_timer,0 ); +/* 'enabled' has set before this function, probably via command line */ +if (enabled) + err =damon_lru_sort_turn (true); - damon_lru_sort_initialized = true; -return 0 ; +return err; }module_init (damon_lru_sort_init);
Signature · 1 line
2.25.1
SeongJae Park
maintainerPATCH 4/4 selftests/damon: add tests for DAMON_LRU_SORT's enabled parameter
In reply to SeongJae ParkAdds simple test cases for DAMON_LRU_SORT's 'enabled' parameter. Those tests are focusing on the synchronous behavior of DAMON_RECLAIM enabling and disabling.
--- tools/testing/selftests/damon/Makefile | 2 +- tools/testing/selftests/damon/lru_sort.sh | 41 +++++++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) create mode 100755 tools/testing/selftests/damon/lru_sort.sh
tools/testing/selftests/damon/Makefile +1 -1
@@ -8,6 +8,6 @@ TEST_PROGS = debugfs_attrs.sh debugfs_schemes.sh debugfs_target_ids.sh TEST_PROGS += debugfs_empty_targets.sh debugfs_huge_count_read_write.sh TEST_PROGS += debugfs_duplicate_context_creation.sh TEST_PROGS += sysfs.sh -TEST_PROGS += reclaim.sh +TEST_PROGS += reclaim.sh lru_sort.sh include ../lib.mk
tools/testing/selftests/damon/lru_sort.sh new file +41 -0
41 lines not on this page · raw message
Signature · 1 line
2.25.1