Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 115836
b: refs/heads/master
c: f04e9eb
h: refs/heads/master
v: v3
  • Loading branch information
KOSAKI Motohiro authored and Linus Torvalds committed Oct 20, 2008
1 parent 00cabe7 commit 1bf63b7
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 67 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: b69408e88bd86b98feb7b9a38fd865e1ddb29827
refs/heads/master: f04e9ebbe4909f9a41efd55149bc353299f4e83b
13 changes: 11 additions & 2 deletions trunk/include/linux/pagevec.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ struct pagevec {
void __pagevec_release(struct pagevec *pvec);
void __pagevec_release_nonlru(struct pagevec *pvec);
void __pagevec_free(struct pagevec *pvec);
void __pagevec_lru_add(struct pagevec *pvec);
void __pagevec_lru_add_active(struct pagevec *pvec);
void ____pagevec_lru_add(struct pagevec *pvec, enum lru_list lru);
void pagevec_strip(struct pagevec *pvec);
unsigned pagevec_lookup(struct pagevec *pvec, struct address_space *mapping,
pgoff_t start, unsigned nr_pages);
Expand Down Expand Up @@ -81,6 +80,16 @@ static inline void pagevec_free(struct pagevec *pvec)
__pagevec_free(pvec);
}

static inline void __pagevec_lru_add(struct pagevec *pvec)
{
____pagevec_lru_add(pvec, LRU_INACTIVE);
}

static inline void __pagevec_lru_add_active(struct pagevec *pvec)
{
____pagevec_lru_add(pvec, LRU_ACTIVE);
}

static inline void pagevec_lru_add(struct pagevec *pvec)
{
if (pagevec_count(pvec))
Expand Down
18 changes: 16 additions & 2 deletions trunk/include/linux/swap.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,15 +171,29 @@ extern unsigned int nr_free_pagecache_pages(void);


/* linux/mm/swap.c */
extern void lru_cache_add(struct page *);
extern void lru_cache_add_active(struct page *);
extern void __lru_cache_add(struct page *, enum lru_list lru);
extern void lru_cache_add_lru(struct page *, enum lru_list lru);
extern void activate_page(struct page *);
extern void mark_page_accessed(struct page *);
extern void lru_add_drain(void);
extern int lru_add_drain_all(void);
extern void rotate_reclaimable_page(struct page *page);
extern void swap_setup(void);

/**
* lru_cache_add: add a page to the page lists
* @page: the page to add
*/
static inline void lru_cache_add(struct page *page)
{
__lru_cache_add(page, LRU_INACTIVE);
}

static inline void lru_cache_add_active(struct page *page)
{
__lru_cache_add(page, LRU_ACTIVE);
}

/* linux/mm/vmscan.c */
extern unsigned long try_to_free_pages(struct zonelist *zonelist, int order,
gfp_t gfp_mask);
Expand Down
11 changes: 1 addition & 10 deletions trunk/mm/migrate.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,7 @@ int migrate_prep(void)

static inline void move_to_lru(struct page *page)
{
if (PageActive(page)) {
/*
* lru_cache_add_active checks that
* the PG_active bit is off.
*/
ClearPageActive(page);
lru_cache_add_active(page);
} else {
lru_cache_add(page);
}
lru_cache_add_lru(page, page_lru(page));
put_page(page);
}

Expand Down
79 changes: 27 additions & 52 deletions trunk/mm/swap.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@
/* How many pages do we try to swap or page in/out together? */
int page_cluster;

static DEFINE_PER_CPU(struct pagevec, lru_add_pvecs);
static DEFINE_PER_CPU(struct pagevec, lru_add_active_pvecs);
static DEFINE_PER_CPU(struct pagevec[NR_LRU_LISTS], lru_add_pvecs);
static DEFINE_PER_CPU(struct pagevec, lru_rotate_pvecs);

/*
Expand Down Expand Up @@ -186,28 +185,29 @@ void mark_page_accessed(struct page *page)

EXPORT_SYMBOL(mark_page_accessed);

/**
* lru_cache_add: add a page to the page lists
* @page: the page to add
*/
void lru_cache_add(struct page *page)
void __lru_cache_add(struct page *page, enum lru_list lru)
{
struct pagevec *pvec = &get_cpu_var(lru_add_pvecs);
struct pagevec *pvec = &get_cpu_var(lru_add_pvecs)[lru];

page_cache_get(page);
if (!pagevec_add(pvec, page))
__pagevec_lru_add(pvec);
____pagevec_lru_add(pvec, lru);
put_cpu_var(lru_add_pvecs);
}

void lru_cache_add_active(struct page *page)
/**
* lru_cache_add_lru - add a page to a page list
* @page: the page to be added to the LRU.
* @lru: the LRU list to which the page is added.
*/
void lru_cache_add_lru(struct page *page, enum lru_list lru)
{
struct pagevec *pvec = &get_cpu_var(lru_add_active_pvecs);
if (PageActive(page)) {
ClearPageActive(page);
}

page_cache_get(page);
if (!pagevec_add(pvec, page))
__pagevec_lru_add_active(pvec);
put_cpu_var(lru_add_active_pvecs);
VM_BUG_ON(PageLRU(page) || PageActive(page));
__lru_cache_add(page, lru);
}

/*
Expand All @@ -217,15 +217,15 @@ void lru_cache_add_active(struct page *page)
*/
static void drain_cpu_pagevecs(int cpu)
{
struct pagevec *pvecs = per_cpu(lru_add_pvecs, cpu);
struct pagevec *pvec;
int lru;

pvec = &per_cpu(lru_add_pvecs, cpu);
if (pagevec_count(pvec))
__pagevec_lru_add(pvec);

pvec = &per_cpu(lru_add_active_pvecs, cpu);
if (pagevec_count(pvec))
__pagevec_lru_add_active(pvec);
for_each_lru(lru) {
pvec = &pvecs[lru - LRU_BASE];
if (pagevec_count(pvec))
____pagevec_lru_add(pvec, lru);
}

pvec = &per_cpu(lru_rotate_pvecs, cpu);
if (pagevec_count(pvec)) {
Expand Down Expand Up @@ -380,7 +380,7 @@ void __pagevec_release_nonlru(struct pagevec *pvec)
* Add the passed pages to the LRU, then drop the caller's refcount
* on them. Reinitialises the caller's pagevec.
*/
void __pagevec_lru_add(struct pagevec *pvec)
void ____pagevec_lru_add(struct pagevec *pvec, enum lru_list lru)
{
int i;
struct zone *zone = NULL;
Expand All @@ -397,42 +397,17 @@ void __pagevec_lru_add(struct pagevec *pvec)
}
VM_BUG_ON(PageLRU(page));
SetPageLRU(page);
add_page_to_inactive_list(zone, page);
if (is_active_lru(lru))
SetPageActive(page);
add_page_to_lru_list(zone, page, lru);
}
if (zone)
spin_unlock_irq(&zone->lru_lock);
release_pages(pvec->pages, pvec->nr, pvec->cold);
pagevec_reinit(pvec);
}

EXPORT_SYMBOL(__pagevec_lru_add);

void __pagevec_lru_add_active(struct pagevec *pvec)
{
int i;
struct zone *zone = NULL;

for (i = 0; i < pagevec_count(pvec); i++) {
struct page *page = pvec->pages[i];
struct zone *pagezone = page_zone(page);

if (pagezone != zone) {
if (zone)
spin_unlock_irq(&zone->lru_lock);
zone = pagezone;
spin_lock_irq(&zone->lru_lock);
}
VM_BUG_ON(PageLRU(page));
SetPageLRU(page);
VM_BUG_ON(PageActive(page));
SetPageActive(page);
add_page_to_active_list(zone, page);
}
if (zone)
spin_unlock_irq(&zone->lru_lock);
release_pages(pvec->pages, pvec->nr, pvec->cold);
pagevec_reinit(pvec);
}
EXPORT_SYMBOL(____pagevec_lru_add);

/*
* Try to drop buffers from the pages in a pagevec
Expand Down

0 comments on commit 1bf63b7

Please sign in to comment.