+ memcg-enhance-memcg-iterator-to-support-predicates.patch added to -mm tree
Subsystems (4)
[email protected]
maintainerSubject: + memcg-enhance-memcg-iterator-to-support-predicates.patch added to -mm tree
To: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected]
From: [email protected]
Date: Tue, 30 Jul 2013 15:33:56 -0700
The patch titled
Subject: memcg: enhance memcg iterator to support predicates
has been added to the -mm tree. Its filename is
memcg-enhance-memcg-iterator-to-support-predicates.patch
This patch should soon appear at
http://ozlabs.org/~akpm/mmots/broken-out/memcg-enhance-memcg-iterator-to-support-predicates.patch
and later at
http://ozlabs.org/~akpm/mmotm/broken-out/memcg-enhance-memcg-iterator-to-support-predicates.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 ***
The -mm tree is included into linux-next and is updated there every 3-4 working days
------------------------------------------------------
From: Michal Hocko <[email protected]>
Subject: memcg: enhance memcg iterator to support predicates
The caller of the iterator might know that some nodes or even subtrees should be skipped but there is no way to tell iterators about that so the only choice left is to let iterators to visit each node and do the selection outside of the iterating code. This, however, doesn't scale well with hierarchies with many groups where only few groups are interesting.
This patch adds mem_cgroup_iter_cond variant of the iterator with a callback which gets called for every visited node. There are three possible ways how the callback can influence the walk. Either the node is visited, it is skipped but the tree walk continues down the tree or the whole subtree of the current group is skipped.
---
include/linux/memcontrol.h | 48 +++++++++++++++++++-- mm/memcontrol.c | 77 +++++++++++++++++++++++++++-------- mm/vmscan.c | 16 ++----- 3 files changed, 108 insertions(+), 33 deletions(-)
include/linux/memcontrol.h renamed from include/linux/memcontrol.h~memcg-enhance-memcg-iterator-to-support-predicates +42 -6
@@ -41,6 +41,23 @@ struct mem_cgroup_reclaim_cookie {unsigned int generation; }; +enum mem_cgroup_filter_t { +VISIT ,/* visit current node */ +SKIP ,/* skip the current node and continue traversal */ +SKIP_TREE ,/* skip the whole subtree and continue traversal */ +}; + +/* +* mem_cgroup_filter_t predicate might instruct mem_cgroup_iter_cond how to +* iterate through the hierarchy tree. Each tree element is checked by the +* predicate before it is returned by the iterator. If a filter returns +* SKIP or SKIP_TREE then the iterator code continues traversal (with the +* next node down the hierarchy or the next node that doesn't belong under the +* memcg's subtree). +*/ +typedef enum mem_cgroup_filter_t +(*mem_cgroup_iter_filter )(struct mem_cgroup *memcg,struct mem_cgroup *root); +#ifdef CONFIG_MEMCG /* * All "charge" functions with gfp_mask should use GFP_KERNEL or
@@ -108,9 +125,18 @@ mem_cgroup_prepare_migration(struct pageextern void mem_cgroup_end_migration (struct mem_cgroup *memcg,struct page *oldpage,struct page *newpage,bool migration_ok); -struct mem_cgroup *mem_cgroup_iter (struct mem_cgroup *, -struct mem_cgroup *, -struct mem_cgroup_reclaim_cookie *); +struct mem_cgroup *mem_cgroup_iter_cond (struct mem_cgroup *root, +struct mem_cgroup *prev, +struct mem_cgroup_reclaim_cookie *reclaim, +mem_cgroup_iter_filter cond); + +static inline struct mem_cgroup *mem_cgroup_iter (struct mem_cgroup *root, +struct mem_cgroup *prev, +struct mem_cgroup_reclaim_cookie *reclaim) +{ +return mem_cgroup_iter_cond (root, prev, reclaim,NULL ); +} +void mem_cgroup_iter_break (struct mem_cgroup *,struct mem_cgroup *);/*
@@ -180,7 +206,8 @@ static inline void mem_cgroup_dec_page_smem_cgroup_update_page_stat (page, idx,-1 ); } -bool mem_cgroup_soft_reclaim_eligible (struct mem_cgroup *memcg, +enum mem_cgroup_filter_t +mem_cgroup_soft_reclaim_eligible (struct mem_cgroup *memcg,struct mem_cgroup *root);void __mem_cgroup_count_vm_event (struct mm_struct *mm,enum vm_event_item idx);
@@ -295,6 +322,14 @@ static inline void mem_cgroup_end_migrat struct page *oldpage, struct page *newpage, bool migration_ok) { } +static inline struct mem_cgroup * +mem_cgroup_iter_cond (struct mem_cgroup *root, +struct mem_cgroup *prev, +struct mem_cgroup_reclaim_cookie *reclaim, +mem_cgroup_iter_filter cond) +{ +return NULL ; +}static inline struct mem_cgroup * mem_cgroup_iter(struct mem_cgroup *root,
@@ -358,10 +393,11 @@ static inline void mem_cgroup_dec_page_s }static inline -bool mem_cgroup_soft_reclaim_eligible (struct mem_cgroup *memcg, +enum mem_cgroup_filter_t +mem_cgroup_soft_reclaim_eligible (struct mem_cgroup *memcg,struct mem_cgroup *root) { -return false; +return VISIT ; }static inline void mem_cgroup_split_huge_fixup (struct page *head)
mm/memcontrol.c renamed from mm/memcontrol.c~memcg-enhance-memcg-iterator-to-support-predicates +61 -16
156 lines not on this page · raw message
mm/vmscan.c renamed from mm/vmscan.c~memcg-enhance-memcg-iterator-to-support-predicates +5 -11
@@ -2132,21 +2132,16 @@ __shrink_zone(struct zone *zone, struct .zone = zone, .priority = sc->priority, }; -struct mem_cgroup *memcg; +struct mem_cgroup *memcg =NULL ; +mem_cgroup_iter_filter filter = (soft_reclaim) ? + mem_cgroup_soft_reclaim_eligible :NULL ; nr_reclaimed = sc->nr_reclaimed; nr_scanned = sc->nr_scanned; - memcg =mem_cgroup_iter (root,NULL , &reclaim); - do { +while ((memcg =mem_cgroup_iter_cond (root, memcg, &reclaim, filter))) {struct lruvec *lruvec; - if (soft_reclaim && - !mem_cgroup_soft_reclaim_eligible(memcg, root)) { - memcg = mem_cgroup_iter(root, memcg, &reclaim); - continue; - } - lruvec =mem_cgroup_zone_lruvec (zone, memcg);shrink_lruvec (lruvec, sc);
@@ -2166,8 +2161,7 @@ __shrink_zone(struct zone *zone, structmem_cgroup_iter_break (root, memcg);break ; } - memcg =mem_cgroup_iter (root, memcg, &reclaim); - }while (memcg); + } vmpressure(sc->gfp_mask, sc->target_mem_cgroup, sc->nr_scanned - nr_scanned,
_
Patches currently in -mm which might be from [email protected] are
vmpressure-change-vmpressure-sr_lock-to-spinlock.patch vmpressure-do-not-check-for-pending-work-to-prevent-from-new-work.patch vmpressure-make-sure-there-are-no-events-queued-after-memcg-is-offlined.patch vmpressure-make-sure-there-are-no-events-queued-after-memcg-is-offlined-checkpatch-fixes.patch include-linux-schedh-dont-use-task-pid-tgid-in-same_thread_group-has_group_leader_pid.patch watchdog-update-watchdog-attributes-atomically.patch watchdog-update-watchdog_tresh-properly.patch mm-fix-potential-null-pointer-dereference.patch mm-hugetlb-move-up-the-code-which-check-availability-of-free-huge-page.patch mm-hugetlb-trivial-commenting-fix.patch
mm-hugetlb-clean-up-alloc_huge_page.patch mm-hugetlb-fix-and-clean-up-node-iteration-code-to-alloc-or-free.patch mm-hugetlb-remove-redundant-list_empty-check-in-gather_surplus_pages.patch mm-hugetlb-do-not-use-a-page-in-page-cache-for-cow-optimization.patch mm-hugetlb-add-vm_noreserve-check-in-vma_has_reserves.patch mm-hugetlb-remove-decrement_hugepage_resv_vma.patch mm-hugetlb-decrement-reserve-count-if-vm_noreserve-alloc-page-cache.patch memcg-remove-redundant-code-in-mem_cgroup_force_empty_write.patch memcg-vmscan-integrate-soft-reclaim-tighter-with-zone-shrinking-code.patch memcg-get-rid-of-soft-limit-tree-infrastructure.patch vmscan-memcg-do-softlimit-reclaim-also-for-targeted-reclaim.patch memcg-enhance-memcg-iterator-to-support-predicates.patch memcg-track-children-in-soft-limit-excess-to-improve-soft-limit.patch memcg-vmscan-do-not-attempt-soft-limit-reclaim-if-it-would-not-scan-anything.patch memcg-track-all-children-over-limit-in-the-root.patch memcg-vmscan-do-not-fall-into-reclaim-all-pass-too-quickly.patch memcg-trivial-cleanups.patch
linux-next.patch inode-convert-inode-lru-list-to-generic-lru-list-code-inode-move-inode-to-a-different-list-inside-lock.patch list_lru-per-node-list-infrastructure-fix-broken-lru_retry-behaviour.patch list_lru-remove-special-case-function-list_lru_dispose_all.patch xfs-convert-dquot-cache-lru-to-list_lru-fix-dquot-isolation-hang.patch list_lru-dynamically-adjust-node-arrays-super-fix-for-destroy-lrus.patch staging-lustre-ldlm-convert-to-shrinkers-to-count-scan-api.patch staging-lustre-obdclass-convert-lu_object-shrinker-to-count-scan-api.patch staging-lustre-ptlrpc-convert-to-new-shrinker-api.patch staging-lustre-libcfs-cleanup-linux-memh.patch