From mboxrd@z Thu Jan 1 00:00:00 1970 From: Tejun Heo Subject: [PATCH 3/7] memcg: immigrate charges only when a threadgroup leader is moved Date: Mon, 18 May 2015 15:49:51 -0400 Message-ID: <1431978595-12176-4-git-send-email-tj@kernel.org> References: <1431978595-12176-1-git-send-email-tj@kernel.org> Return-path: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=LSz6YeTfhe7MAwTOX3xmiG/EBzZzEDIwIgWqnIR2y54=; b=uxYuB1bwlleCr34P+Da2e80c70JYGOlKrrUzR5HSXeblCeXsPawXvIA9af7+xJbiy2 zsU8FzDlX3t0eD3cF03yAY9pQIHtmui3B0oAC7X5zC5l6JGFUR80OtJdZ6LVHDqcUiP9 9PDWnQmUJFv8AQVHEOok7QfzcAA0nMLe1N7QEcLXV4/uxaFAlMJUtE4/ljeH5cZfUJ21 z7bvXCd0HnjyxAOmeWd3WAV8SnMgRwVS/P2SL5y80DL1AK9csrnsRjtmJjHzPc1mVYEj wjkLQ5QThsQufL4Z+/W/tbZhmeW+HqzK9MiH8RAmOkeHQFL+uqy+nWMjjGJOGwt3/elm 1T8Q== In-Reply-To: <1431978595-12176-1-git-send-email-tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org> Sender: cgroups-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org List-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: lizefan-hv44wF8Li93QT0dZR+AlfA@public.gmane.org Cc: cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, hannes-druUgvl0LCNAfugRpC6u6w@public.gmane.org, mhocko-AlSwsSmVLrQ@public.gmane.org, linux-mm-Bw31MaZKKs3YtjvyW6yDsg@public.gmane.org, Tejun Heo If move_charge flag is set, memcg tries to move memory charges to the destnation css. The current implementation migrates memory whenever any thread of a process is migrated making the behavior somewhat arbitrary. Let's tie memory operations to the threadgroup leader so that memory is migrated only when the leader is migrated. While this is a behavior change, given the inherent fuziness, this change is not too likely to be noticed and allows us to clearly define who owns the memory (always the leader) and helps the planned atomic multi-process migration. Signed-off-by: Tejun Heo Cc: Johannes Weiner Cc: Michal Hocko --- mm/memcontrol.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index b1b834d..74fcea3 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -5014,6 +5014,9 @@ static int mem_cgroup_can_attach(struct cgroup_subsys_state *css, return 0; p = cgroup_taskset_first(tset); + if (!thread_group_leader(p)) + return 0; + from = mem_cgroup_from_task(p); VM_BUG_ON(from == memcg); -- 2.4.0