Skip to content

Commit

Permalink
mm: return boolean from page_is_file_cache()
Browse files Browse the repository at this point in the history
page_is_file_cache() has been used for both boolean checks and LRU
arithmetic, which was always a bit weird.

Now that page_lru_base_type() exists for LRU arithmetic, make
page_is_file_cache() a real predicate function and adjust the
boolean-using callsites to drop those pesky double negations.

Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
Reviewed-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Johannes Weiner authored and Linus Torvalds committed Sep 22, 2009
1 parent 401a8e1 commit 6c0b135
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 11 deletions.
8 changes: 2 additions & 6 deletions include/linux/mm_inline.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* page_is_file_cache - should the page be on a file LRU or anon LRU?
* @page: the page to test
*
* Returns LRU_FILE if @page is page cache page backed by a regular filesystem,
* Returns 1 if @page is page cache page backed by a regular filesystem,
* or 0 if @page is anonymous, tmpfs or otherwise ram or swap backed.
* Used by functions that manipulate the LRU lists, to sort a page
* onto the right LRU list.
Expand All @@ -16,11 +16,7 @@
*/
static inline int page_is_file_cache(struct page *page)
{
if (PageSwapBacked(page))
return 0;

/* The page is page cache backed by a normal filesystem. */
return LRU_FILE;
return !PageSwapBacked(page);
}

static inline void
Expand Down
6 changes: 3 additions & 3 deletions mm/migrate.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ int putback_lru_pages(struct list_head *l)
list_for_each_entry_safe(page, page2, l, lru) {
list_del(&page->lru);
dec_zone_page_state(page, NR_ISOLATED_ANON +
!!page_is_file_cache(page));
page_is_file_cache(page));
putback_lru_page(page);
count++;
}
Expand Down Expand Up @@ -701,7 +701,7 @@ static int unmap_and_move(new_page_t get_new_page, unsigned long private,
*/
list_del(&page->lru);
dec_zone_page_state(page, NR_ISOLATED_ANON +
!!page_is_file_cache(page));
page_is_file_cache(page));
putback_lru_page(page);
}

Expand Down Expand Up @@ -751,7 +751,7 @@ int migrate_pages(struct list_head *from,
local_irq_save(flags);
list_for_each_entry(page, from, lru)
__inc_zone_page_state(page, NR_ISOLATED_ANON +
!!page_is_file_cache(page));
page_is_file_cache(page));
local_irq_restore(flags);

if (!swapwrite)
Expand Down
2 changes: 1 addition & 1 deletion mm/swap.c
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ void activate_page(struct page *page)
add_page_to_lru_list(zone, page, lru);
__count_vm_event(PGACTIVATE);

update_page_reclaim_stat(zone, page, !!file, 1);
update_page_reclaim_stat(zone, page, file, 1);
}
spin_unlock_irq(&zone->lru_lock);
}
Expand Down
2 changes: 1 addition & 1 deletion mm/vmscan.c
Original file line number Diff line number Diff line change
Expand Up @@ -821,7 +821,7 @@ int __isolate_lru_page(struct page *page, int mode, int file)
if (mode != ISOLATE_BOTH && (!PageActive(page) != !mode))
return ret;

if (mode != ISOLATE_BOTH && (!page_is_file_cache(page) != !file))
if (mode != ISOLATE_BOTH && page_is_file_cache(page) != file)
return ret;

/*
Expand Down

0 comments on commit 6c0b135

Please sign in to comment.