diff options
| author | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2025-09-15 08:18:40 +0200 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2025-09-15 08:18:40 +0200 |
| commit | a4d43c1f17b9f143af5868285c513c866e9cf67b (patch) | |
| tree | 36117fb220ae2ff5cf1c11fc6ffa705acdc34833 /mm/damon/sysfs.c | |
| parent | 82432bbfb9e83b7e81d04660fe129b99a29b2ac2 (diff) | |
| parent | f83ec76bf285bea5727f478a68b894f5543ca76e (diff) | |
Merge 6.17-rc6 into usb-next
We need the USB fixes in here as well.
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'mm/damon/sysfs.c')
| -rw-r--r-- | mm/damon/sysfs.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/mm/damon/sysfs.c b/mm/damon/sysfs.c index 6d2b0dab50cb..7b9254cadd5f 100644 --- a/mm/damon/sysfs.c +++ b/mm/damon/sysfs.c @@ -1260,14 +1260,18 @@ static ssize_t state_show(struct kobject *kobj, struct kobj_attribute *attr, { struct damon_sysfs_kdamond *kdamond = container_of(kobj, struct damon_sysfs_kdamond, kobj); - struct damon_ctx *ctx = kdamond->damon_ctx; - bool running; + struct damon_ctx *ctx; + bool running = false; - if (!ctx) - running = false; - else + if (!mutex_trylock(&damon_sysfs_lock)) + return -EBUSY; + + ctx = kdamond->damon_ctx; + if (ctx) running = damon_is_running(ctx); + mutex_unlock(&damon_sysfs_lock); + return sysfs_emit(buf, "%s\n", running ? damon_sysfs_cmd_strs[DAMON_SYSFS_CMD_ON] : damon_sysfs_cmd_strs[DAMON_SYSFS_CMD_OFF]); |
