aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorMel Gorman <mgorman@suse.de>2012-01-12 20:19:43 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2012-01-12 23:13:09 -0500
commita6bc32b899223a877f595ef9ddc1e89ead5072b8 (patch)
treea9529f7af2cf8e77bb6670acea32169c891a2b76 /include
parent66199712e9eef5aede09dbcd9dfff87798a66917 (diff)
mm: compaction: introduce sync-light migration for use by compaction
This patch adds a lightweight sync migrate operation MIGRATE_SYNC_LIGHT mode that avoids writing back pages to backing storage. Async compaction maps to MIGRATE_ASYNC while sync compaction maps to MIGRATE_SYNC_LIGHT. For other migrate_pages users such as memory hotplug, MIGRATE_SYNC is used. This avoids sync compaction stalling for an excessive length of time, particularly when copying files to a USB stick where there might be a large number of dirty pages backed by a filesystem that does not support ->writepages. [aarcange@redhat.com: This patch is heavily based on Andrea's work] [akpm@linux-foundation.org: fix fs/nfs/write.c build] [akpm@linux-foundation.org: fix fs/btrfs/disk-io.c build] Signed-off-by: Mel Gorman <mgorman@suse.de> Reviewed-by: Rik van Riel <riel@redhat.com> Cc: Andrea Arcangeli <aarcange@redhat.com> Cc: Minchan Kim <minchan.kim@gmail.com> Cc: Dave Jones <davej@redhat.com> Cc: Jan Kara <jack@suse.cz> Cc: Andy Isaacson <adi@hexapodia.org> Cc: Nai Xia <nai.xia@gmail.com> Cc: Johannes Weiner <jweiner@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include')
-rw-r--r--include/linux/fs.h6
-rw-r--r--include/linux/migrate.h23
2 files changed, 22 insertions, 7 deletions
diff --git a/include/linux/fs.h b/include/linux/fs.h
index b92b73d0b2b9..e694bd4434a4 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -525,6 +525,7 @@ enum positive_aop_returns {
525struct page; 525struct page;
526struct address_space; 526struct address_space;
527struct writeback_control; 527struct writeback_control;
528enum migrate_mode;
528 529
529struct iov_iter { 530struct iov_iter {
530 const struct iovec *iov; 531 const struct iovec *iov;
@@ -614,7 +615,7 @@ struct address_space_operations {
614 * is false, it must not block. 615 * is false, it must not block.
615 */ 616 */
616 int (*migratepage) (struct address_space *, 617 int (*migratepage) (struct address_space *,
617 struct page *, struct page *, bool); 618 struct page *, struct page *, enum migrate_mode);
618 int (*launder_page) (struct page *); 619 int (*launder_page) (struct page *);
619 int (*is_partially_uptodate) (struct page *, read_descriptor_t *, 620 int (*is_partially_uptodate) (struct page *, read_descriptor_t *,
620 unsigned long); 621 unsigned long);
@@ -2540,7 +2541,8 @@ extern int generic_check_addressable(unsigned, u64);
2540 2541
2541#ifdef CONFIG_MIGRATION 2542#ifdef CONFIG_MIGRATION
2542extern int buffer_migrate_page(struct address_space *, 2543extern int buffer_migrate_page(struct address_space *,
2543 struct page *, struct page *, bool); 2544 struct page *, struct page *,
2545 enum migrate_mode);
2544#else 2546#else
2545#define buffer_migrate_page NULL 2547#define buffer_migrate_page NULL
2546#endif 2548#endif
diff --git a/include/linux/migrate.h b/include/linux/migrate.h
index 14e6d2a88475..eaf867412f7a 100644
--- a/include/linux/migrate.h
+++ b/include/linux/migrate.h
@@ -6,18 +6,31 @@
6 6
7typedef struct page *new_page_t(struct page *, unsigned long private, int **); 7typedef struct page *new_page_t(struct page *, unsigned long private, int **);
8 8
9/*
10 * MIGRATE_ASYNC means never block
11 * MIGRATE_SYNC_LIGHT in the current implementation means to allow blocking
12 * on most operations but not ->writepage as the potential stall time
13 * is too significant
14 * MIGRATE_SYNC will block when migrating pages
15 */
16enum migrate_mode {
17 MIGRATE_ASYNC,
18 MIGRATE_SYNC_LIGHT,
19 MIGRATE_SYNC,
20};
21
9#ifdef CONFIG_MIGRATION 22#ifdef CONFIG_MIGRATION
10#define PAGE_MIGRATION 1 23#define PAGE_MIGRATION 1
11 24
12extern void putback_lru_pages(struct list_head *l); 25extern void putback_lru_pages(struct list_head *l);
13extern int migrate_page(struct address_space *, 26extern int migrate_page(struct address_space *,
14 struct page *, struct page *, bool); 27 struct page *, struct page *, enum migrate_mode);
15extern int migrate_pages(struct list_head *l, new_page_t x, 28extern int migrate_pages(struct list_head *l, new_page_t x,
16 unsigned long private, bool offlining, 29 unsigned long private, bool offlining,
17 bool sync); 30 enum migrate_mode mode);
18extern int migrate_huge_pages(struct list_head *l, new_page_t x, 31extern int migrate_huge_pages(struct list_head *l, new_page_t x,
19 unsigned long private, bool offlining, 32 unsigned long private, bool offlining,
20 bool sync); 33 enum migrate_mode mode);
21 34
22extern int fail_migrate_page(struct address_space *, 35extern int fail_migrate_page(struct address_space *,
23 struct page *, struct page *); 36 struct page *, struct page *);
@@ -36,10 +49,10 @@ extern int migrate_huge_page_move_mapping(struct address_space *mapping,
36static inline void putback_lru_pages(struct list_head *l) {} 49static inline void putback_lru_pages(struct list_head *l) {}
37static inline int migrate_pages(struct list_head *l, new_page_t x, 50static inline int migrate_pages(struct list_head *l, new_page_t x,
38 unsigned long private, bool offlining, 51 unsigned long private, bool offlining,
39 bool sync) { return -ENOSYS; } 52 enum migrate_mode mode) { return -ENOSYS; }
40static inline int migrate_huge_pages(struct list_head *l, new_page_t x, 53static inline int migrate_huge_pages(struct list_head *l, new_page_t x,
41 unsigned long private, bool offlining, 54 unsigned long private, bool offlining,
42 bool sync) { return -ENOSYS; } 55 enum migrate_mode mode) { return -ENOSYS; }
43 56
44static inline int migrate_prep(void) { return -ENOSYS; } 57static inline int migrate_prep(void) { return -ENOSYS; }
45static inline int migrate_prep_local(void) { return -ENOSYS; } 58static inline int migrate_prep_local(void) { return -ENOSYS; }