Re: [patch v4 4/6] mm, compaction: embed migration mode in compact_control

2014-05-09 Thread Andrew Morton
On Wed, 7 May 2014 03:36:46 -0700 (PDT) David Rientjes  
wrote:

> We're going to want to manipulate the migration mode for compaction in the 
> page 
> allocator, and currently compact_control's sync field is only a bool.  
> 
> Currently, we only do MIGRATE_ASYNC or MIGRATE_SYNC_LIGHT compaction 
> depending 
> on the value of this bool.  Convert the bool to enum migrate_mode and pass 
> the 
> migration mode in directly.  Later, we'll want to avoid MIGRATE_SYNC_LIGHT 
> for 
> thp allocations in the pagefault patch to avoid unnecessary latency.
> 
> This also alters compaction triggered from sysfs, either for the entire 
> system 
> or for a node, to force MIGRATE_SYNC.

mm/page_alloc.c: In function 'alloc_contig_range':
mm/page_alloc.c:6255: error: unknown field 'sync' specified in initializer

--- a/mm/page_alloc.c~mm-compaction-embed-migration-mode-in-compact_control-fix
+++ a/mm/page_alloc.c
@@ -6252,7 +6252,7 @@ int alloc_contig_range(unsigned long sta
.nr_migratepages = 0,
.order = -1,
.zone = page_zone(pfn_to_page(start)),
-   .sync = MIGRATE_SYNC_LIGHT,
+   .mode = MIGRATE_SYNC_LIGHT,
.ignore_skip_hint = true,
};
INIT_LIST_HEAD();


Please check that you sent the correct version of this?
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [patch v4 4/6] mm, compaction: embed migration mode in compact_control

2014-05-09 Thread Andrew Morton
On Wed, 7 May 2014 03:36:46 -0700 (PDT) David Rientjes rient...@google.com 
wrote:

 We're going to want to manipulate the migration mode for compaction in the 
 page 
 allocator, and currently compact_control's sync field is only a bool.  
 
 Currently, we only do MIGRATE_ASYNC or MIGRATE_SYNC_LIGHT compaction 
 depending 
 on the value of this bool.  Convert the bool to enum migrate_mode and pass 
 the 
 migration mode in directly.  Later, we'll want to avoid MIGRATE_SYNC_LIGHT 
 for 
 thp allocations in the pagefault patch to avoid unnecessary latency.
 
 This also alters compaction triggered from sysfs, either for the entire 
 system 
 or for a node, to force MIGRATE_SYNC.

mm/page_alloc.c: In function 'alloc_contig_range':
mm/page_alloc.c:6255: error: unknown field 'sync' specified in initializer

--- a/mm/page_alloc.c~mm-compaction-embed-migration-mode-in-compact_control-fix
+++ a/mm/page_alloc.c
@@ -6252,7 +6252,7 @@ int alloc_contig_range(unsigned long sta
.nr_migratepages = 0,
.order = -1,
.zone = page_zone(pfn_to_page(start)),
-   .sync = MIGRATE_SYNC_LIGHT,
+   .mode = MIGRATE_SYNC_LIGHT,
.ignore_skip_hint = true,
};
INIT_LIST_HEAD(cc.migratepages);


Please check that you sent the correct version of this?
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[patch v4 4/6] mm, compaction: embed migration mode in compact_control

2014-05-07 Thread David Rientjes
We're going to want to manipulate the migration mode for compaction in the page 
allocator, and currently compact_control's sync field is only a bool.  

Currently, we only do MIGRATE_ASYNC or MIGRATE_SYNC_LIGHT compaction depending 
on the value of this bool.  Convert the bool to enum migrate_mode and pass the 
migration mode in directly.  Later, we'll want to avoid MIGRATE_SYNC_LIGHT for 
thp allocations in the pagefault patch to avoid unnecessary latency.

This also alters compaction triggered from sysfs, either for the entire system 
or for a node, to force MIGRATE_SYNC.

Suggested-by: Mel Gorman 
Acked-by: Vlastimil Babka 
Signed-off-by: David Rientjes 
---
 v4 of this patch only: converted name of formal from "sync" to "mode" for
try_to_compact_pages() per Vlastimil

 include/linux/compaction.h |  4 ++--
 mm/compaction.c| 38 --
 mm/internal.h  |  2 +-
 mm/page_alloc.c| 37 -
 4 files changed, 39 insertions(+), 42 deletions(-)

diff --git a/include/linux/compaction.h b/include/linux/compaction.h
--- a/include/linux/compaction.h
+++ b/include/linux/compaction.h
@@ -22,7 +22,7 @@ extern int sysctl_extfrag_handler(struct ctl_table *table, 
int write,
 extern int fragmentation_index(struct zone *zone, unsigned int order);
 extern unsigned long try_to_compact_pages(struct zonelist *zonelist,
int order, gfp_t gfp_mask, nodemask_t *mask,
-   bool sync, bool *contended);
+   enum migrate_mode mode, bool *contended);
 extern void compact_pgdat(pg_data_t *pgdat, int order);
 extern void reset_isolation_suitable(pg_data_t *pgdat);
 extern unsigned long compaction_suitable(struct zone *zone, int order);
@@ -91,7 +91,7 @@ static inline bool compaction_restarting(struct zone *zone, 
int order)
 #else
 static inline unsigned long try_to_compact_pages(struct zonelist *zonelist,
int order, gfp_t gfp_mask, nodemask_t *nodemask,
-   bool sync, bool *contended)
+   enum migrate_mode mode, bool *contended)
 {
return COMPACT_CONTINUE;
 }
diff --git a/mm/compaction.c b/mm/compaction.c
--- a/mm/compaction.c
+++ b/mm/compaction.c
@@ -161,7 +161,8 @@ static void update_pageblock_skip(struct compact_control 
*cc,
return;
if (pfn > zone->compact_cached_migrate_pfn[0])
zone->compact_cached_migrate_pfn[0] = pfn;
-   if (cc->sync && pfn > zone->compact_cached_migrate_pfn[1])
+   if (cc->mode != MIGRATE_ASYNC &&
+   pfn > zone->compact_cached_migrate_pfn[1])
zone->compact_cached_migrate_pfn[1] = pfn;
} else {
if (cc->finished_update_free)
@@ -208,7 +209,7 @@ static bool compact_checklock_irqsave(spinlock_t *lock, 
unsigned long *flags,
}
 
/* async aborts if taking too long or contended */
-   if (!cc->sync) {
+   if (cc->mode == MIGRATE_ASYNC) {
cc->contended = true;
return false;
}
@@ -479,7 +480,8 @@ isolate_migratepages_range(struct zone *zone, struct 
compact_control *cc,
bool locked = false;
struct page *page = NULL, *valid_page = NULL;
bool set_unsuitable = true;
-   const isolate_mode_t mode = (!cc->sync ? ISOLATE_ASYNC_MIGRATE : 0) |
+   const isolate_mode_t mode = (cc->mode == MIGRATE_ASYNC ?
+   ISOLATE_ASYNC_MIGRATE : 0) |
(unevictable ? ISOLATE_UNEVICTABLE : 0);
 
/*
@@ -489,7 +491,7 @@ isolate_migratepages_range(struct zone *zone, struct 
compact_control *cc,
 */
while (unlikely(too_many_isolated(zone))) {
/* async migration should just abort */
-   if (!cc->sync)
+   if (cc->mode == MIGRATE_ASYNC)
return 0;
 
congestion_wait(BLK_RW_ASYNC, HZ/10);
@@ -554,7 +556,8 @@ isolate_migratepages_range(struct zone *zone, struct 
compact_control *cc,
 * the minimum amount of work satisfies the allocation
 */
mt = get_pageblock_migratetype(page);
-   if (!cc->sync && !migrate_async_suitable(mt)) {
+   if (cc->mode == MIGRATE_ASYNC &&
+   !migrate_async_suitable(mt)) {
set_unsuitable = false;
goto next_pageblock;
}
@@ -990,6 +993,7 @@ static int compact_zone(struct zone *zone, struct 
compact_control *cc)
int ret;
unsigned long start_pfn = zone->zone_start_pfn;
unsigned long end_pfn = zone_end_pfn(zone);
+   const bool sync = cc->mode != 

[patch v4 4/6] mm, compaction: embed migration mode in compact_control

2014-05-07 Thread David Rientjes
We're going to want to manipulate the migration mode for compaction in the page 
allocator, and currently compact_control's sync field is only a bool.  

Currently, we only do MIGRATE_ASYNC or MIGRATE_SYNC_LIGHT compaction depending 
on the value of this bool.  Convert the bool to enum migrate_mode and pass the 
migration mode in directly.  Later, we'll want to avoid MIGRATE_SYNC_LIGHT for 
thp allocations in the pagefault patch to avoid unnecessary latency.

This also alters compaction triggered from sysfs, either for the entire system 
or for a node, to force MIGRATE_SYNC.

Suggested-by: Mel Gorman mgor...@suse.de
Acked-by: Vlastimil Babka vba...@suse.cz
Signed-off-by: David Rientjes rient...@google.com
---
 v4 of this patch only: converted name of formal from sync to mode for
try_to_compact_pages() per Vlastimil

 include/linux/compaction.h |  4 ++--
 mm/compaction.c| 38 --
 mm/internal.h  |  2 +-
 mm/page_alloc.c| 37 -
 4 files changed, 39 insertions(+), 42 deletions(-)

diff --git a/include/linux/compaction.h b/include/linux/compaction.h
--- a/include/linux/compaction.h
+++ b/include/linux/compaction.h
@@ -22,7 +22,7 @@ extern int sysctl_extfrag_handler(struct ctl_table *table, 
int write,
 extern int fragmentation_index(struct zone *zone, unsigned int order);
 extern unsigned long try_to_compact_pages(struct zonelist *zonelist,
int order, gfp_t gfp_mask, nodemask_t *mask,
-   bool sync, bool *contended);
+   enum migrate_mode mode, bool *contended);
 extern void compact_pgdat(pg_data_t *pgdat, int order);
 extern void reset_isolation_suitable(pg_data_t *pgdat);
 extern unsigned long compaction_suitable(struct zone *zone, int order);
@@ -91,7 +91,7 @@ static inline bool compaction_restarting(struct zone *zone, 
int order)
 #else
 static inline unsigned long try_to_compact_pages(struct zonelist *zonelist,
int order, gfp_t gfp_mask, nodemask_t *nodemask,
-   bool sync, bool *contended)
+   enum migrate_mode mode, bool *contended)
 {
return COMPACT_CONTINUE;
 }
diff --git a/mm/compaction.c b/mm/compaction.c
--- a/mm/compaction.c
+++ b/mm/compaction.c
@@ -161,7 +161,8 @@ static void update_pageblock_skip(struct compact_control 
*cc,
return;
if (pfn  zone-compact_cached_migrate_pfn[0])
zone-compact_cached_migrate_pfn[0] = pfn;
-   if (cc-sync  pfn  zone-compact_cached_migrate_pfn[1])
+   if (cc-mode != MIGRATE_ASYNC 
+   pfn  zone-compact_cached_migrate_pfn[1])
zone-compact_cached_migrate_pfn[1] = pfn;
} else {
if (cc-finished_update_free)
@@ -208,7 +209,7 @@ static bool compact_checklock_irqsave(spinlock_t *lock, 
unsigned long *flags,
}
 
/* async aborts if taking too long or contended */
-   if (!cc-sync) {
+   if (cc-mode == MIGRATE_ASYNC) {
cc-contended = true;
return false;
}
@@ -479,7 +480,8 @@ isolate_migratepages_range(struct zone *zone, struct 
compact_control *cc,
bool locked = false;
struct page *page = NULL, *valid_page = NULL;
bool set_unsuitable = true;
-   const isolate_mode_t mode = (!cc-sync ? ISOLATE_ASYNC_MIGRATE : 0) |
+   const isolate_mode_t mode = (cc-mode == MIGRATE_ASYNC ?
+   ISOLATE_ASYNC_MIGRATE : 0) |
(unevictable ? ISOLATE_UNEVICTABLE : 0);
 
/*
@@ -489,7 +491,7 @@ isolate_migratepages_range(struct zone *zone, struct 
compact_control *cc,
 */
while (unlikely(too_many_isolated(zone))) {
/* async migration should just abort */
-   if (!cc-sync)
+   if (cc-mode == MIGRATE_ASYNC)
return 0;
 
congestion_wait(BLK_RW_ASYNC, HZ/10);
@@ -554,7 +556,8 @@ isolate_migratepages_range(struct zone *zone, struct 
compact_control *cc,
 * the minimum amount of work satisfies the allocation
 */
mt = get_pageblock_migratetype(page);
-   if (!cc-sync  !migrate_async_suitable(mt)) {
+   if (cc-mode == MIGRATE_ASYNC 
+   !migrate_async_suitable(mt)) {
set_unsuitable = false;
goto next_pageblock;
}
@@ -990,6 +993,7 @@ static int compact_zone(struct zone *zone, struct 
compact_control *cc)
int ret;
unsigned long start_pfn = zone-zone_start_pfn;
unsigned long end_pfn = zone_end_pfn(zone);
+   const bool sync = cc-mode