History

mm/damon/core: make damon_stop() never fail

damon_stop() has no reason to fail. It returns an error code only for possible future changes that can make it fail. Such a change has not been made yet, and this only makes the error handling complicated and confusing. Ensure it returns no error.

SJ Park committed 4 months ago

Commit a0f1e311 parent 5c5df7a1 file · +6 −15Browse files

Unified · Split

mm/damon/core.c+6−15
@@ -1926,10 +1926,8 @@ int damon_start(struct damon_ctx **ctxs, int nr_ctxs, bool exclusive) · 1925 unmodified lines
19261926 /*
19271927 * __damon_stop() - Stops monitoring of a given context.
19281928 * @ctx: monitoring context
1929− *
1930− * Return: 0 on success, negative error code otherwise.
19311929 */
1932−static int __damon_stop(struct damon_ctx *ctx)
1930+static void __damon_stop(struct damon_ctx *ctx)
19331931 {
19341932 struct task_struct *tsk;
19351933
@@ -1939,31 +1937,24 @@ static int __damon_stop(struct damon_ctx *ctx) · 3 unmodified lines
19391937 get_task_struct(tsk);
19401938 mutex_unlock(&ctx->kdamond_lock);
19411939 kthread_stop_put(tsk);
1942− return 0;
1940+ return;
19431941 }
19441942 mutex_unlock(&ctx->kdamond_lock);
1945−
1946− return -EPERM;
19471943 }
19481944
19491945 /**
19501946 * damon_stop() - Stops the monitorings for a given group of contexts.
19511947 * @ctxs: an array of the pointers for contexts to stop monitoring
19521948 * @nr_ctxs: size of @ctxs
1953− *
1954− * Return: 0 on success, negative error code otherwise.
19551949 */
19561950 int damon_stop(struct damon_ctx **ctxs, int nr_ctxs)
19571951 {
1958− int i, err = 0;
1952+ int i;
19591953
1960− for (i = 0; i < nr_ctxs; i++) {
1954+ for (i = 0; i < nr_ctxs; i++)
19611955 /* nr_running_ctxs is decremented in kdamond_fn */
1962− err = __damon_stop(ctxs[i]);
1963− if (err)
1964− break;
1965− }
1966− return err;
1956+ __damon_stop(ctxs[i]);
1957+ return 0;
19671958 }
19681959
19691960 /**