Received: by 10.192.165.148 with SMTP id m20csp297125imm; Fri, 4 May 2018 10:27:54 -0700 (PDT) X-Google-Smtp-Source: AB8JxZr77+JDETa+Cmr1RkxmLNG8jxG56wKuWxL8aacMCd2OEm5y44yCMf6UuGU0R1t+1+DZmWKH X-Received: by 2002:a17:902:8f95:: with SMTP id z21-v6mr24257475plo.259.1525454874325; Fri, 04 May 2018 10:27:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525454874; cv=none; d=google.com; s=arc-20160816; b=tQLsrLDfeC9w6/KnIItX7u0UG0H59KO4NOCoKcHJ+JaCE85mTah+O1o5Q/x9MiR5sp lk1M8vmWh9wyi2zvtl5g7GuH8IeE/yME1swEJ7EHJQxdoT8IXwVcI3YiTGiUF4W17hnU Ty9hecFRI0huGXPSRm7X+oTg0n/49auzLTBWbcE3L7Gsh/GQakg/oRgfJvGBX6D/35u6 nxbF/sqpSYs9Fs1BdwwX7z//PNC9Ifo/YvV8yQCO9C9KuEvhEi9GUmdoOneqGWw33LZo TEtCs7LtvMIbZzrLBl3IsClCnj4L8jVpsvv5Evtl24LMaQHk/qoJV9HVv2uoxzu51D1S WgdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:subject:mime-version:user-agent :message-id:in-reply-to:date:references:cc:to:from :arc-authentication-results; bh=tGNlDCP9p0nx3kFruY+zwYkLMBgZAlueBclaTn3BrPg=; b=I+k9tVdWdb7ksNP13WyLNKqeHuQp+6NtipgOMjYlyX0GinTUQZjieLS5ihSeNjYzFc s94Cq8xDZoDtyhvBGCEAWuyXmZdqXYHY+cvgMpa+xQQo9V9JhPuJVd+KOb8Oq1cGSS70 /8kts+11W5xG2yyhIOdi344haDJ6MxtI7eOjX/jXfJqdHlGCb6Siu3NXx7b0Qd8XJr0Y Q85uJQGZsFC1nIO0ycPxYm0asFqRbuNKK2KtPvu4ImcNNW+OUusNkndnm2Dv924padKB KLa1zz9l7K5UFUBfihX3b+KJE+Zv6J/zaqhYrsEXaJjdsASoxsoSujPkByYCXhrjCra7 KNRA== 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 q9-v6si12926968pgp.226.2018.05.04.10.27.40; Fri, 04 May 2018 10:27:54 -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 S1751756AbeEDR1C (ORCPT + 99 others); Fri, 4 May 2018 13:27:02 -0400 Received: from out02.mta.xmission.com ([166.70.13.232]:51255 "EHLO out02.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751470AbeEDR1B (ORCPT ); Fri, 4 May 2018 13:27:01 -0400 Received: from in01.mta.xmission.com ([166.70.13.51]) by out02.mta.xmission.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.87) (envelope-from ) id 1fEeU0-0001CQ-CQ; Fri, 04 May 2018 11:27:00 -0600 Received: from [97.119.174.25] (helo=x220.xmission.com) by in01.mta.xmission.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.87) (envelope-from ) id 1fEeTz-0002iN-IB; Fri, 04 May 2018 11:27:00 -0600 From: ebiederm@xmission.com (Eric W. Biederman) To: Andrew Morton Cc: Johannes Weiner , Michal Hocko , 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 References: <87h8nr2sa3.fsf_-_@xmission.com> <20180502084708.GC26305@dhcp22.suse.cz> <20180502132026.GB16060@cmpxchg.org> <87lgd1zww0.fsf_-_@xmission.com> <20180503133338.GA23401@redhat.com> <87y3h0x0qg.fsf@xmission.com> <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> Date: Fri, 04 May 2018 12:26:51 -0500 In-Reply-To: <87tvrncoyc.fsf_-_@xmission.com> (Eric W. Biederman's message of "Fri, 04 May 2018 12:26:03 -0500") Message-ID: <87lgczcox0.fsf_-_@xmission.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-XM-SPF: eid=1fEeTz-0002iN-IB;;;mid=<87lgczcox0.fsf_-_@xmission.com>;;;hst=in01.mta.xmission.com;;;ip=97.119.174.25;;;frm=ebiederm@xmission.com;;;spf=neutral X-XM-AID: U2FsdGVkX19oAP8d0+WTkiVC4VwnD1Lxvo/1+nkler0= X-SA-Exim-Connect-IP: 97.119.174.25 X-SA-Exim-Mail-From: ebiederm@xmission.com X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on sa07.xmission.com X-Spam-Level: ** X-Spam-Status: No, score=2.0 required=8.0 tests=ALL_TRUSTED,BAYES_50, DCC_CHECK_NEGATIVE,T_TooManySym_01,T_TooManySym_02,T_TooManySym_03, T_TooManySym_04,XMNoVowels,XMSubLong autolearn=disabled version=3.4.1 X-Spam-Report: * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP * 0.7 XMSubLong Long Subject * 1.5 XMNoVowels Alpha-numberic number with no vowels * 0.8 BAYES_50 BODY: Bayes spam probability is 40 to 60% * [score: 0.5000] * -0.0 DCC_CHECK_NEGATIVE Not listed in DCC * [sa07 1397; Body=1 Fuz1=1 Fuz2=1] * 0.0 T_TooManySym_01 4+ unique symbols in subject * 0.0 T_TooManySym_04 7+ unique symbols in subject * 0.0 T_TooManySym_03 6+ unique symbols in subject * 0.0 T_TooManySym_02 5+ unique symbols in subject X-Spam-DCC: XMission; sa07 1397; Body=1 Fuz1=1 Fuz2=1 X-Spam-Combo: **;Andrew Morton X-Spam-Relay-Country: X-Spam-Timing: total 356 ms - load_scoreonly_sql: 0.04 (0.0%), signal_user_changed: 2.1 (0.6%), b_tie_ro: 1.35 (0.4%), parse: 0.87 (0.2%), extract_message_metadata: 10 (2.9%), get_uri_detail_list: 2.2 (0.6%), tests_pri_-1000: 6 (1.6%), tests_pri_-950: 1.08 (0.3%), tests_pri_-900: 0.95 (0.3%), tests_pri_-400: 30 (8.4%), check_bayes: 29 (8.1%), b_tokenize: 11 (3.1%), b_tok_get_all: 9 (2.6%), b_comp_prob: 3.0 (0.8%), b_tok_touch_all: 3.2 (0.9%), b_finish: 0.63 (0.2%), tests_pri_0: 298 (83.9%), check_dkim_signature: 0.55 (0.2%), check_dkim_adsp: 3.5 (1.0%), tests_pri_500: 4.2 (1.2%), rewrite_mail: 0.00 (0.0%) Subject: [PATCH 1/2] memcg: Update the mm->memcg maintenance to work when !CONFIG_MMU X-Spam-Flag: No X-SA-Exim-Version: 4.2.1 (built Thu, 05 May 2016 13:38:54 -0600) X-SA-Exim-Scanned: Yes (on in01.mta.xmission.com) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Michal Hocko reported: > I am getting the following for nommu with MEMCG=y randconfig: > kernel/fork.o: In function `mm_init': > fork.c:(.text+0x948): undefined reference to `mm_update_memcg' > kernel/fork.o: In function `mmput': > fork.c:(.text+0x119c): undefined reference to `mm_update_memcg' > make: *** [vmlinux] Error 1 A memory control group that only accounts mm activity on page fault seems pointless when !MMU. Still I don't intend to break it so move the mm->memcg changes out of #ifndef MMU. Reported-by: Michal Hocko Signed-off-by: "Eric W. Biederman" --- mm/memcontrol.c | 109 ++++++++++++++++++++++++++------------------------------ 1 file changed, 51 insertions(+), 58 deletions(-) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index a3745ccbd8c0..d74aeba7dfed 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -4846,59 +4846,6 @@ static int mem_cgroup_can_attach(struct cgroup_taskset *tset) return ret; } -/** - * mm_update_memcg - Update the memory cgroup of a mm_struct - * @mm: mm struct - * @new: new memory cgroup value - * - * Called whenever mm->memcg needs to change. Consumes a reference - * to new (unless new is NULL). The reference to the old memory - * cgroup is decreased. - */ -void mm_update_memcg(struct mm_struct *mm, struct mem_cgroup *new) -{ - /* This is the only place where mm->memcg is changed */ - struct mem_cgroup *old; - - old = xchg(&mm->memcg, new); - if (old) - css_put(&old->css); -} - -static void task_update_memcg(struct task_struct *tsk, struct mem_cgroup *new) -{ - struct mm_struct *mm; - task_lock(tsk); - mm = tsk->mm; - if (mm && !(tsk->flags & PF_KTHREAD)) - mm_update_memcg(mm, new); - task_unlock(tsk); -} - -static void mem_cgroup_attach(struct cgroup_taskset *tset) -{ - struct cgroup_subsys_state *css; - struct task_struct *tsk; - - cgroup_taskset_for_each(tsk, css, tset) { - struct mem_cgroup *new = mem_cgroup_from_css(css); - css_get(css); - task_update_memcg(tsk, new); - } -} - -static void mem_cgroup_fork(struct task_struct *tsk) -{ - struct cgroup_subsys_state *css; - - rcu_read_lock(); - css = task_css(tsk, memory_cgrp_id); - if (css && css_tryget(css)) - task_update_memcg(tsk, mem_cgroup_from_css(css)); - rcu_read_unlock(); -} - - static void mem_cgroup_cancel_attach(struct cgroup_taskset *tset) { if (mc.to) @@ -5067,19 +5014,65 @@ static int mem_cgroup_can_attach(struct cgroup_taskset *tset) { return 0; } -static void mem_cgroup_attach(struct cgroup_taskset *tset) +static void mem_cgroup_cancel_attach(struct cgroup_taskset *tset) { } -static void mem_cgroup_fork(struct task_struct *task) +static void mem_cgroup_move_task(void) { } -static void mem_cgroup_cancel_attach(struct cgroup_taskset *tset) +#endif + +/** + * mm_update_memcg - Update the memory cgroup of a mm_struct + * @mm: mm struct + * @new: new memory cgroup value + * + * Called whenever mm->memcg needs to change. Consumes a reference + * to new (unless new is NULL). The reference to the old memory + * cgroup is decreased. + */ +void mm_update_memcg(struct mm_struct *mm, struct mem_cgroup *new) { + /* This is the only place where mm->memcg is changed */ + struct mem_cgroup *old; + + old = xchg(&mm->memcg, new); + if (old) + css_put(&old->css); } -static void mem_cgroup_move_task(void) + +static void task_update_memcg(struct task_struct *tsk, struct mem_cgroup *new) +{ + struct mm_struct *mm; + task_lock(tsk); + mm = tsk->mm; + if (mm && !(tsk->flags & PF_KTHREAD)) + mm_update_memcg(mm, new); + task_unlock(tsk); +} + +static void mem_cgroup_attach(struct cgroup_taskset *tset) { + struct cgroup_subsys_state *css; + struct task_struct *tsk; + + cgroup_taskset_for_each(tsk, css, tset) { + struct mem_cgroup *new = mem_cgroup_from_css(css); + css_get(css); + task_update_memcg(tsk, new); + } +} + +static void mem_cgroup_fork(struct task_struct *tsk) +{ + struct cgroup_subsys_state *css; + + rcu_read_lock(); + css = task_css(tsk, memory_cgrp_id); + if (css && css_tryget(css)) + task_update_memcg(tsk, mem_cgroup_from_css(css)); + rcu_read_unlock(); } -#endif /* * Cgroup retains root cgroups across [un]mount cycles making it necessary -- 2.14.1