lkml.org 
[lkml]   [2020]   [Mar]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] mm/vmscan.c: Clean code by removing unnecessary assignment
It is usually preferable to Cc author of the code (added Johannes)

On Thu 19-03-20 17:59:38, mateusznosek0@gmail.com wrote:
> From: Mateusz Nosek <mateusznosek0@gmail.com>
>
> Previously 0 was assigned to 'sc->skipped_deactivate'. It could happen only
> if 'sc->skipped_deactivate' was 0 so the assignment is unnecessary and can
> be removed.

The above wording was a bit hard to understdand for me. I would go with
"
sc->memcg_low_skipped resets skipped_deactivate to 0 but this is not
needed as this code path is never reachable with skipped_deactivate != 0
due to previous sc->skipped_deactivate branch.
"

> Signed-off-by: Mateusz Nosek <mateusznosek0@gmail.com>

The patch is correct. I am not sure it results in a better code though.
I will defer to Johannes here. I suspect he simply wanted to express
that skipped_deactivate should be always reset when retrying the direct
reclaim. After this patch this could be lost in future changes so the
code would be more subtle. But I am only guessing here.

> ---
> mm/vmscan.c | 1 -
> 1 file changed, 1 deletion(-)
>
> diff --git a/mm/vmscan.c b/mm/vmscan.c
> index dca623db51c8..453ff2abcb58 100644
> --- a/mm/vmscan.c
> +++ b/mm/vmscan.c
> @@ -3093,7 +3093,6 @@ static unsigned long do_try_to_free_pages(struct zonelist *zonelist,
> if (sc->memcg_low_skipped) {
> sc->priority = initial_priority;
> sc->force_deactivate = 0;
> - sc->skipped_deactivate = 0;
> sc->memcg_low_reclaim = 1;
> sc->memcg_low_skipped = 0;
> goto retry;
> --
> 2.17.1

--
Michal Hocko
SUSE Labs

\
 
 \ /
  Last update: 2020-03-19 18:13    [W:0.040 / U:0.544 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site