summaryrefslogtreecommitdiff
path: root/samples/damon
diff options
context:
space:
mode:
Diffstat (limited to 'samples/damon')
-rw-r--r--samples/damon/mtier.c25
-rw-r--r--samples/damon/prcl.c31
-rw-r--r--samples/damon/wsse.c22
3 files changed, 47 insertions, 31 deletions
diff --git a/samples/damon/mtier.c b/samples/damon/mtier.c
index ed6bed8b3d4d..88156145172f 100644
--- a/samples/damon/mtier.c
+++ b/samples/damon/mtier.c
@@ -27,14 +27,14 @@ module_param(node1_end_addr, ulong, 0600);
static int damon_sample_mtier_enable_store(
const char *val, const struct kernel_param *kp);
-static const struct kernel_param_ops enable_param_ops = {
+static const struct kernel_param_ops enabled_param_ops = {
.set = damon_sample_mtier_enable_store,
.get = param_get_bool,
};
-static bool enable __read_mostly;
-module_param_cb(enable, &enable_param_ops, &enable, 0600);
-MODULE_PARM_DESC(enable, "Enable of disable DAMON_SAMPLE_MTIER");
+static bool enabled __read_mostly;
+module_param_cb(enabled, &enabled_param_ops, &enabled, 0600);
+MODULE_PARM_DESC(enabled, "Enable or disable DAMON_SAMPLE_MTIER");
static struct damon_ctx *ctxs[2];
@@ -156,20 +156,23 @@ static bool init_called;
static int damon_sample_mtier_enable_store(
const char *val, const struct kernel_param *kp)
{
- bool enabled = enable;
+ bool is_enabled = enabled;
int err;
- err = kstrtobool(val, &enable);
+ err = kstrtobool(val, &enabled);
if (err)
return err;
- if (enable == enabled)
+ if (enabled == is_enabled)
return 0;
- if (enable) {
+ if (!init_called)
+ return 0;
+
+ if (enabled) {
err = damon_sample_mtier_start();
if (err)
- enable = false;
+ enabled = false;
return err;
}
damon_sample_mtier_stop();
@@ -181,10 +184,10 @@ static int __init damon_sample_mtier_init(void)
int err = 0;
init_called = true;
- if (enable) {
+ if (enabled) {
err = damon_sample_mtier_start();
if (err)
- enable = false;
+ enabled = false;
}
return 0;
}
diff --git a/samples/damon/prcl.c b/samples/damon/prcl.c
index 5597e6a08ab2..f971e61e6c5c 100644
--- a/samples/damon/prcl.c
+++ b/samples/damon/prcl.c
@@ -17,14 +17,14 @@ module_param(target_pid, int, 0600);
static int damon_sample_prcl_enable_store(
const char *val, const struct kernel_param *kp);
-static const struct kernel_param_ops enable_param_ops = {
+static const struct kernel_param_ops enabled_param_ops = {
.set = damon_sample_prcl_enable_store,
.get = param_get_bool,
};
-static bool enable __read_mostly;
-module_param_cb(enable, &enable_param_ops, &enable, 0600);
-MODULE_PARM_DESC(enable, "Enable of disable DAMON_SAMPLE_WSSE");
+static bool enabled __read_mostly;
+module_param_cb(enabled, &enabled_param_ops, &enabled, 0600);
+MODULE_PARM_DESC(enabled, "Enable or disable DAMON_SAMPLE_PRCL");
static struct damon_ctx *ctx;
static struct pid *target_pidp;
@@ -109,23 +109,28 @@ static void damon_sample_prcl_stop(void)
put_pid(target_pidp);
}
+static bool init_called;
+
static int damon_sample_prcl_enable_store(
const char *val, const struct kernel_param *kp)
{
- bool enabled = enable;
+ bool is_enabled = enabled;
int err;
- err = kstrtobool(val, &enable);
+ err = kstrtobool(val, &enabled);
if (err)
return err;
- if (enable == enabled)
+ if (enabled == is_enabled)
+ return 0;
+
+ if (!init_called)
return 0;
- if (enable) {
+ if (enabled) {
err = damon_sample_prcl_start();
if (err)
- enable = false;
+ enabled = false;
return err;
}
damon_sample_prcl_stop();
@@ -134,6 +139,14 @@ static int damon_sample_prcl_enable_store(
static int __init damon_sample_prcl_init(void)
{
+ int err = 0;
+
+ init_called = true;
+ if (enabled) {
+ err = damon_sample_prcl_start();
+ if (err)
+ enabled = false;
+ }
return 0;
}
diff --git a/samples/damon/wsse.c b/samples/damon/wsse.c
index e941958b1032..d50730ee65a7 100644
--- a/samples/damon/wsse.c
+++ b/samples/damon/wsse.c
@@ -18,14 +18,14 @@ module_param(target_pid, int, 0600);
static int damon_sample_wsse_enable_store(
const char *val, const struct kernel_param *kp);
-static const struct kernel_param_ops enable_param_ops = {
+static const struct kernel_param_ops enabled_param_ops = {
.set = damon_sample_wsse_enable_store,
.get = param_get_bool,
};
-static bool enable __read_mostly;
-module_param_cb(enable, &enable_param_ops, &enable, 0600);
-MODULE_PARM_DESC(enable, "Enable or disable DAMON_SAMPLE_WSSE");
+static bool enabled __read_mostly;
+module_param_cb(enabled, &enabled_param_ops, &enabled, 0600);
+MODULE_PARM_DESC(enabled, "Enable or disable DAMON_SAMPLE_WSSE");
static struct damon_ctx *ctx;
static struct pid *target_pidp;
@@ -94,20 +94,20 @@ static bool init_called;
static int damon_sample_wsse_enable_store(
const char *val, const struct kernel_param *kp)
{
- bool enabled = enable;
+ bool is_enabled = enabled;
int err;
- err = kstrtobool(val, &enable);
+ err = kstrtobool(val, &enabled);
if (err)
return err;
- if (enable == enabled)
+ if (enabled == is_enabled)
return 0;
- if (enable) {
+ if (enabled) {
err = damon_sample_wsse_start();
if (err)
- enable = false;
+ enabled = false;
return err;
}
damon_sample_wsse_stop();
@@ -119,10 +119,10 @@ static int __init damon_sample_wsse_init(void)
int err = 0;
init_called = true;
- if (enable) {
+ if (enabled) {
err = damon_sample_wsse_start();
if (err)
- enable = false;
+ enabled = false;
}
return err;
}