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
1926/*1926/*
1927 * __damon_stop() - Stops monitoring of a given context.1927 * __damon_stop() - Stops monitoring of a given context.
1928 * @ctx: monitoring context1928 * @ctx: monitoring context
1929 *
1930 * Return: 0 on success, negative error code otherwise.
1931 */1929 */
1932static int __damon_stop(struct damon_ctx *ctx)1930static void __damon_stop(struct damon_ctx *ctx)
1933{1931{
1934 struct task_struct *tsk;1932 struct task_struct *tsk;
1935 1933
@@ -1939,31 +1937,24 @@ static int __damon_stop(struct damon_ctx *ctx) · 3 unmodified lines
1939 get_task_struct(tsk);1937 get_task_struct(tsk);
1940 mutex_unlock(&ctx->kdamond_lock);1938 mutex_unlock(&ctx->kdamond_lock);
1941 kthread_stop_put(tsk);1939 kthread_stop_put(tsk);
1942 return 0;1940 return;
1943 }1941 }
1944 mutex_unlock(&ctx->kdamond_lock);1942 mutex_unlock(&ctx->kdamond_lock);
1945
1946 return -EPERM;
1947}1943}
1948 1944
1949/**1945/**
1950 * damon_stop() - Stops the monitorings for a given group of contexts.1946 * damon_stop() - Stops the monitorings for a given group of contexts.
1951 * @ctxs: an array of the pointers for contexts to stop monitoring1947 * @ctxs: an array of the pointers for contexts to stop monitoring
1952 * @nr_ctxs: size of @ctxs1948 * @nr_ctxs: size of @ctxs
1953 *
1954 * Return: 0 on success, negative error code otherwise.
1955 */1949 */
1956int damon_stop(struct damon_ctx **ctxs, int nr_ctxs)1950int damon_stop(struct damon_ctx **ctxs, int nr_ctxs)
1957{1951{
1958 int i, err = 0;1952 int i;
1959 1953
1960 for (i = 0; i < nr_ctxs; i++) {1954 for (i = 0; i < nr_ctxs; i++)
1961 /* nr_running_ctxs is decremented in kdamond_fn */1955 /* nr_running_ctxs is decremented in kdamond_fn */
1962 err = __damon_stop(ctxs[i]);1956 __damon_stop(ctxs[i]);
1963 if (err)1957 return 0;
1964 break;
1965 }
1966 return err;
1967}1958}
1968 1959
1969/**1960/**