* [PATCH 0/6] mm: trivial cleanups
@ 2012-01-01 7:39 Hugh Dickins
2012-01-01 7:41 ` [PATCH 1/6] mm: fewer underscores in ____pagevec_lru_add Hugh Dickins
` (5 more replies)
0 siblings, 6 replies; 12+ messages in thread
From: Hugh Dickins @ 2012-01-01 7:39 UTC (permalink / raw)
To: Andrew Morton; +Cc: Johannes Weiner, KOSAKI Motohiro, linux-mm
Six trivial cleanups to some mm files, mainly swap.c and vmscan.c.
The last less trivial than the others, renaming putback_lru_pages and
rearranging a little of the stats updating. That one does assume my
"mm: take pagevecs off reclaim stack" is still in mmotm/next: should
be easy to settle its lock-hold-time if that's still a worry.
(I did have a patch to factor isolate_lumpy_pages out of isolate_lru_pages;
but lumpy remains a battleground of frequent little fixups, so I think it
will be easier for everyone if I leave it as is for now, and cope with
the deep indentation later on.)
[PATCH 1/6] mm: fewer underscores in ____pagevec_lru_add
[PATCH 2/6] mm: no blank line after EXPORT_SYMBOL in swap.c
[PATCH 3/6] mm: enum lru_list lru
[PATCH 4/6] mm: remove del_page_from_lru, add page_off_lru
[PATCH 5/6] mm: remove isolate_pages
[PATCH 6/6] mm: rearrange putback_inactive_pages
include/linux/mm_inline.h | 37 ++++---
include/linux/mmzone.h | 16 +--
include/linux/pagevec.h | 10 +-
mm/page_alloc.c | 6 -
mm/swap.c | 21 +---
mm/vmscan.c | 179 ++++++++++++++++--------------------
6 files changed, 126 insertions(+), 143 deletions(-)
Hugh
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 1/6] mm: fewer underscores in ____pagevec_lru_add
2012-01-01 7:39 [PATCH 0/6] mm: trivial cleanups Hugh Dickins
@ 2012-01-01 7:41 ` Hugh Dickins
2012-01-01 8:17 ` KOSAKI Motohiro
2012-01-01 7:42 ` [PATCH 2/6] mm: no blank line after EXPORT_SYMBOL in swap.c Hugh Dickins
` (4 subsequent siblings)
5 siblings, 1 reply; 12+ messages in thread
From: Hugh Dickins @ 2012-01-01 7:41 UTC (permalink / raw)
To: Andrew Morton; +Cc: Johannes Weiner, KOSAKI Motohiro, linux-mm
What's so special about ____pagevec_lru_add() that it needs four
leading underscores? Nothing, it just helped to distinguish from
__pagevec_lru_add() in 2.6.28 development. Cut two leading underscores.
Signed-off-by: Hugh Dickins <hughd@google.com>
---
include/linux/pagevec.h | 10 +++++-----
mm/swap.c | 12 ++++++------
2 files changed, 11 insertions(+), 11 deletions(-)
--- mmotm.orig/include/linux/pagevec.h 2011-12-30 21:21:34.735338589 -0800
+++ mmotm/include/linux/pagevec.h 2011-12-30 21:29:45.671350259 -0800
@@ -21,7 +21,7 @@ struct pagevec {
};
void __pagevec_release(struct pagevec *pvec);
-void ____pagevec_lru_add(struct pagevec *pvec, enum lru_list lru);
+void __pagevec_lru_add(struct pagevec *pvec, enum lru_list lru);
unsigned pagevec_lookup(struct pagevec *pvec, struct address_space *mapping,
pgoff_t start, unsigned nr_pages);
unsigned pagevec_lookup_tag(struct pagevec *pvec,
@@ -66,22 +66,22 @@ static inline void pagevec_release(struc
static inline void __pagevec_lru_add_anon(struct pagevec *pvec)
{
- ____pagevec_lru_add(pvec, LRU_INACTIVE_ANON);
+ __pagevec_lru_add(pvec, LRU_INACTIVE_ANON);
}
static inline void __pagevec_lru_add_active_anon(struct pagevec *pvec)
{
- ____pagevec_lru_add(pvec, LRU_ACTIVE_ANON);
+ __pagevec_lru_add(pvec, LRU_ACTIVE_ANON);
}
static inline void __pagevec_lru_add_file(struct pagevec *pvec)
{
- ____pagevec_lru_add(pvec, LRU_INACTIVE_FILE);
+ __pagevec_lru_add(pvec, LRU_INACTIVE_FILE);
}
static inline void __pagevec_lru_add_active_file(struct pagevec *pvec)
{
- ____pagevec_lru_add(pvec, LRU_ACTIVE_FILE);
+ __pagevec_lru_add(pvec, LRU_ACTIVE_FILE);
}
static inline void pagevec_lru_add_file(struct pagevec *pvec)
--- mmotm.orig/mm/swap.c 2011-12-30 21:21:34.735338589 -0800
+++ mmotm/mm/swap.c 2011-12-30 21:29:45.675350259 -0800
@@ -378,7 +378,7 @@ void __lru_cache_add(struct page *page,
page_cache_get(page);
if (!pagevec_add(pvec, page))
- ____pagevec_lru_add(pvec, lru);
+ __pagevec_lru_add(pvec, lru);
put_cpu_var(lru_add_pvecs);
}
EXPORT_SYMBOL(__lru_cache_add);
@@ -506,7 +506,7 @@ static void drain_cpu_pagevecs(int cpu)
for_each_lru(lru) {
pvec = &pvecs[lru - LRU_BASE];
if (pagevec_count(pvec))
- ____pagevec_lru_add(pvec, lru);
+ __pagevec_lru_add(pvec, lru);
}
pvec = &per_cpu(lru_rotate_pvecs, cpu);
@@ -698,7 +698,7 @@ void lru_add_page_tail(struct zone* zone
}
#endif /* CONFIG_TRANSPARENT_HUGEPAGE */
-static void ____pagevec_lru_add_fn(struct page *page, void *arg)
+static void __pagevec_lru_add_fn(struct page *page, void *arg)
{
enum lru_list lru = (enum lru_list)arg;
struct zone *zone = page_zone(page);
@@ -720,14 +720,14 @@ static void ____pagevec_lru_add_fn(struc
* 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, enum lru_list lru)
+void __pagevec_lru_add(struct pagevec *pvec, enum lru_list lru)
{
VM_BUG_ON(is_unevictable_lru(lru));
- pagevec_lru_move_fn(pvec, ____pagevec_lru_add_fn, (void *)lru);
+ pagevec_lru_move_fn(pvec, __pagevec_lru_add_fn, (void *)lru);
}
-EXPORT_SYMBOL(____pagevec_lru_add);
+EXPORT_SYMBOL(__pagevec_lru_add);
/**
* pagevec_lookup - gang pagecache lookup
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 2/6] mm: no blank line after EXPORT_SYMBOL in swap.c
2012-01-01 7:39 [PATCH 0/6] mm: trivial cleanups Hugh Dickins
2012-01-01 7:41 ` [PATCH 1/6] mm: fewer underscores in ____pagevec_lru_add Hugh Dickins
@ 2012-01-01 7:42 ` Hugh Dickins
2012-01-01 8:18 ` KOSAKI Motohiro
2012-01-01 7:43 ` [PATCH 3/6] mm: enum lru_list lru Hugh Dickins
` (3 subsequent siblings)
5 siblings, 1 reply; 12+ messages in thread
From: Hugh Dickins @ 2012-01-01 7:42 UTC (permalink / raw)
To: Andrew Morton; +Cc: Johannes Weiner, KOSAKI Motohiro, linux-mm
checkpatch rightly protests
WARNING: EXPORT_SYMBOL(foo); should immediately follow its function/variable
so fix the five offenders in mm/swap.c.
Signed-off-by: Hugh Dickins <hughd@google.com>
---
mm/swap.c | 5 -----
1 file changed, 5 deletions(-)
--- mmotm.orig/mm/swap.c 2011-12-30 21:29:45.675350259 -0800
+++ mmotm/mm/swap.c 2011-12-30 21:29:54.415350465 -0800
@@ -369,7 +369,6 @@ void mark_page_accessed(struct page *pag
SetPageReferenced(page);
}
}
-
EXPORT_SYMBOL(mark_page_accessed);
void __lru_cache_add(struct page *page, enum lru_list lru)
@@ -646,7 +645,6 @@ void __pagevec_release(struct pagevec *p
release_pages(pvec->pages, pagevec_count(pvec), pvec->cold);
pagevec_reinit(pvec);
}
-
EXPORT_SYMBOL(__pagevec_release);
#ifdef CONFIG_TRANSPARENT_HUGEPAGE
@@ -726,7 +724,6 @@ void __pagevec_lru_add(struct pagevec *p
pagevec_lru_move_fn(pvec, __pagevec_lru_add_fn, (void *)lru);
}
-
EXPORT_SYMBOL(__pagevec_lru_add);
/**
@@ -751,7 +748,6 @@ unsigned pagevec_lookup(struct pagevec *
pvec->nr = find_get_pages(mapping, start, nr_pages, pvec->pages);
return pagevec_count(pvec);
}
-
EXPORT_SYMBOL(pagevec_lookup);
unsigned pagevec_lookup_tag(struct pagevec *pvec, struct address_space *mapping,
@@ -761,7 +757,6 @@ unsigned pagevec_lookup_tag(struct pagev
nr_pages, pvec->pages);
return pagevec_count(pvec);
}
-
EXPORT_SYMBOL(pagevec_lookup_tag);
/*
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 3/6] mm: enum lru_list lru
2012-01-01 7:39 [PATCH 0/6] mm: trivial cleanups Hugh Dickins
2012-01-01 7:41 ` [PATCH 1/6] mm: fewer underscores in ____pagevec_lru_add Hugh Dickins
2012-01-01 7:42 ` [PATCH 2/6] mm: no blank line after EXPORT_SYMBOL in swap.c Hugh Dickins
@ 2012-01-01 7:43 ` Hugh Dickins
2012-01-01 8:19 ` KOSAKI Motohiro
2012-01-01 7:45 ` [PATCH 4/6] mm: remove del_page_from_lru, add page_off_lru Hugh Dickins
` (2 subsequent siblings)
5 siblings, 1 reply; 12+ messages in thread
From: Hugh Dickins @ 2012-01-01 7:43 UTC (permalink / raw)
To: Andrew Morton; +Cc: Johannes Weiner, KOSAKI Motohiro, linux-mm
Mostly we use "enum lru_list lru": change those few "l"s to "lru"s.
Signed-off-by: Hugh Dickins <hughd@google.com>
---
include/linux/mm_inline.h | 26 +++++++++++++-------------
include/linux/mmzone.h | 16 ++++++++--------
mm/page_alloc.c | 6 +++---
mm/vmscan.c | 22 +++++++++++-----------
4 files changed, 35 insertions(+), 35 deletions(-)
--- mmotm.orig/include/linux/mm_inline.h 2011-12-30 21:21:34.531338585 -0800
+++ mmotm/include/linux/mm_inline.h 2011-12-31 14:49:11.044022084 -0800
@@ -22,21 +22,21 @@ static inline int page_is_file_cache(str
}
static inline void
-add_page_to_lru_list(struct zone *zone, struct page *page, enum lru_list l)
+add_page_to_lru_list(struct zone *zone, struct page *page, enum lru_list lru)
{
struct lruvec *lruvec;
- lruvec = mem_cgroup_lru_add_list(zone, page, l);
- list_add(&page->lru, &lruvec->lists[l]);
- __mod_zone_page_state(zone, NR_LRU_BASE + l, hpage_nr_pages(page));
+ lruvec = mem_cgroup_lru_add_list(zone, page, lru);
+ list_add(&page->lru, &lruvec->lists[lru]);
+ __mod_zone_page_state(zone, NR_LRU_BASE + lru, hpage_nr_pages(page));
}
static inline void
-del_page_from_lru_list(struct zone *zone, struct page *page, enum lru_list l)
+del_page_from_lru_list(struct zone *zone, struct page *page, enum lru_list lru)
{
- mem_cgroup_lru_del_list(page, l);
+ mem_cgroup_lru_del_list(page, lru);
list_del(&page->lru);
- __mod_zone_page_state(zone, NR_LRU_BASE + l, -hpage_nr_pages(page));
+ __mod_zone_page_state(zone, NR_LRU_BASE + lru, -hpage_nr_pages(page));
}
/**
@@ -57,21 +57,21 @@ static inline enum lru_list page_lru_bas
static inline void
del_page_from_lru(struct zone *zone, struct page *page)
{
- enum lru_list l;
+ enum lru_list lru;
if (PageUnevictable(page)) {
__ClearPageUnevictable(page);
- l = LRU_UNEVICTABLE;
+ lru = LRU_UNEVICTABLE;
} else {
- l = page_lru_base_type(page);
+ lru = page_lru_base_type(page);
if (PageActive(page)) {
__ClearPageActive(page);
- l += LRU_ACTIVE;
+ lru += LRU_ACTIVE;
}
}
- mem_cgroup_lru_del_list(page, l);
+ mem_cgroup_lru_del_list(page, lru);
list_del(&page->lru);
- __mod_zone_page_state(zone, NR_LRU_BASE + l, -hpage_nr_pages(page));
+ __mod_zone_page_state(zone, NR_LRU_BASE + lru, -hpage_nr_pages(page));
}
/**
--- mmotm.orig/include/linux/mmzone.h 2011-12-30 21:21:34.531338585 -0800
+++ mmotm/include/linux/mmzone.h 2011-12-31 14:49:11.044022084 -0800
@@ -140,23 +140,23 @@ enum lru_list {
NR_LRU_LISTS
};
-#define for_each_lru(l) for (l = 0; l < NR_LRU_LISTS; l++)
+#define for_each_lru(lru) for (lru = 0; lru < NR_LRU_LISTS; lru++)
-#define for_each_evictable_lru(l) for (l = 0; l <= LRU_ACTIVE_FILE; l++)
+#define for_each_evictable_lru(lru) for (lru = 0; lru <= LRU_ACTIVE_FILE; lru++)
-static inline int is_file_lru(enum lru_list l)
+static inline int is_file_lru(enum lru_list lru)
{
- return (l == LRU_INACTIVE_FILE || l == LRU_ACTIVE_FILE);
+ return (lru == LRU_INACTIVE_FILE || lru == LRU_ACTIVE_FILE);
}
-static inline int is_active_lru(enum lru_list l)
+static inline int is_active_lru(enum lru_list lru)
{
- return (l == LRU_ACTIVE_ANON || l == LRU_ACTIVE_FILE);
+ return (lru == LRU_ACTIVE_ANON || lru == LRU_ACTIVE_FILE);
}
-static inline int is_unevictable_lru(enum lru_list l)
+static inline int is_unevictable_lru(enum lru_list lru)
{
- return (l == LRU_UNEVICTABLE);
+ return (lru == LRU_UNEVICTABLE);
}
struct lruvec {
--- mmotm.orig/mm/page_alloc.c 2011-12-30 21:21:34.531338585 -0800
+++ mmotm/mm/page_alloc.c 2011-12-31 14:49:11.048022293 -0800
@@ -4275,7 +4275,7 @@ static void __paginginit free_area_init_
for (j = 0; j < MAX_NR_ZONES; j++) {
struct zone *zone = pgdat->node_zones + j;
unsigned long size, realsize, memmap_pages;
- enum lru_list l;
+ enum lru_list lru;
size = zone_spanned_pages_in_node(nid, j, zones_size);
realsize = size - zone_absent_pages_in_node(nid, j,
@@ -4325,8 +4325,8 @@ static void __paginginit free_area_init_
zone->zone_pgdat = pgdat;
zone_pcp_init(zone);
- for_each_lru(l)
- INIT_LIST_HEAD(&zone->lruvec.lists[l]);
+ for_each_lru(lru)
+ INIT_LIST_HEAD(&zone->lruvec.lists[lru]);
zone->reclaim_stat.recent_rotated[0] = 0;
zone->reclaim_stat.recent_rotated[1] = 0;
zone->reclaim_stat.recent_scanned[0] = 0;
--- mmotm.orig/mm/vmscan.c 2011-12-31 14:36:24.704004318 -0800
+++ mmotm/mm/vmscan.c 2011-12-31 14:49:11.048022293 -0800
@@ -1920,7 +1920,7 @@ static void get_scan_count(struct mem_cg
unsigned long ap, fp;
struct zone_reclaim_stat *reclaim_stat = get_reclaim_stat(mz);
u64 fraction[2], denominator;
- enum lru_list l;
+ enum lru_list lru;
int noswap = 0;
bool force_scan = false;
@@ -2010,18 +2010,18 @@ static void get_scan_count(struct mem_cg
fraction[1] = fp;
denominator = ap + fp + 1;
out:
- for_each_evictable_lru(l) {
- int file = is_file_lru(l);
+ for_each_evictable_lru(lru) {
+ int file = is_file_lru(lru);
unsigned long scan;
- scan = zone_nr_lru_pages(mz, l);
+ scan = zone_nr_lru_pages(mz, lru);
if (priority || noswap) {
scan >>= priority;
if (!scan && force_scan)
scan = SWAP_CLUSTER_MAX;
scan = div64_u64(scan * fraction[file], denominator);
}
- nr[l] = scan;
+ nr[lru] = scan;
}
}
@@ -2097,7 +2097,7 @@ static void shrink_mem_cgroup_zone(int p
{
unsigned long nr[NR_LRU_LISTS];
unsigned long nr_to_scan;
- enum lru_list l;
+ enum lru_list lru;
unsigned long nr_reclaimed, nr_scanned;
unsigned long nr_to_reclaim = sc->nr_to_reclaim;
struct blk_plug plug;
@@ -2110,13 +2110,13 @@ restart:
blk_start_plug(&plug);
while (nr[LRU_INACTIVE_ANON] || nr[LRU_ACTIVE_FILE] ||
nr[LRU_INACTIVE_FILE]) {
- for_each_evictable_lru(l) {
- if (nr[l]) {
+ for_each_evictable_lru(lru) {
+ if (nr[lru]) {
nr_to_scan = min_t(unsigned long,
- nr[l], SWAP_CLUSTER_MAX);
- nr[l] -= nr_to_scan;
+ nr[lru], SWAP_CLUSTER_MAX);
+ nr[lru] -= nr_to_scan;
- nr_reclaimed += shrink_list(l, nr_to_scan,
+ nr_reclaimed += shrink_list(lru, nr_to_scan,
mz, sc, priority);
}
}
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 4/6] mm: remove del_page_from_lru, add page_off_lru
2012-01-01 7:39 [PATCH 0/6] mm: trivial cleanups Hugh Dickins
` (2 preceding siblings ...)
2012-01-01 7:43 ` [PATCH 3/6] mm: enum lru_list lru Hugh Dickins
@ 2012-01-01 7:45 ` Hugh Dickins
2012-01-01 8:22 ` KOSAKI Motohiro
2012-01-01 7:46 ` [PATCH 5/6] mm: remove isolate_pages Hugh Dickins
2012-01-01 7:48 ` [PATCH 6/6] mm: rearrange putback_inactive_pages Hugh Dickins
5 siblings, 1 reply; 12+ messages in thread
From: Hugh Dickins @ 2012-01-01 7:45 UTC (permalink / raw)
To: Andrew Morton; +Cc: Johannes Weiner, KOSAKI Motohiro, linux-mm
del_page_from_lru() repeats del_page_from_lru_list(), also working out
which LRU the page was on, clearing the relevant bits. Decouple those
functions: remove del_page_from_lru() and add page_off_lru().
Signed-off-by: Hugh Dickins <hughd@google.com>
---
include/linux/mm_inline.h | 15 +++++++++------
mm/swap.c | 4 ++--
2 files changed, 11 insertions(+), 8 deletions(-)
--- mmotm.orig/include/linux/mm_inline.h 2011-12-31 14:49:11.044022084 -0800
+++ mmotm/include/linux/mm_inline.h 2011-12-31 14:55:00.860030864 -0800
@@ -54,8 +54,14 @@ static inline enum lru_list page_lru_bas
return LRU_INACTIVE_ANON;
}
-static inline void
-del_page_from_lru(struct zone *zone, struct page *page)
+/**
+ * page_off_lru - which LRU list was page on? clearing its lru flags.
+ * @page: the page to test
+ *
+ * Returns the LRU list a page was on, as an index into the array of LRU
+ * lists; and clears its Unevictable or Active flags, ready for freeing.
+ */
+static inline enum lru_list page_off_lru(struct page *page)
{
enum lru_list lru;
@@ -69,9 +75,7 @@ del_page_from_lru(struct zone *zone, str
lru += LRU_ACTIVE;
}
}
- mem_cgroup_lru_del_list(page, lru);
- list_del(&page->lru);
- __mod_zone_page_state(zone, NR_LRU_BASE + lru, -hpage_nr_pages(page));
+ return lru;
}
/**
@@ -92,7 +96,6 @@ static inline enum lru_list page_lru(str
if (PageActive(page))
lru += LRU_ACTIVE;
}
-
return lru;
}
--- mmotm.orig/mm/swap.c 2011-12-30 21:29:54.415350465 -0800
+++ mmotm/mm/swap.c 2011-12-31 14:55:00.860030864 -0800
@@ -53,7 +53,7 @@ static void __page_cache_release(struct
spin_lock_irqsave(&zone->lru_lock, flags);
VM_BUG_ON(!PageLRU(page));
__ClearPageLRU(page);
- del_page_from_lru(zone, page);
+ del_page_from_lru_list(zone, page, page_off_lru(page));
spin_unlock_irqrestore(&zone->lru_lock, flags);
}
}
@@ -617,7 +617,7 @@ void release_pages(struct page **pages,
}
VM_BUG_ON(!PageLRU(page));
__ClearPageLRU(page);
- del_page_from_lru(zone, page);
+ del_page_from_lru_list(zone, page, page_off_lru(page));
}
list_add(&page->lru, &pages_to_free);
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 5/6] mm: remove isolate_pages
2012-01-01 7:39 [PATCH 0/6] mm: trivial cleanups Hugh Dickins
` (3 preceding siblings ...)
2012-01-01 7:45 ` [PATCH 4/6] mm: remove del_page_from_lru, add page_off_lru Hugh Dickins
@ 2012-01-01 7:46 ` Hugh Dickins
2012-01-01 9:36 ` KOSAKI Motohiro
2012-01-01 7:48 ` [PATCH 6/6] mm: rearrange putback_inactive_pages Hugh Dickins
5 siblings, 1 reply; 12+ messages in thread
From: Hugh Dickins @ 2012-01-01 7:46 UTC (permalink / raw)
To: Andrew Morton; +Cc: Johannes Weiner, KOSAKI Motohiro, linux-mm
The isolate_pages() level in vmscan.c offers little but indirection:
merge it into isolate_lru_pages() as the compiler does, and use the
names nr_to_scan and nr_scanned in each case.
Signed-off-by: Hugh Dickins <hughd@google.com>
---
mm/vmscan.c | 61 ++++++++++++++++++++++----------------------------
1 file changed, 27 insertions(+), 34 deletions(-)
--- mmotm.orig/mm/vmscan.c 2011-12-30 21:21:34.651338587 -0800
+++ mmotm/mm/vmscan.c 2011-12-30 21:30:02.315350653 -0800
@@ -1136,25 +1136,36 @@ int __isolate_lru_page(struct page *page
* Appropriate locks must be held before calling this function.
*
* @nr_to_scan: The number of pages to look through on the list.
- * @src: The LRU list to pull pages off.
+ * @mz: The mem_cgroup_zone to pull pages from.
* @dst: The temp list to put pages on to.
- * @scanned: The number of pages that were scanned.
+ * @nr_scanned: The number of pages that were scanned.
* @order: The caller's attempted allocation order
* @mode: One of the LRU isolation modes
+ * @active: True [1] if isolating active pages
* @file: True [1] if isolating file [!anon] pages
*
* returns how many pages were moved onto *@dst.
*/
static unsigned long isolate_lru_pages(unsigned long nr_to_scan,
- struct list_head *src, struct list_head *dst,
- unsigned long *scanned, int order, isolate_mode_t mode,
- int file)
+ struct mem_cgroup_zone *mz, struct list_head *dst,
+ unsigned long *nr_scanned, int order, isolate_mode_t mode,
+ int active, int file)
{
+ struct lruvec *lruvec;
+ struct list_head *src;
unsigned long nr_taken = 0;
unsigned long nr_lumpy_taken = 0;
unsigned long nr_lumpy_dirty = 0;
unsigned long nr_lumpy_failed = 0;
unsigned long scan;
+ int lru = LRU_BASE;
+
+ lruvec = mem_cgroup_zone_lruvec(mz->zone, mz->mem_cgroup);
+ if (active)
+ lru += LRU_ACTIVE;
+ if (file)
+ lru += LRU_FILE;
+ src = &lruvec->lists[lru];
for (scan = 0; scan < nr_to_scan && !list_empty(src); scan++) {
struct page *page;
@@ -1263,7 +1274,7 @@ static unsigned long isolate_lru_pages(u
nr_lumpy_failed++;
}
- *scanned = scan;
+ *nr_scanned = scan;
trace_mm_vmscan_lru_isolate(order,
nr_to_scan, scan,
@@ -1273,23 +1284,6 @@ static unsigned long isolate_lru_pages(u
return nr_taken;
}
-static unsigned long isolate_pages(unsigned long nr, struct mem_cgroup_zone *mz,
- struct list_head *dst,
- unsigned long *scanned, int order,
- isolate_mode_t mode, int active, int file)
-{
- struct lruvec *lruvec;
- int lru = LRU_BASE;
-
- lruvec = mem_cgroup_zone_lruvec(mz->zone, mz->mem_cgroup);
- if (active)
- lru += LRU_ACTIVE;
- if (file)
- lru += LRU_FILE;
- return isolate_lru_pages(nr, &lruvec->lists[lru], dst,
- scanned, order, mode, file);
-}
-
/*
* clear_active_flags() is a helper for shrink_active_list(), clearing
* any active bits from the pages in the list.
@@ -1559,9 +1553,9 @@ shrink_inactive_list(unsigned long nr_to
spin_lock_irq(&zone->lru_lock);
- nr_taken = isolate_pages(nr_to_scan, mz, &page_list,
- &nr_scanned, sc->order,
- reclaim_mode, 0, file);
+ nr_taken = isolate_lru_pages(nr_to_scan, mz, &page_list,
+ &nr_scanned, sc->order,
+ reclaim_mode, 0, file);
if (global_reclaim(sc)) {
zone->pages_scanned += nr_scanned;
if (current_is_kswapd())
@@ -1700,13 +1694,13 @@ static void move_active_pages_to_lru(str
__count_vm_events(PGDEACTIVATE, pgmoved);
}
-static void shrink_active_list(unsigned long nr_pages,
+static void shrink_active_list(unsigned long nr_to_scan,
struct mem_cgroup_zone *mz,
struct scan_control *sc,
int priority, int file)
{
unsigned long nr_taken;
- unsigned long pgscanned;
+ unsigned long nr_scanned;
unsigned long vm_flags;
LIST_HEAD(l_hold); /* The pages which were snipped off */
LIST_HEAD(l_active);
@@ -1726,16 +1720,15 @@ static void shrink_active_list(unsigned
spin_lock_irq(&zone->lru_lock);
- nr_taken = isolate_pages(nr_pages, mz, &l_hold,
- &pgscanned, sc->order,
- reclaim_mode, 1, file);
-
+ nr_taken = isolate_lru_pages(nr_to_scan, mz, &l_hold,
+ &nr_scanned, sc->order,
+ reclaim_mode, 1, file);
if (global_reclaim(sc))
- zone->pages_scanned += pgscanned;
+ zone->pages_scanned += nr_scanned;
reclaim_stat->recent_scanned[file] += nr_taken;
- __count_zone_vm_events(PGREFILL, zone, pgscanned);
+ __count_zone_vm_events(PGREFILL, zone, nr_scanned);
if (file)
__mod_zone_page_state(zone, NR_ACTIVE_FILE, -nr_taken);
else
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 6/6] mm: rearrange putback_inactive_pages
2012-01-01 7:39 [PATCH 0/6] mm: trivial cleanups Hugh Dickins
` (4 preceding siblings ...)
2012-01-01 7:46 ` [PATCH 5/6] mm: remove isolate_pages Hugh Dickins
@ 2012-01-01 7:48 ` Hugh Dickins
5 siblings, 0 replies; 12+ messages in thread
From: Hugh Dickins @ 2012-01-01 7:48 UTC (permalink / raw)
To: Andrew Morton; +Cc: Johannes Weiner, KOSAKI Motohiro, linux-mm
There is sometimes confusion between the global putback_lru_pages()
in migrate.c and the static putback_lru_pages() in vmscan.c: rename
the latter putback_inactive_pages(): it helps shrink_inactive_list()
rather as move_active_pages_to_lru() helps shrink_active_list().
Remove unused scan_control arg from putback_inactive_pages() and
from update_isolated_counts(). Move clear_active_flags() inside
update_isolated_counts(). Move NR_ISOLATED accounting up into
shrink_inactive_list() itself, so the balance is clearer.
Do the spin_lock_irq() before calling putback_inactive_pages() and
spin_unlock_irq() after return from it, so that it better matches
update_isolated_counts() and move_active_pages_to_lru().
Signed-off-by: Hugh Dickins <hughd@google.com>
---
mm/vmscan.c | 96 ++++++++++++++++++++++----------------------------
1 file changed, 44 insertions(+), 52 deletions(-)
--- mmotm.orig/mm/vmscan.c 2011-12-31 14:58:45.680036183 -0800
+++ mmotm/mm/vmscan.c 2011-12-31 17:26:25.264246809 -0800
@@ -1284,32 +1284,6 @@ static unsigned long isolate_lru_pages(u
return nr_taken;
}
-/*
- * clear_active_flags() is a helper for shrink_active_list(), clearing
- * any active bits from the pages in the list.
- */
-static unsigned long clear_active_flags(struct list_head *page_list,
- unsigned int *count)
-{
- int nr_active = 0;
- int lru;
- struct page *page;
-
- list_for_each_entry(page, page_list, lru) {
- int numpages = hpage_nr_pages(page);
- lru = page_lru_base_type(page);
- if (PageActive(page)) {
- lru += LRU_ACTIVE;
- ClearPageActive(page);
- nr_active += numpages;
- }
- if (count)
- count[lru] += numpages;
- }
-
- return nr_active;
-}
-
/**
* isolate_lru_page - tries to isolate a page from its LRU list
* @page: page to isolate from its LRU list
@@ -1383,26 +1357,21 @@ static int too_many_isolated(struct zone
return isolated > inactive;
}
-/*
- * TODO: Try merging with migrations version of putback_lru_pages
- */
static noinline_for_stack void
-putback_lru_pages(struct mem_cgroup_zone *mz, struct scan_control *sc,
- unsigned long nr_anon, unsigned long nr_file,
- struct list_head *page_list)
+putback_inactive_pages(struct mem_cgroup_zone *mz,
+ struct list_head *page_list)
{
- struct page *page;
- LIST_HEAD(pages_to_free);
- struct zone *zone = mz->zone;
struct zone_reclaim_stat *reclaim_stat = get_reclaim_stat(mz);
+ struct zone *zone = mz->zone;
+ LIST_HEAD(pages_to_free);
/*
* Put back any unfreeable pages.
*/
- spin_lock(&zone->lru_lock);
while (!list_empty(page_list)) {
+ struct page *page = lru_to_page(page_list);
int lru;
- page = lru_to_page(page_list);
+
VM_BUG_ON(PageLRU(page));
list_del(&page->lru);
if (unlikely(!page_evictable(page, NULL))) {
@@ -1432,26 +1401,40 @@ putback_lru_pages(struct mem_cgroup_zone
list_add(&page->lru, &pages_to_free);
}
}
- __mod_zone_page_state(zone, NR_ISOLATED_ANON, -nr_anon);
- __mod_zone_page_state(zone, NR_ISOLATED_FILE, -nr_file);
- spin_unlock_irq(&zone->lru_lock);
- free_hot_cold_page_list(&pages_to_free, 1);
+ /*
+ * To save our caller's stack, now use input list for pages to free.
+ */
+ list_splice(&pages_to_free, page_list);
}
static noinline_for_stack void
update_isolated_counts(struct mem_cgroup_zone *mz,
- struct scan_control *sc,
+ struct list_head *page_list,
unsigned long *nr_anon,
- unsigned long *nr_file,
- struct list_head *isolated_list)
+ unsigned long *nr_file)
{
- unsigned long nr_active;
+ struct zone_reclaim_stat *reclaim_stat = get_reclaim_stat(mz);
struct zone *zone = mz->zone;
unsigned int count[NR_LRU_LISTS] = { 0, };
- struct zone_reclaim_stat *reclaim_stat = get_reclaim_stat(mz);
+ unsigned long nr_active = 0;
+ struct page *page;
+ int lru;
+
+ /*
+ * Count pages and clear active flags
+ */
+ list_for_each_entry(page, page_list, lru) {
+ int numpages = hpage_nr_pages(page);
+ lru = page_lru_base_type(page);
+ if (PageActive(page)) {
+ lru += LRU_ACTIVE;
+ ClearPageActive(page);
+ nr_active += numpages;
+ }
+ count[lru] += numpages;
+ }
- nr_active = clear_active_flags(isolated_list, count);
__count_vm_events(PGDEACTIVATE, nr_active);
__mod_zone_page_state(zone, NR_ACTIVE_FILE,
@@ -1465,8 +1448,6 @@ update_isolated_counts(struct mem_cgroup
*nr_anon = count[LRU_ACTIVE_ANON] + count[LRU_INACTIVE_ANON];
*nr_file = count[LRU_ACTIVE_FILE] + count[LRU_INACTIVE_FILE];
- __mod_zone_page_state(zone, NR_ISOLATED_ANON, *nr_anon);
- __mod_zone_page_state(zone, NR_ISOLATED_FILE, *nr_file);
reclaim_stat->recent_scanned[0] += *nr_anon;
reclaim_stat->recent_scanned[1] += *nr_file;
@@ -1571,7 +1552,10 @@ shrink_inactive_list(unsigned long nr_to
return 0;
}
- update_isolated_counts(mz, sc, &nr_anon, &nr_file, &page_list);
+ update_isolated_counts(mz, &page_list, &nr_anon, &nr_file);
+
+ __mod_zone_page_state(zone, NR_ISOLATED_ANON, nr_anon);
+ __mod_zone_page_state(zone, NR_ISOLATED_FILE, nr_file);
spin_unlock_irq(&zone->lru_lock);
@@ -1585,12 +1569,20 @@ shrink_inactive_list(unsigned long nr_to
priority, &nr_dirty, &nr_writeback);
}
- local_irq_disable();
+ spin_lock_irq(&zone->lru_lock);
+
if (current_is_kswapd())
__count_vm_events(KSWAPD_STEAL, nr_reclaimed);
__count_zone_vm_events(PGSTEAL, zone, nr_reclaimed);
- putback_lru_pages(mz, sc, nr_anon, nr_file, &page_list);
+ putback_inactive_pages(mz, &page_list);
+
+ __mod_zone_page_state(zone, NR_ISOLATED_ANON, -nr_anon);
+ __mod_zone_page_state(zone, NR_ISOLATED_FILE, -nr_file);
+
+ spin_unlock_irq(&zone->lru_lock);
+
+ free_hot_cold_page_list(&page_list, 1);
/*
* If reclaim is isolating dirty pages under writeback, it implies
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 1/6] mm: fewer underscores in ____pagevec_lru_add
2012-01-01 7:41 ` [PATCH 1/6] mm: fewer underscores in ____pagevec_lru_add Hugh Dickins
@ 2012-01-01 8:17 ` KOSAKI Motohiro
0 siblings, 0 replies; 12+ messages in thread
From: KOSAKI Motohiro @ 2012-01-01 8:17 UTC (permalink / raw)
To: Hugh Dickins; +Cc: Andrew Morton, Johannes Weiner, linux-mm
(1/1/12 2:41 AM), Hugh Dickins wrote:
> What's so special about ____pagevec_lru_add() that it needs four
> leading underscores? Nothing, it just helped to distinguish from
> __pagevec_lru_add() in 2.6.28 development. Cut two leading underscores.
>
> Signed-off-by: Hugh Dickins<hughd@google.com>
Yes, this is just historical reason.
Reviewed-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 2/6] mm: no blank line after EXPORT_SYMBOL in swap.c
2012-01-01 7:42 ` [PATCH 2/6] mm: no blank line after EXPORT_SYMBOL in swap.c Hugh Dickins
@ 2012-01-01 8:18 ` KOSAKI Motohiro
0 siblings, 0 replies; 12+ messages in thread
From: KOSAKI Motohiro @ 2012-01-01 8:18 UTC (permalink / raw)
To: Hugh Dickins; +Cc: Andrew Morton, Johannes Weiner, linux-mm
(1/1/12 2:42 AM), Hugh Dickins wrote:
> checkpatch rightly protests
> WARNING: EXPORT_SYMBOL(foo); should immediately follow its function/variable
> so fix the five offenders in mm/swap.c.
>
> Signed-off-by: Hugh Dickins<hughd@google.com>
Reviewed-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 3/6] mm: enum lru_list lru
2012-01-01 7:43 ` [PATCH 3/6] mm: enum lru_list lru Hugh Dickins
@ 2012-01-01 8:19 ` KOSAKI Motohiro
0 siblings, 0 replies; 12+ messages in thread
From: KOSAKI Motohiro @ 2012-01-01 8:19 UTC (permalink / raw)
To: Hugh Dickins; +Cc: Andrew Morton, Johannes Weiner, linux-mm
(1/1/12 2:43 AM), Hugh Dickins wrote:
> Mostly we use "enum lru_list lru": change those few "l"s to "lru"s.
>
> Signed-off-by: Hugh Dickins<hughd@google.com>
> ---
> include/linux/mm_inline.h | 26 +++++++++++++-------------
> include/linux/mmzone.h | 16 ++++++++--------
> mm/page_alloc.c | 6 +++---
> mm/vmscan.c | 22 +++++++++++-----------
> 4 files changed, 35 insertions(+), 35 deletions(-)
>
Reviewed-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 4/6] mm: remove del_page_from_lru, add page_off_lru
2012-01-01 7:45 ` [PATCH 4/6] mm: remove del_page_from_lru, add page_off_lru Hugh Dickins
@ 2012-01-01 8:22 ` KOSAKI Motohiro
0 siblings, 0 replies; 12+ messages in thread
From: KOSAKI Motohiro @ 2012-01-01 8:22 UTC (permalink / raw)
To: Hugh Dickins; +Cc: Andrew Morton, Johannes Weiner, linux-mm
(1/1/12 2:45 AM), Hugh Dickins wrote:
> del_page_from_lru() repeats del_page_from_lru_list(), also working out
> which LRU the page was on, clearing the relevant bits. Decouple those
> functions: remove del_page_from_lru() and add page_off_lru().
>
> Signed-off-by: Hugh Dickins<hughd@google.com>
Reviewed-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 5/6] mm: remove isolate_pages
2012-01-01 7:46 ` [PATCH 5/6] mm: remove isolate_pages Hugh Dickins
@ 2012-01-01 9:36 ` KOSAKI Motohiro
0 siblings, 0 replies; 12+ messages in thread
From: KOSAKI Motohiro @ 2012-01-01 9:36 UTC (permalink / raw)
To: Hugh Dickins; +Cc: Andrew Morton, Johannes Weiner, linux-mm
(1/1/12 2:46 AM), Hugh Dickins wrote:
> The isolate_pages() level in vmscan.c offers little but indirection:
> merge it into isolate_lru_pages() as the compiler does, and use the
> names nr_to_scan and nr_scanned in each case.
>
> Signed-off-by: Hugh Dickins<hughd@google.com>
> ---
> mm/vmscan.c | 61 ++++++++++++++++++++++----------------------------
> 1 file changed, 27 insertions(+), 34 deletions(-)
Reviewed-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2012-01-01 9:36 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-01 7:39 [PATCH 0/6] mm: trivial cleanups Hugh Dickins
2012-01-01 7:41 ` [PATCH 1/6] mm: fewer underscores in ____pagevec_lru_add Hugh Dickins
2012-01-01 8:17 ` KOSAKI Motohiro
2012-01-01 7:42 ` [PATCH 2/6] mm: no blank line after EXPORT_SYMBOL in swap.c Hugh Dickins
2012-01-01 8:18 ` KOSAKI Motohiro
2012-01-01 7:43 ` [PATCH 3/6] mm: enum lru_list lru Hugh Dickins
2012-01-01 8:19 ` KOSAKI Motohiro
2012-01-01 7:45 ` [PATCH 4/6] mm: remove del_page_from_lru, add page_off_lru Hugh Dickins
2012-01-01 8:22 ` KOSAKI Motohiro
2012-01-01 7:46 ` [PATCH 5/6] mm: remove isolate_pages Hugh Dickins
2012-01-01 9:36 ` KOSAKI Motohiro
2012-01-01 7:48 ` [PATCH 6/6] mm: rearrange putback_inactive_pages Hugh Dickins
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).