Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756033Ab2FZJUW (ORCPT ); Tue, 26 Jun 2012 05:20:22 -0400 Received: from mx2.parallels.com ([64.131.90.16]:39093 "EHLO mx2.parallels.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754286Ab2FZJUV (ORCPT ); Tue, 26 Jun 2012 05:20:21 -0400 Message-ID: <4FE97E31.3010201@parallels.com> Date: Tue, 26 Jun 2012 13:17:37 +0400 From: Glauber Costa User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:13.0) Gecko/20120605 Thunderbird/13.0 MIME-Version: 1.0 To: David Rientjes CC: , , Andrew Morton , , Frederic Weisbecker , Pekka Enberg , Michal Hocko , Johannes Weiner , Christoph Lameter , , , Tejun Heo , Pekka Enberg Subject: Re: [PATCH 06/11] memcg: kmem controller infrastructure References: <1340633728-12785-1-git-send-email-glommer@parallels.com> <1340633728-12785-7-git-send-email-glommer@parallels.com> In-Reply-To: Content-Type: text/plain; charset="ISO-8859-1"; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2471 Lines: 71 On 06/26/2012 01:12 PM, David Rientjes wrote: > On Mon, 25 Jun 2012, Glauber Costa wrote: > >> diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h >> index 83e7ba9..22479eb 100644 >> --- a/include/linux/memcontrol.h >> +++ b/include/linux/memcontrol.h >> @@ -21,6 +21,7 @@ >> #define _LINUX_MEMCONTROL_H >> #include >> #include >> +#include >> >> struct mem_cgroup; >> struct page_cgroup; >> @@ -409,6 +410,12 @@ struct sock; >> #ifdef CONFIG_CGROUP_MEM_RES_CTLR_KMEM >> void sock_update_memcg(struct sock *sk); >> void sock_release_memcg(struct sock *sk); >> + >> +#define mem_cgroup_kmem_on 1 >> +bool __mem_cgroup_new_kmem_page(gfp_t gfp, void *handle, int order); >> +void __mem_cgroup_commit_kmem_page(struct page *page, void *handle, int order); >> +void __mem_cgroup_free_kmem_page(struct page *page, int order); >> +#define is_kmem_tracked_alloc (gfp & __GFP_KMEMCG) >> #else >> static inline void sock_update_memcg(struct sock *sk) >> { >> @@ -416,6 +423,43 @@ static inline void sock_update_memcg(struct sock *sk) >> static inline void sock_release_memcg(struct sock *sk) >> { >> } >> + >> +#define mem_cgroup_kmem_on 0 >> +#define __mem_cgroup_new_kmem_page(a, b, c) false >> +#define __mem_cgroup_free_kmem_page(a,b ) >> +#define __mem_cgroup_commit_kmem_page(a, b, c) >> +#define is_kmem_tracked_alloc (false) >> #endif /* CONFIG_CGROUP_MEM_RES_CTLR_KMEM */ >> + >> +static __always_inline >> +bool mem_cgroup_new_kmem_page(gfp_t gfp, void *handle, int order) >> +{ >> + if (!mem_cgroup_kmem_on) >> + return true; >> + if (!is_kmem_tracked_alloc) >> + return true; >> + if (!current->mm) >> + return true; >> + if (in_interrupt()) >> + return true; > > You can't test for current->mm in irq context, so you need to check for > in_interrupt() first. > Right, thanks. > Also, what prevents __mem_cgroup_new_kmem_page() > from being called for a kthread that has called use_mm() before > unuse_mm()? Nothing, but I also don't see how to prevent that. At a first glance, it seems fair to me to say that if a kernel thread uses the mm of a process, it poses as this process for any accounting purpose. -- 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/