From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,PDS_BAD_THREAD_QP_64, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BDF40C433DB for ; Wed, 3 Mar 2021 09:16:03 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id AD79764EEE for ; Wed, 3 Mar 2021 09:16:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AD79764EEE Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=huawei.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 03C828D013B; Wed, 3 Mar 2021 04:16:02 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 0132D8D0135; Wed, 3 Mar 2021 04:16:01 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E1CD48D013B; Wed, 3 Mar 2021 04:16:01 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0171.hostedemail.com [216.40.44.171]) by kanga.kvack.org (Postfix) with ESMTP id C69EB8D0135 for ; Wed, 3 Mar 2021 04:16:01 -0500 (EST) Received: from smtpin14.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 7A202363B for ; Wed, 3 Mar 2021 09:16:01 +0000 (UTC) X-FDA: 77878006122.14.D08C8C4 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf13.hostedemail.com (Postfix) with ESMTP id BC0A1E0011F1 for ; Wed, 3 Mar 2021 09:15:58 +0000 (UTC) Received: from DGGEMM404-HUB.china.huawei.com (unknown [172.30.72.54]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4Dr7bp3qh5z5YCd; Wed, 3 Mar 2021 17:14:14 +0800 (CST) Received: from dggema772-chm.china.huawei.com (10.1.198.214) by DGGEMM404-HUB.china.huawei.com (10.3.20.212) with Microsoft SMTP Server (TLS) id 14.3.498.0; Wed, 3 Mar 2021 17:15:56 +0800 Received: from dggeme755-chm.china.huawei.com (10.3.19.101) by dggema772-chm.china.huawei.com (10.1.198.214) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2106.2; Wed, 3 Mar 2021 17:15:55 +0800 Received: from dggeme755-chm.china.huawei.com ([10.7.64.71]) by dggeme755-chm.china.huawei.com ([10.7.64.71]) with mapi id 15.01.2106.006; Wed, 3 Mar 2021 17:15:55 +0800 From: "Zhouguanghui (OS Kernel)" To: Michal Hocko , Johannes Weiner CC: Hugh Dickins , "linux-kernel@vger.kernel.org" , "linux-mm@kvack.org" , "akpm@linux-foundation.org" , "Wangkefeng (OS Kernel Lab)" , "Guohanjun (Hanjun Guo)" , Dingtianhong , Chenweilong , "Xiangrui (Euler)" , Nicholas Piggin , "Kirill A. Shutemov" , Zi Yan Subject: Re: [PATCH] mm/memcg: set memcg when split pages Thread-Topic: [PATCH] mm/memcg: set memcg when split pages Thread-Index: AQHXD0TOPfGiAC+zfUG9IaYiC6n5KA== Date: Wed, 3 Mar 2021 09:15:55 +0000 Message-ID: References: <20210302013451.118701-1-zhouguanghui1@huawei.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.174.178.106] Content-Type: text/plain; charset="iso-2022-jp" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-CFilter-Loop: Reflected X-Stat-Signature: f4p7gyyp354da9u7sa91yi5bwwwojqf4 X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: BC0A1E0011F1 Received-SPF: none (huawei.com>: No applicable sender policy available) receiver=imf13; identity=mailfrom; envelope-from=""; helo=szxga02-in.huawei.com; client-ip=45.249.212.188 X-HE-DKIM-Result: none/none X-HE-Tag: 1614762958-132940 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: =1B$B:_=1B(B 2021/3/3 15:46, Michal Hocko =1B$B On Tue 02-03-21 17:56:07, Johannes Weiner wrote:=0A= >> On Tue, Mar 02, 2021 at 12:24:41PM -0800, Hugh Dickins wrote:=0A= >>> On Tue, 2 Mar 2021, Michal Hocko wrote:=0A= >>>> [Cc Johannes for awareness and fixup Nick's email]=0A= >>>>=0A= >>>> On Tue 02-03-21 01:34:51, Zhou Guanghui wrote:=0A= >>>>> When split page, the memory cgroup info recorded in first page is=0A= >>>>> not copied to tail pages. In this case, when the tail pages are=0A= >>>>> freed, the uncharge operation is not performed. As a result, the=0A= >>>>> usage of this memcg keeps increasing, and the OOM may occur.=0A= >>>>>=0A= >>>>> So, the copying of first page's memory cgroup info to tail pages=0A= >>>>> is needed when split page.=0A= >>>>=0A= >>>> I was not aware that alloc_pages_exact is used for accounted allocatio= ns=0A= >>>> but git grep told me otherwise so this is not a theoretical one. Both= =0A= >>>> users (arm64 and s390 kvm) are quite recent AFAICS. split_page is also= =0A= >>>> used in dma allocator but I got lost in indirection so I have no idea= =0A= >>>> whether there are any users there.=0A= >>>=0A= >>> Yes, it's a bit worrying that such a low-level thing as split_page()=0A= >>> can now get caught up in memcg accounting, but I suppose that's okay.= =0A= >>>=0A= >>> I feel rather strongly that whichever way it is done, THP splitting=0A= >>> and split_page() should use the same interface to memcg.=0A= >>>=0A= >>> And a look at mem_cgroup_split_huge_fixup() suggests that nowadays=0A= >>> there need to be css_get()s too - or better, a css_get_many().=0A= >>>=0A= >>> Its #ifdef CONFIG_TRANSPARENT_HUGEPAGE should be removed, rename=0A= >>> it mem_cgroup_split_page_fixup(), and take order from caller.=0A= >>=0A= >> +1=0A= >>=0A= >> There is already a split_page_owner() in both these places as well=0A= >> which does a similar thing. Mabye we can match that by calling it=0A= >> split_page_memcg() and having it take a nr of pages?=0A= > =0A= > Sounds good to me.=0A= > =0A= Hi, Michal, Johannes, Hugh, and Zi Yan, thank you for taking time for =0A= this.=0A= =0A= I agree, and will send v2 patches for taking these.=0A= =0A= Thanks=0A=