diff options
author | Mel Gorman <mel@csn.ul.ie> | 2010-05-24 17:32:29 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-05-25 11:06:59 -0400 |
commit | ed4a6d7f0676db50b5023cc01f6cda82a2f2a307 (patch) | |
tree | 6496343ba964e105cf30f8703714471f22edc806 /mm/compaction.c | |
parent | 76ab0f530e4a01d4dc20cdc1d5e87753c579dc18 (diff) |
mm: compaction: add /sys trigger for per-node memory compaction
Add a per-node sysfs file called compact. When the file is written to,
each zone in that node is compacted. The intention that this would be
used by something like a job scheduler in a batch system before a job
starts so that the job can allocate the maximum number of hugepages
without significant start-up cost.
Signed-off-by: Mel Gorman <mel@csn.ul.ie>
Acked-by: Rik van Riel <riel@redhat.com>
Reviewed-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Reviewed-by: Christoph Lameter <cl@linux-foundation.org>
Reviewed-by: Minchan Kim <minchan.kim@gmail.com>
Reviewed-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/compaction.c')
-rw-r--r-- | mm/compaction.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/mm/compaction.c b/mm/compaction.c index 77854fbc0f56..f61f77983ff4 100644 --- a/mm/compaction.c +++ b/mm/compaction.c | |||
@@ -13,6 +13,7 @@ | |||
13 | #include <linux/mm_inline.h> | 13 | #include <linux/mm_inline.h> |
14 | #include <linux/backing-dev.h> | 14 | #include <linux/backing-dev.h> |
15 | #include <linux/sysctl.h> | 15 | #include <linux/sysctl.h> |
16 | #include <linux/sysfs.h> | ||
16 | #include "internal.h" | 17 | #include "internal.h" |
17 | 18 | ||
18 | /* | 19 | /* |
@@ -453,3 +454,25 @@ int sysctl_compaction_handler(struct ctl_table *table, int write, | |||
453 | 454 | ||
454 | return 0; | 455 | return 0; |
455 | } | 456 | } |
457 | |||
458 | #if defined(CONFIG_SYSFS) && defined(CONFIG_NUMA) | ||
459 | ssize_t sysfs_compact_node(struct sys_device *dev, | ||
460 | struct sysdev_attribute *attr, | ||
461 | const char *buf, size_t count) | ||
462 | { | ||
463 | compact_node(dev->id); | ||
464 | |||
465 | return count; | ||
466 | } | ||
467 | static SYSDEV_ATTR(compact, S_IWUSR, NULL, sysfs_compact_node); | ||
468 | |||
469 | int compaction_register_node(struct node *node) | ||
470 | { | ||
471 | return sysdev_create_file(&node->sysdev, &attr_compact); | ||
472 | } | ||
473 | |||
474 | void compaction_unregister_node(struct node *node) | ||
475 | { | ||
476 | return sysdev_remove_file(&node->sysdev, &attr_compact); | ||
477 | } | ||
478 | #endif /* CONFIG_SYSFS && CONFIG_NUMA */ | ||