diff mbox series

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

Message ID 20201117164919.GA82821@rlk (mailing list archive)
State New, archived
Headers show
Series mm/lru: simplify is_file_lru() and is_active_lru() | expand

Commit Message

Hui Su Nov. 17, 2020, 4:49 p.m. UTC
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.

Signed-off-by: Hui Su <sh_def@163.com>
---
 include/linux/mmzone.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Hui Su Nov. 17, 2020, 4:53 p.m. UTC | #1
On Wed, Nov 18, 2020 at 12:49:19AM +0800, Hui Su wrote:
> 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.
> 
> Signed-off-by: Hui Su <sh_def@163.com>
> ---
>  include/linux/mmzone.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
> index fb3bf696c05e..294369c652d0 100644
> --- a/include/linux/mmzone.h
> +++ b/include/linux/mmzone.h
> @@ -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
> -- 
> 2.29.0

The commit message is not correct, please ignore this change.
Matthew Wilcox Nov. 17, 2020, 5:40 p.m. UTC | #2
On Wed, Nov 18, 2020 at 12:49:19AM +0800, Hui Su wrote:
> 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.
diff mbox series

Patch

diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
index fb3bf696c05e..294369c652d0 100644
--- a/include/linux/mmzone.h
+++ b/include/linux/mmzone.h
@@ -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