Skip to contentSkip to conversation

mm/lru: simplify is_file_lru() and is_active_lru()

PATCH In review Hui Su 2 participants 3 messages Nov 17, 2020

Subsystems (3)
lore
Share & tools
lore

Hui Su

author
#0 lore raw

PATCH 1/1 mm/lru: simplify is_file_lru() and is_active_lru()

page->lru bit 0 can tell whether the page is avtive page or not.
page->lru bit 1 can tell whether the page is file page or not.

---
 include/linux/mmzone.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
include/linux/mmzone.h +2 -2
index fb3bf696c05e..294369c652d0 100644
@@ -258,12 +258,12 @@ enum lru_list {
 
 static inline bool is_file_lru(enum lru_list lru)
 {
-	return (lru == LRU_INACTIVE_FILE || lru == LRU_ACTIVE_FILE);
+	return lru & LRU_FILE;
 }
 
 static inline bool is_active_lru(enum lru_list lru)
 {
-	return (lru == LRU_ACTIVE_ANON || lru == LRU_ACTIVE_FILE);
+	return lru & LRU_ACTIVE;
 }
 
 #define ANON_AND_FILE 2
Signature · 1 line
2.29.0
author
#1 lore raw
Quoted 31 lines · Hui Su

page->lru bit 0 can tell whether the page is avtive page or not.
page->lru bit 1 can tell whether the page is file page or not.

---
 include/linux/mmzone.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
include/linux/mmzone.h +2 -2
index fb3bf696c05e..294369c652d0 100644
@@ -258,12 +258,12 @@ enum lru_list {
 
 static inline bool is_file_lru(enum lru_list lru)
 {
-	return (lru == LRU_INACTIVE_FILE || lru == LRU_ACTIVE_FILE);
+	return lru & LRU_FILE;
 }
 
 static inline bool is_active_lru(enum lru_list lru)
 {
-	return (lru == LRU_ACTIVE_ANON || lru == LRU_ACTIVE_FILE);
+	return lru & LRU_ACTIVE;
 }
 
 #define ANON_AND_FILE 2
Signature · 1 line
2.29.0

The commit message is not correct, please ignore this change.

#2 lore raw
In reply to Hui Su
Quoted 4 lines · Hui Su

page->lru bit 0 can tell whether the page is avtive page or not.
page->lru bit 1 can tell whether the page is file page or not.

This is wrong. I'll let you figure out why.