Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp2950039imm; Thu, 24 May 2018 19:43:44 -0700 (PDT) X-Google-Smtp-Source: AB8JxZroFSDOgjkC5zTWs+913a/VhdYlnG6TkZaUskoadYTIHhWyGFdGs/eDk9xdkONiJ8sQUL1S X-Received: by 2002:a17:902:988b:: with SMTP id s11-v6mr623202plp.304.1527216224708; Thu, 24 May 2018 19:43:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527216224; cv=none; d=google.com; s=arc-20160816; b=taWpQvYKYVxqRPV1F9owzj2jj9dm3iTpxM9LPBQtC897ASNb5BvjIPvpgYNJ3lx8ya JnYMR0u0Jyw2Xql7TTXHW6rEVOwd8N6fNH8NCrS08+iiU/1DVh8Wv985IOtg9JNzh+AL 6cr1dMkxXtheQgS1lCiH8hMYlfcknZFlo/B4z88l8pgyWn9hXcQUW+d0g1iTZuH+hHa+ kTx3LMmOu+lf6P1/fE2XsKEB1iAIlSPT2k4fiCplUCEKyvI9vOR2KovbGe2AL2rM5pai d66m8St7mXw+yEnkaIWqE1tmNbWrHKtenvFIvHNmprMu3JvuvVYtLa5crLHILMjOSPRo QQDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :arc-authentication-results; bh=0QpKjez741MZU+7To/Ez8M4XG2E5K0rbn1FML/Oguac=; b=LL3Bej6G04z3FyQDrIToOfnhTHQ5QYN5BMbp6oRGuV6Tf1GZRMeMps6fvpMhxFkXJY +UBieFcIwWGBSf6GqHzg3GiY/4GYORTz8cD5th2Q30YCkojbxyBGPQsK5kGJbRdPpX4g kouM5RBYcDJmiMo2r2kJPD3EObNT/aR4DIuHmR7yum1kea0QH5ZMwFfyEQRcJEsA34Pg 8ilPCmmQ9/mldtVRRpUfH9GKyRcdpbZf055/fEDsNJcINGJnPmCFzjk2WkgTcDwUL767 qMJQdj7bw1LYPeUzpBBTOVdFdow9PqPlTP8dOwxU2FH4lLzHb4jR+/HZeHHZt2VHNx2R pD1g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z20-v6si509201pfl.209.2018.05.24.19.43.30; Thu, 24 May 2018 19:43:44 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S971606AbeEXVRK (ORCPT + 99 others); Thu, 24 May 2018 17:17:10 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:46208 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S967358AbeEXVRJ (ORCPT ); Thu, 24 May 2018 17:17:09 -0400 Received: from akpm3.svl.corp.google.com (unknown [104.133.9.71]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 9B376D0A; Thu, 24 May 2018 21:17:07 +0000 (UTC) Date: Thu, 24 May 2018 14:17:06 -0700 From: Andrew Morton To: Michal Hocko Cc: "Eric W. Biederman" , Johannes Weiner , Kirill Tkhai , peterz@infradead.org, viro@zeniv.linux.org.uk, mingo@kernel.org, paulmck@linux.vnet.ibm.com, keescook@chromium.org, riel@redhat.com, tglx@linutronix.de, kirill.shutemov@linux.intel.com, marcos.souza.org@gmail.com, hoeun.ryu@gmail.com, pasha.tatashin@oracle.com, gs051095@gmail.com, dhowells@redhat.com, rppt@linux.vnet.ibm.com, linux-kernel@vger.kernel.org, Balbir Singh , Tejun Heo , Oleg Nesterov Subject: Re: [PATCH 0/2] mm->owner to mm->memcg fixes Message-Id: <20180524141706.049f1baa9eba1afd041b4820@linux-foundation.org> In-Reply-To: <20180524111002.GB20441@dhcp22.suse.cz> References: <20180504142056.GA26151@redhat.com> <87r2mrh4is.fsf@xmission.com> <20180504145435.GA26573@redhat.com> <87y3gzfmjt.fsf@xmission.com> <20180504162209.GB26573@redhat.com> <871serfk77.fsf@xmission.com> <87tvrncoyc.fsf_-_@xmission.com> <20180510121418.GD5325@dhcp22.suse.cz> <20180522125757.GL20020@dhcp22.suse.cz> <87wovu889o.fsf@xmission.com> <20180524111002.GB20441@dhcp22.suse.cz> X-Mailer: Sylpheed 3.6.0 (GTK+ 2.24.31; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 24 May 2018 13:10:02 +0200 Michal Hocko wrote: > I would really prefer and appreciate a repost with all the fixes folded > in. [2/2] From: Andrew Morton Subject: mm/memcontrol.c: add mem_cgroup_from_task() as a local helper Factor out some commonly-occurring code. Cc: "Eric W. Biederman" Cc: Johannes Weiner Cc: "Kirill A. Shutemov" Cc: Kirill Tkhai Cc: Michal Hocko Cc: Tejun Heo Signed-off-by: Andrew Morton --- mm/memcontrol.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff -puN mm/memcontrol.c~mm-memcontrolc-add-mem_cgroup_from_task-as-a-local-helper mm/memcontrol.c --- a/mm/memcontrol.c~mm-memcontrolc-add-mem_cgroup_from_task-as-a-local-helper +++ a/mm/memcontrol.c @@ -664,6 +664,11 @@ static void memcg_check_events(struct me } } +static inline struct mem_cgroup *mem_cgroup_from_task(struct task_struct *p) +{ + return mem_cgroup_from_css(task_css(p, memory_cgrp_id)); +} + struct mem_cgroup *get_mem_cgroup_from_mm(struct mm_struct *mm) { struct mem_cgroup *memcg = NULL; @@ -1011,7 +1016,7 @@ bool task_in_mem_cgroup(struct task_stru * killed to prevent needlessly killing additional tasks. */ rcu_read_lock(); - task_memcg = mem_cgroup_from_css(task_css(task, memory_cgrp_id)); + task_memcg = mem_cgroup_from_task(task); css_get(&task_memcg->css); rcu_read_unlock(); } @@ -4836,7 +4841,7 @@ static int mem_cgroup_can_attach(struct if (!move_flags) return 0; - from = mem_cgroup_from_css(task_css(p, memory_cgrp_id)); + from = mem_cgroup_from_task(p); VM_BUG_ON(from == memcg); @@ -5887,7 +5892,7 @@ void mem_cgroup_sk_alloc(struct sock *sk } rcu_read_lock(); - memcg = mem_cgroup_from_css(task_css(current, memory_cgrp_id)); + memcg = mem_cgroup_from_task(current); if (memcg == root_mem_cgroup) goto out; if (!cgroup_subsys_on_dfl(memory_cgrp_subsys) && !memcg->tcpmem_active) _