lkml.org 
[lkml]   [2020]   [Mar]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] mm/swap_state.c: use the same way to count page in [add_to|delete_from]_swap_cache
Date
Function add_to_swap_cache() and delete_from_swap_cache() are counter
parts, while currently they use different way to count page.

It doesn't break any thing because we only have two size for PageAnon,
but this is confusing and not a good practice.

This patch corrects it by both using compound_nr().

Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
---
mm/swap_state.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/mm/swap_state.c b/mm/swap_state.c
index 8e7ce9a9bc5e..51d8884a693a 100644
--- a/mm/swap_state.c
+++ b/mm/swap_state.c
@@ -158,7 +158,7 @@ int add_to_swap_cache(struct page *page, swp_entry_t entry, gfp_t gfp)
void __delete_from_swap_cache(struct page *page, swp_entry_t entry)
{
struct address_space *address_space = swap_address_space(entry);
- int i, nr = hpage_nr_pages(page);
+ int i, nr = compound_nr(page);
pgoff_t idx = swp_offset(entry);
XA_STATE(xas, &address_space->i_pages, idx);

@@ -251,7 +251,7 @@ void delete_from_swap_cache(struct page *page)
xa_unlock_irq(&address_space->i_pages);

put_swap_page(page, entry);
- page_ref_sub(page, hpage_nr_pages(page));
+ page_ref_sub(page, compound_nr(page));
}

/*
--
2.23.0
\
 
 \ /
  Last update: 2020-03-15 03:08    [W:0.036 / U:0.856 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site