+ memcg-slab-merge-memcg_bindrelease_pages-to-memcg_uncharge_slab.patch added to -mm tree
Subsystems (3)
[email protected]
maintainerSubject: + memcg-slab-merge-memcg_bindrelease_pages-to-memcg_uncharge_slab.patch added to -mm tree
To: [email protected],[email protected],[email protected],[email protected],[email protected]
From: [email protected]
Date: Wed, 23 Apr 2014 14:23:37 -0700
The patch titled
Subject: memcg, slab: merge memcg_{bind,release}_pages to memcg_{un}charge_slab
has been added to the -mm tree. Its filename is
memcg-slab-merge-memcg_bindrelease_pages-to-memcg_uncharge_slab.patch
This patch should soon appear at
http://ozlabs.org/~akpm/mmots/broken-out/memcg-slab-merge-memcg_bindrelease_pages-to-memcg_uncharge_slab.patch
and later at
http://ozlabs.org/~akpm/mmotm/broken-out/memcg-slab-merge-memcg_bindrelease_pages-to-memcg_uncharge_slab.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: Vladimir Davydov <[email protected]>
Subject: memcg, slab: merge memcg_{bind,release}_pages to memcg_{un}charge_slab
Currently we have two pairs of kmemcg-related functions that are called on slab alloc/free. The first is memcg_{bind,release}_pages that count the total number of pages allocated on a kmem cache. The second is memcg_{un}charge_slab that {un}charge slab pages to kmemcg resource counter. Let's just merge them to keep the code clean.
---
include/linux/memcontrol.h | 4 ++-- mm/memcontrol.c | 22 ++++++++++++++++++++-- mm/slab.c | 2 -- mm/slab.h | 25 ++----------------------- mm/slub.c | 2 -- 5 files changed, 24 insertions(+), 31 deletions(-)
include/linux/memcontrol.h renamed from include/linux/memcontrol.h~memcg-slab-merge-memcg_bindrelease_pages-to-memcg_uncharge_slab +2 -2
@@ -506,8 +506,8 @@ void memcg_update_array_size(int num_grostruct kmem_cache *__memcg_kmem_get_cache (struct kmem_cache *cachep,gfp_t gfp); -int memcg_charge_kmem (struct mem_cgroup *memcg,gfp_t gfp,u64 size); -void memcg_uncharge_kmem (struct mem_cgroup *memcg,u64 size); +int __memcg_charge_slab (struct kmem_cache *cachep,gfp_t gfp,int order); +void __memcg_uncharge_slab (struct kmem_cache *cachep,int order);int __kmem_cache_destroy_memcg_children (struct kmem_cache *s);
mm/memcontrol.c renamed from mm/memcontrol.c~memcg-slab-merge-memcg_bindrelease_pages-to-memcg_uncharge_slab +20 -2
@@ -2952,7 +2952,7 @@ static int mem_cgroup_slabinfo_read(stru }#endif -int memcg_charge_kmem (struct mem_cgroup *memcg,gfp_t gfp,u64 size) +static int memcg_charge_kmem (struct mem_cgroup *memcg,gfp_t gfp,u64 size) {struct res_counter *fail_res;int ret =0 ;
@@ -2990,7 +2990,7 @@ int memcg_charge_kmem(struct mem_cgroupreturn ret; } -void memcg_uncharge_kmem (struct mem_cgroup *memcg,u64 size) +static void memcg_uncharge_kmem (struct mem_cgroup *memcg,u64 size) {res_counter_uncharge (&memcg->res, size);if (do_swap_account)
@@ -3388,6 +3388,24 @@ static void memcg_create_cache_enqueue(s__memcg_create_cache_enqueue (memcg, cachep);memcg_resume_kmem_account (); } + +int __memcg_charge_slab (struct kmem_cache *cachep,gfp_t gfp,int order) +{ +int res; + + res =memcg_charge_kmem (cachep->memcg_params->memcg, gfp, +PAGE_SIZE << order); +if (!res) +atomic_add (1 << order, &cachep->memcg_params->nr_pages); +return res; +} + +void __memcg_uncharge_slab (struct kmem_cache *cachep,int order) +{ +memcg_uncharge_kmem (cachep->memcg_params->memcg,PAGE_SIZE << order); +atomic_sub (1 << order, &cachep->memcg_params->nr_pages); +} +/* * Return the kmem_cache we're supposed to use for a slab allocation. * We try to use the current memcg's version of the cache.
mm/slab.c renamed from mm/slab.c~memcg-slab-merge-memcg_bindrelease_pages-to-memcg_uncharge_slab +0 -2
@@ -1706,7 +1706,6 @@ static struct page *kmem_getpages(struct__SetPageSlab (page);if (page->pfmemalloc)SetPageSlabPfmemalloc (page); -memcg_bind_pages (cachep, cachep->gfporder);if (kmemcheck_enabled && !(cachep->flags &SLAB_NOTRACK )) {kmemcheck_alloc_shadow (page, cachep->gfporder, flags, nodeid);
@@ -1742,7 +1741,6 @@ static void kmem_freepages(struct kmem_cpage_mapcount_reset (page); page->mapping =NULL ; -memcg_release_pages (cachep, cachep->gfporder);if (current->reclaim_state) current->reclaim_state->reclaimed_slab += nr_freed;__free_pages (page, cachep->gfporder);
mm/slab.h renamed from mm/slab.h~memcg-slab-merge-memcg_bindrelease_pages-to-memcg_uncharge_slab +2 -23
@@ -120,18 +120,6 @@ static inline bool is_root_cache(structreturn !s->memcg_params || s->memcg_params->is_root_cache; } -static inline void memcg_bind_pages (struct kmem_cache *s,int order) -{ -if (!is_root_cache (s)) -atomic_add (1 << order, &s->memcg_params->nr_pages); -} - -static inline void memcg_release_pages (struct kmem_cache *s,int order) -{ -if (!is_root_cache (s)) -atomic_sub (1 << order, &s->memcg_params->nr_pages); -} -static inline bool slab_equal_or_root (struct kmem_cache *s,struct kmem_cache *p) {
@@ -197,8 +185,7 @@ static __always_inline int memcg_charge_return 0 ;if (is_root_cache (s))return 0 ; -return memcg_charge_kmem (s->memcg_params->memcg, gfp, -PAGE_SIZE << order); +return __memcg_charge_slab (s, gfp, order); } static __always_inline void memcg_uncharge_slab(struct kmem_cache *s, int order)
@@ -207,7 +194,7 @@ static __always_inline void memcg_uncharreturn ;if (is_root_cache (s))return ; - memcg_uncharge_kmem(s->memcg_params->memcg, PAGE_SIZE << order); + __memcg_uncharge_slab(s, order); }#else static inline bool is_root_cache (struct kmem_cache *s)
@@ -215,14 +202,6 @@ static inline bool is_root_cache(structreturn true; } -static inline void memcg_bind_pages (struct kmem_cache *s,int order) -{ -} - -static inline void memcg_release_pages (struct kmem_cache *s,int order) -{ -} -static inline bool slab_equal_or_root (struct kmem_cache *s,struct kmem_cache *p) {
mm/slub.c renamed from mm/slub.c~memcg-slab-merge-memcg_bindrelease_pages-to-memcg_uncharge_slab +0 -2
@@ -1427,7 +1427,6 @@ static struct page *new_slab(struct kmem order =compound_order (page);inc_slabs_node (s,page_to_nid (page), page->objects); -memcg_bind_pages (s, order); page->slab_cache = s;__SetPageSlab (page);if (page->pfmemalloc)
@@ -1478,7 +1477,6 @@ static void __free_slab(struct kmem_cach__ClearPageSlabPfmemalloc (page);__ClearPageSlab (page); -memcg_release_pages (s, order);page_mapcount_reset (page);if (current->reclaim_state) current->reclaim_state->reclaimed_slab += pages;
_
Patches currently in -mm which might be from [email protected] are
slub-fix-memcg_propagate_slab_attrs.patch slb-charge-slabs-to-kmemcg-explicitly.patch mm-get-rid-of-__gfp_kmemcg.patch mm-get-rid-of-__gfp_kmemcg-fix.patch slab-document-kmalloc_order.patch memcg-un-export-__memcg_kmem_get_cache.patch mem-hotplug-implement-get-put_online_mems.patch slab-get_online_mems-for-kmem_cache_createdestroyshrink.patch documentation-memcg-warn-about-incomplete-kmemcg-state.patch memcg-slab-do-not-schedule-cache-destruction-when-last-page-goes-away.patch memcg-slab-merge-memcg_bindrelease_pages-to-memcg_uncharge_slab.patch memcg-slab-simplify-synchronization-scheme.patch