The patch titled mm: compaction: add /sys trigger for per-node memory compaction has been added to the -mm tree. Its filename is mmcompaction-add-sys-trigger-for-per-node-memory-compaction.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/SubmitChecklist when testing your code *** See http://userweb.kernel.org/~akpm/stuff/added-to-mm.txt to find out what to do about this The current -mm tree may be found at http://userweb.kernel.org/~akpm/mmotm/ ------------------------------------------------------ Subject: mm: compaction: add /sys trigger for per-node memory compaction From: Mel Gorman <mel@xxxxxxxxx> 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@xxxxxxxxx> Acked-by: Rik van Riel <riel@xxxxxxxxxx> Reviewed-by: KOSAKI Motohiro <kosaki.motohiro@xxxxxxxxxxxxxx> Reviewed-by: Christoph Lameter <cl@xxxxxxxxxxxxxxxxxxxx> Reviewed-by: Minchan Kim <minchan.kim@xxxxxxxxx> Reviewed-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@xxxxxxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- Documentation/ABI/testing/sysfs-devices-node | 7 +++++ drivers/base/node.c | 3 ++ include/linux/compaction.h | 16 +++++++++++ mm/compaction.c | 23 +++++++++++++++++ 4 files changed, 49 insertions(+) diff -puN /dev/null Documentation/ABI/testing/sysfs-devices-node --- /dev/null +++ a/Documentation/ABI/testing/sysfs-devices-node @@ -0,0 +1,7 @@ +What: /sys/devices/system/node/nodeX/compact +Date: February 2010 +Contact: Mel Gorman <mel@xxxxxxxxx> +Description: + When this file is written to, all memory within that node + will be compacted. When it completes, memory will be freed + into blocks which have as many contiguous pages as possible diff -puN drivers/base/node.c~mmcompaction-add-sys-trigger-for-per-node-memory-compaction drivers/base/node.c --- a/drivers/base/node.c~mmcompaction-add-sys-trigger-for-per-node-memory-compaction +++ a/drivers/base/node.c @@ -9,6 +9,7 @@ #include <linux/memory.h> #include <linux/node.h> #include <linux/hugetlb.h> +#include <linux/compaction.h> #include <linux/cpumask.h> #include <linux/topology.h> #include <linux/nodemask.h> @@ -246,6 +247,8 @@ int register_node(struct node *node, int scan_unevictable_register_node(node); hugetlb_register_node(node); + + compaction_register_node(node); } return error; } diff -puN include/linux/compaction.h~mmcompaction-add-sys-trigger-for-per-node-memory-compaction include/linux/compaction.h --- a/include/linux/compaction.h~mmcompaction-add-sys-trigger-for-per-node-memory-compaction +++ a/include/linux/compaction.h @@ -12,4 +12,20 @@ extern int sysctl_compaction_handler(str void __user *buffer, size_t *length, loff_t *ppos); #endif /* CONFIG_COMPACTION */ +#if defined(CONFIG_COMPACTION) && defined(CONFIG_SYSFS) && defined(CONFIG_NUMA) +extern int compaction_register_node(struct node *node); +extern void compaction_unregister_node(struct node *node); + +#else + +static inline int compaction_register_node(struct node *node) +{ + return 0; +} + +static inline void compaction_unregister_node(struct node *node) +{ +} +#endif /* CONFIG_COMPACTION && CONFIG_SYSFS && CONFIG_NUMA */ + #endif /* _LINUX_COMPACTION_H */ diff -puN mm/compaction.c~mmcompaction-add-sys-trigger-for-per-node-memory-compaction mm/compaction.c --- a/mm/compaction.c~mmcompaction-add-sys-trigger-for-per-node-memory-compaction +++ a/mm/compaction.c @@ -13,6 +13,7 @@ #include <linux/mm_inline.h> #include <linux/backing-dev.h> #include <linux/sysctl.h> +#include <linux/sysfs.h> #include "internal.h" /* @@ -453,3 +454,25 @@ int sysctl_compaction_handler(struct ctl return 0; } + +#if defined(CONFIG_SYSFS) && defined(CONFIG_NUMA) +ssize_t sysfs_compact_node(struct sys_device *dev, + struct sysdev_attribute *attr, + const char *buf, size_t count) +{ + compact_node(dev->id); + + return count; +} +static SYSDEV_ATTR(compact, S_IWUSR, NULL, sysfs_compact_node); + +int compaction_register_node(struct node *node) +{ + return sysdev_create_file(&node->sysdev, &attr_compact); +} + +void compaction_unregister_node(struct node *node) +{ + return sysdev_remove_file(&node->sysdev, &attr_compact); +} +#endif /* CONFIG_SYSFS && CONFIG_NUMA */ _ Patches currently in -mm which might be from mel@xxxxxxxxx are linux-next.patch hugetlb-fix-infinite-loop-in-get_futex_key-when-backed-by-huge-pages.patch hugetlb-fix-infinite-loop-in-get_futex_key-when-backed-by-huge-pages-fix.patch hugetlbfs-kill-applications-that-use-map_noreserve-with-sigbus-instead-of-oom-killer.patch page-allocator-reduce-fragmentation-in-buddy-allocator-by-adding-buddies-that-are-merging-to-the-tail-of-the-free-lists.patch mempolicy-remove-redundant-code.patch mm-default-to-node-zonelist-ordering-when-nodes-have-only-lowmem.patch mmmigration-take-a-reference-to-the-anon_vma-before-migrating.patch mmmigration-share-the-anon_vma-ref-counts-between-ksm-and-page-migration.patch mmmigration-do-not-try-to-migrate-unmapped-anonymous-pages.patch mmmigration-allow-the-migration-of-pageswapcache-pages.patch mm-allow-config_migration-to-be-set-without-config_numa-or-memory-hot-remove.patch mm-export-unusable-free-space-index-via-debugfs.patch mm-export-fragmentation-index-via-debugfs.patch mm-move-definition-for-lru-isolation-modes-to-a-header.patch mmcompaction-memory-compaction-core.patch mmcompaction-add-proc-trigger-for-memory-compaction.patch mmcompaction-add-sys-trigger-for-per-node-memory-compaction.patch mmcompaction-direct-compact-when-a-high-order-allocation-fails.patch mmcompaction-add-a-tunable-that-decides-when-memory-should-be-compacted-and-when-it-should-be-reclaimed.patch mmcompaction-defer-compaction-using-an-exponential-backoff-when-compaction-fails.patch mm-introduce-free_pages_prepare.patch mm-introduce-free_pages_prepare-fix.patch delay-accounting-re-implement-c-for-getdelaysc-to-report-information-on-a-target-command.patch delay-accounting-re-implement-c-for-getdelaysc-to-report-information-on-a-target-command-checkpatch-fixes.patch numa-add-generic-percpu-var-numa_node_id-implementation.patch numa-x86_64-use-generic-percpu-var-numa_node_id-implementation.patch numa-ia64-use-generic-percpu-var-numa_node_id-implementation.patch numa-introduce-numa_mem_id-effective-local-memory-node-id.patch numa-ia64-support-numa_mem_id-for-memoryless-nodes.patch numa-slab-use-numa_mem_id-for-slab-local-memory-node.patch numa-in-kernel-profiling-use-cpu_to_mem-for-per-cpu-allocations.patch numa-update-documentation-vm-numa-add-memoryless-node-info.patch add-debugging-aid-for-memory-initialisation-problems.patch -- To unsubscribe from this list: send the line "unsubscribe mm-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html