Skip to content

Commit c53954a

Browse files
Mel Gormantorvalds
authored andcommitted
mm: remove lru parameter from __lru_cache_add and lru_cache_add_lru
Similar to __pagevec_lru_add, this patch removes the LRU parameter from __lru_cache_add and lru_cache_add_lru as the caller does not control the exact LRU the page gets added to. lru_cache_add_lru gets renamed to lru_cache_add the name is silly without the lru parameter. With the parameter removed, it is required that the caller indicate if they want the page added to the active or inactive list by setting or clearing PageActive respectively. [akpm@linux-foundation.org: Suggested the patch] [gang.chen@asianux.com: fix used-unintialized warning] Signed-off-by: Mel Gorman <mgorman@suse.de> Signed-off-by: Chen Gang <gang.chen@asianux.com> Cc: Jan Kara <jack@suse.cz> Cc: Rik van Riel <riel@redhat.com> Acked-by: Johannes Weiner <hannes@cmpxchg.org> Cc: Alexey Lyahkov <alexey.lyashkov@gmail.com> Cc: Andrew Perepechko <anserper@ya.ru> Cc: Robin Dong <sanbai@taobao.com> Cc: Theodore Tso <tytso@mit.edu> Cc: Hugh Dickins <hughd@google.com> Cc: Rik van Riel <riel@redhat.com> Cc: Bernd Schubert <bernd.schubert@fastmail.fm> Cc: David Howells <dhowells@redhat.com> Cc: Trond Myklebust <Trond.Myklebust@netapp.com> Cc: Mel Gorman <mgorman@suse.de> Cc: Rik van Riel <riel@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent a0b8cab commit c53954a

4 files changed

Lines changed: 20 additions & 20 deletions

File tree

‎include/linux/swap.h‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <linux/node.h>
1111
#include <linux/fs.h>
1212
#include <linux/atomic.h>
13+
#include <linux/page-flags.h>
1314
#include <asm/page.h>
1415

1516
struct notifier_block;
@@ -233,8 +234,8 @@ extern unsigned long nr_free_pagecache_pages(void);
233234

234235

235236
/* linux/mm/swap.c */
236-
extern void __lru_cache_add(struct page *, enum lru_list lru);
237-
extern void lru_cache_add_lru(struct page *, enum lru_list lru);
237+
extern void __lru_cache_add(struct page *);
238+
extern void lru_cache_add(struct page *);
238239
extern void lru_add_page_tail(struct page *page, struct page *page_tail,
239240
struct lruvec *lruvec, struct list_head *head);
240241
extern void activate_page(struct page *);
@@ -254,12 +255,14 @@ extern void add_page_to_unevictable_list(struct page *page);
254255
*/
255256
static inline void lru_cache_add_anon(struct page *page)
256257
{
257-
__lru_cache_add(page, LRU_INACTIVE_ANON);
258+
ClearPageActive(page);
259+
__lru_cache_add(page);
258260
}
259261

260262
static inline void lru_cache_add_file(struct page *page)
261263
{
262-
__lru_cache_add(page, LRU_INACTIVE_FILE);
264+
ClearPageActive(page);
265+
__lru_cache_add(page);
263266
}
264267

265268
/* linux/mm/vmscan.c */

‎mm/rmap.c‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1093,9 +1093,10 @@ void page_add_new_anon_rmap(struct page *page,
10931093
else
10941094
__inc_zone_page_state(page, NR_ANON_TRANSPARENT_HUGEPAGES);
10951095
__page_set_anon_rmap(page, vma, address, 1);
1096-
if (!mlocked_vma_newpage(vma, page))
1097-
lru_cache_add_lru(page, LRU_ACTIVE_ANON);
1098-
else
1096+
if (!mlocked_vma_newpage(vma, page)) {
1097+
SetPageActive(page);
1098+
lru_cache_add(page);
1099+
} else
10991100
add_page_to_unevictable_list(page);
11001101
}
11011102

‎mm/swap.c‎

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -494,15 +494,10 @@ EXPORT_SYMBOL(mark_page_accessed);
494494
* pagevec is drained. This gives a chance for the caller of __lru_cache_add()
495495
* have the page added to the active list using mark_page_accessed().
496496
*/
497-
void __lru_cache_add(struct page *page, enum lru_list lru)
497+
void __lru_cache_add(struct page *page)
498498
{
499499
struct pagevec *pvec = &get_cpu_var(lru_add_pvec);
500500

501-
if (is_active_lru(lru))
502-
SetPageActive(page);
503-
else
504-
ClearPageActive(page);
505-
506501
page_cache_get(page);
507502
if (!pagevec_space(pvec))
508503
__pagevec_lru_add(pvec);
@@ -512,11 +507,10 @@ void __lru_cache_add(struct page *page, enum lru_list lru)
512507
EXPORT_SYMBOL(__lru_cache_add);
513508

514509
/**
515-
* lru_cache_add_lru - add a page to a page list
510+
* lru_cache_add - add a page to a page list
516511
* @page: the page to be added to the LRU.
517-
* @lru: the LRU list to which the page is added.
518512
*/
519-
void lru_cache_add_lru(struct page *page, enum lru_list lru)
513+
void lru_cache_add(struct page *page)
520514
{
521515
if (PageActive(page)) {
522516
VM_BUG_ON(PageUnevictable(page));
@@ -525,7 +519,7 @@ void lru_cache_add_lru(struct page *page, enum lru_list lru)
525519
}
526520

527521
VM_BUG_ON(PageLRU(page));
528-
__lru_cache_add(page, lru);
522+
__lru_cache_add(page);
529523
}
530524

531525
/**
@@ -745,6 +739,9 @@ void release_pages(struct page **pages, int nr, int cold)
745739
del_page_from_lru_list(page, lruvec, page_off_lru(page));
746740
}
747741

742+
/* Clear Active bit in case of parallel mark_page_accessed */
743+
ClearPageActive(page);
744+
748745
list_add(&page->lru, &pages_to_free);
749746
}
750747
if (zone)

‎mm/vmscan.c‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,6 @@ int remove_mapping(struct address_space *mapping, struct page *page)
546546
void putback_lru_page(struct page *page)
547547
{
548548
int lru;
549-
int active = !!TestClearPageActive(page);
550549
int was_unevictable = PageUnevictable(page);
551550

552551
VM_BUG_ON(PageLRU(page));
@@ -561,8 +560,8 @@ void putback_lru_page(struct page *page)
561560
* unevictable page on [in]active list.
562561
* We know how to handle that.
563562
*/
564-
lru = active + page_lru_base_type(page);
565-
lru_cache_add_lru(page, lru);
563+
lru = page_lru_base_type(page);
564+
lru_cache_add(page);
566565
} else {
567566
/*
568567
* Put unevictable pages directly on zone's unevictable

0 commit comments

Comments
 (0)