Skip to contentSkip to conversation

mm/vmscan.c: Clean code by removing unnecessary assignment

PATCH Applied [email protected] 3 participants 3 messages Mar 19, 2020 – Mar 20, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mm/vmscan.c: Clean code by removing unnecessary assignment

From: Mateusz Nosek <[email protected]>

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.

---
 mm/vmscan.c | 1 -
 1 file changed, 1 deletion(-)
mm/vmscan.c +0 -1
index dca623db51c8..453ff2abcb58 100644
@@ -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;
Signature · 1 line
2.17.1
reviewer
#1 lore raw

It is usually preferable to Cc author of the code (added Johannes)

Quoted 5 lines · On Thu 19-03-20 17:59:38, [email protected] wrote:

From: Mateusz Nosek <[email protected]>

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.
"

Quoted 1 line

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.

Quoted 18 lines
---
 mm/vmscan.c | 1 -
 1 file changed, 1 deletion(-)
mm/vmscan.c +0 -1
index dca623db51c8..453ff2abcb58 100644
@@ -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;
Signature · 1 line
2.17.1
Signature · 2 lines
Michal Hocko
SUSE Labs
maintainer Acked-by
#2 lore raw
Quoted 9 lines · Michal Hocko

It is usually preferable to Cc author of the code (added Johannes)

Quoted 5 lines · On Thu 19-03-20 17:59:38, [email protected] wrote:

From: Mateusz Nosek <[email protected]>

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.

Quoted 6 lines

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.
"

Yeah that sounds good.

Quoted 7 lines
Quoted 1 line

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.

It's a valid concern, but I think in this case specifically we're very unlikely to change the ordering here - violate memory.low before going after active pages of unprotected cgroups.

I indeed just kept it stupid: reset everything, then retry. But it appears that the unnecessary assignment trips people up and wastes their time, so I'm in favor of removing it.