linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm/damon: remove dead code in damon_lru_sort_enabled_store()
@ 2022-08-12  1:24 Zeng Jingxiang
  2022-08-12  1:50 ` SeongJae Park
  0 siblings, 1 reply; 2+ messages in thread
From: Zeng Jingxiang @ 2022-08-12  1:24 UTC (permalink / raw)
  To: sj, akpm; +Cc: damon, linux-mm, linux-kernel, Zeng Jingxiang

From: Zeng Jingxiang <linuszeng@tencent.com>

The variable damon_lru_sort_initialized is always true, causing the
corresponding conditional expression cannot be executed.

Assigning true to damon_lru_sort_initialized here
544         damon_lru_sort_initialized = true;

The value of damon_lru_sort_initialized is always true.
As a result, the following expression cannot be executed.

463         if (!damon_lru_sort_initialized)
464                 return rc;

Fixes: 40e983cca927 ("mm/damon: introduce DAMON-based LRU-lists Sorting")
Signed-off-by: Zeng Jingxiang <linuszeng@tencent.com>
---
 mm/damon/lru_sort.c | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/mm/damon/lru_sort.c b/mm/damon/lru_sort.c
index 9de6f00a71c5..e2a656e1b728 100644
--- a/mm/damon/lru_sort.c
+++ b/mm/damon/lru_sort.c
@@ -450,8 +450,6 @@ static void damon_lru_sort_timer_fn(struct work_struct *work)
 }
 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)
 {
@@ -460,9 +458,6 @@ static int damon_lru_sort_enabled_store(const char *val,
 	if (rc < 0)
 		return rc;
 
-	if (!damon_lru_sort_initialized)
-		return rc;
-
 	schedule_delayed_work(&damon_lru_sort_timer, 0);
 
 	return 0;
@@ -541,7 +536,6 @@ static int __init damon_lru_sort_init(void)
 
 	schedule_delayed_work(&damon_lru_sort_timer, 0);
 
-	damon_lru_sort_initialized = true;
 	return 0;
 }
 
-- 
2.36.1



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] mm/damon: remove dead code in damon_lru_sort_enabled_store()
  2022-08-12  1:24 [PATCH] mm/damon: remove dead code in damon_lru_sort_enabled_store() Zeng Jingxiang
@ 2022-08-12  1:50 ` SeongJae Park
  0 siblings, 0 replies; 2+ messages in thread
From: SeongJae Park @ 2022-08-12  1:50 UTC (permalink / raw)
  To: Zeng Jingxiang; +Cc: sj, akpm, damon, linux-mm, linux-kernel, Zeng Jingxiang

Hi Zeng,

On Fri, 12 Aug 2022 09:24:59 +0800 Zeng Jingxiang <zengjx95@gmail.com> wrote:

> From: Zeng Jingxiang <linuszeng@tencent.com>
> 
> The variable damon_lru_sort_initialized is always true, causing the
> corresponding conditional expression cannot be executed.
> 
> Assigning true to damon_lru_sort_initialized here
> 544         damon_lru_sort_initialized = true;

Before the assignment, the variable is set 'false'.

> 
> The value of damon_lru_sort_initialized is always true.
> As a result, the following expression cannot be executed.
> 
> 463         if (!damon_lru_sort_initialized)
> 464                 return rc;

If this code is executed before the assignment, the expression can be executed.

Actually, there was a bug due to the absence of the variable.  You may refer to
that for the detail:
https://lore.kernel.org/damon/20220604192222.1488-1-sj@kernel.org/T/#t


Thanks,
SJ

[...]


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-08-12  1:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-08-12  1:24 [PATCH] mm/damon: remove dead code in damon_lru_sort_enabled_store() Zeng Jingxiang
2022-08-12  1:50 ` SeongJae Park

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).