Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752658AbaDCPEM (ORCPT ); Thu, 3 Apr 2014 11:04:12 -0400 Received: from relay.parallels.com ([195.214.232.42]:32781 "EHLO relay.parallels.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752302AbaDCPEI (ORCPT ); Thu, 3 Apr 2014 11:04:08 -0400 Message-ID: <533D7864.7080907@parallels.com> Date: Thu, 3 Apr 2014 19:04:04 +0400 From: Vladimir Davydov MIME-Version: 1.0 To: Greg Thelen CC: , , , , , , Subject: Re: [PATCH -mm v2.1] mm: get rid of __GFP_KMEMCG References: <1396419365-351-1-git-send-email-vdavydov@parallels.com> In-Reply-To: Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.30.16.96] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 04/03/2014 01:25 AM, Greg Thelen wrote: > On Tue, Apr 01 2014, Vladimir Davydov wrote: > >> Currently to allocate a page that should be charged to kmemcg (e.g. >> threadinfo), we pass __GFP_KMEMCG flag to the page allocator. The page >> allocated is then to be freed by free_memcg_kmem_pages. Apart from >> looking asymmetrical, this also requires intrusion to the general >> allocation path. So let's introduce separate functions that will >> alloc/free pages charged to kmemcg. >> >> The new functions are called alloc_kmem_pages and free_kmem_pages. They >> should be used when the caller actually would like to use kmalloc, but >> has to fall back to the page allocator for the allocation is large. They >> only differ from alloc_pages and free_pages in that besides allocating >> or freeing pages they also charge them to the kmem resource counter of >> the current memory cgroup. >> >> Signed-off-by: Vladimir Davydov > One comment nit below, otherwise looks good to me. > > Acked-by: Greg Thelen > >> Cc: Johannes Weiner >> Cc: Michal Hocko >> Cc: Glauber Costa >> Cc: Christoph Lameter >> Cc: Pekka Enberg >> --- >> Changes in v2.1: >> - add missing kmalloc_order forward declaration; lacking it caused >> compilation breakage with CONFIG_TRACING=n >> >> include/linux/gfp.h | 10 ++++--- >> include/linux/memcontrol.h | 2 +- >> include/linux/slab.h | 11 +------- >> include/linux/thread_info.h | 2 -- >> include/trace/events/gfpflags.h | 1 - >> kernel/fork.c | 6 ++--- >> mm/page_alloc.c | 56 ++++++++++++++++++++++++--------------- >> mm/slab_common.c | 12 +++++++++ >> mm/slub.c | 6 ++--- >> 9 files changed, 61 insertions(+), 45 deletions(-) >> >> diff --git a/include/linux/gfp.h b/include/linux/gfp.h >> index 39b81dc7d01a..d382db71e300 100644 >> --- a/include/linux/gfp.h >> +++ b/include/linux/gfp.h >> @@ -31,7 +31,6 @@ struct vm_area_struct; >> #define ___GFP_HARDWALL 0x20000u >> #define ___GFP_THISNODE 0x40000u >> #define ___GFP_RECLAIMABLE 0x80000u >> -#define ___GFP_KMEMCG 0x100000u >> #define ___GFP_NOTRACK 0x200000u >> #define ___GFP_NO_KSWAPD 0x400000u >> #define ___GFP_OTHER_NODE 0x800000u >> @@ -91,7 +90,6 @@ struct vm_area_struct; >> >> #define __GFP_NO_KSWAPD ((__force gfp_t)___GFP_NO_KSWAPD) >> #define __GFP_OTHER_NODE ((__force gfp_t)___GFP_OTHER_NODE) /* On behalf of other node */ >> -#define __GFP_KMEMCG ((__force gfp_t)___GFP_KMEMCG) /* Allocation comes from a memcg-accounted resource */ >> #define __GFP_WRITE ((__force gfp_t)___GFP_WRITE) /* Allocator intends to dirty page */ >> >> /* >> @@ -353,6 +351,10 @@ extern struct page *alloc_pages_vma(gfp_t gfp_mask, int order, >> #define alloc_page_vma_node(gfp_mask, vma, addr, node) \ >> alloc_pages_vma(gfp_mask, 0, vma, addr, node) >> >> +extern struct page *alloc_kmem_pages(gfp_t gfp_mask, unsigned int order); >> +extern struct page *alloc_kmem_pages_node(int nid, gfp_t gfp_mask, >> + unsigned int order); >> + >> extern unsigned long __get_free_pages(gfp_t gfp_mask, unsigned int order); >> extern unsigned long get_zeroed_page(gfp_t gfp_mask); >> >> @@ -372,8 +374,8 @@ extern void free_pages(unsigned long addr, unsigned int order); >> extern void free_hot_cold_page(struct page *page, int cold); >> extern void free_hot_cold_page_list(struct list_head *list, int cold); >> >> -extern void __free_memcg_kmem_pages(struct page *page, unsigned int order); >> -extern void free_memcg_kmem_pages(unsigned long addr, unsigned int order); >> +extern void __free_kmem_pages(struct page *page, unsigned int order); >> +extern void free_kmem_pages(unsigned long addr, unsigned int order); >> >> #define __free_page(page) __free_pages((page), 0) >> #define free_page(addr) free_pages((addr), 0) >> diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h >> index 29068dd26c3d..13acdb5259f5 100644 >> --- a/include/linux/memcontrol.h >> +++ b/include/linux/memcontrol.h >> @@ -543,7 +543,7 @@ memcg_kmem_newpage_charge(gfp_t gfp, struct mem_cgroup **memcg, int order) >> * res_counter_charge_nofail, but we hope those allocations are rare, >> * and won't be worth the trouble. >> */ > Just a few lines higher in first memcg_kmem_newpage_charge() comment, > there is a leftover reference to GFP_KMEMCG which should be removed. Good catch, will resend. Thank you for the review! -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/