Skip to contentSkip to conversation

mm/vmscan: reorder scan_balance definition to simplify the scan type check

PATCH In review Wei Yang 2 participants 3 messages Apr 5, 2022 – Apr 6, 2022

Subsystems (3)
lore
Share & tools
lore

Wei Yang

author
#0 lore raw

PATCH 1/1 mm/vmscan: reorder scan_balance definition to simplify the scan type check

Even is_file_lru() return bool type, we leverage it as an index for anon or file.

With this in hand, after reorder scan_balance definition, we can compare directly between scan_balance and file to get the exclusive scan type.

After this, the code looks more readable and save some instructions.

CC Johannes Weiner <[email protected]>
CC Mel Gorman <[email protected]>
---
 mm/vmscan.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
mm/vmscan.c +3 -3
index 89745cf34386..0b7cc9309e70 100644
@@ -2638,10 +2638,10 @@ static bool inactive_is_low(struct lruvec *lruvec, enum lru_list inactive_lru)
 }
 
 enum scan_balance {
-	SCAN_EQUAL,
-	SCAN_FRACT,
 	SCAN_ANON,
 	SCAN_FILE,
+	SCAN_EQUAL,
+	SCAN_FRACT,
 };
 
 /*
@@ -2838,7 +2838,7 @@ static void get_scan_count(struct lruvec *lruvec, struct scan_control *sc,
 		case SCAN_FILE:
 		case SCAN_ANON:
 			/* Scan one type exclusively */
-			if ((scan_balance == SCAN_FILE) != file)
+			if (scan_balance != file)
 				scan = 0;
 			break;
 		default:
Signature · 1 line
2.33.1
#1 lore raw
Quoted 7 lines · Wei Yang

Even is_file_lru() return bool type, we leverage it as an index for anon or file.

With this in hand, after reorder scan_balance definition, we can compare directly between scan_balance and file to get the exclusive scan type.

After this, the code looks more readable and save some instructions.

This scares me. I would not apply this patch.

author
#2 lore raw
Quoted 10 lines · Matthew Wilcox
Quoted 7 lines · Wei Yang

Even is_file_lru() return bool type, we leverage it as an index for anon or file.

With this in hand, after reorder scan_balance definition, we can compare directly between scan_balance and file to get the exclusive scan type.

After this, the code looks more readable and save some instructions.

This scares me. I would not apply this patch.

Because?

Signature · 2 lines
Wei Yang
Help you, Help me