Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1950880pxb; Fri, 5 Mar 2021 03:56:14 -0800 (PST) X-Google-Smtp-Source: ABdhPJxb+xHPWBwZ4S/cJ27ZSCqSA1ob2vraio7oRwmD/Rn0Nlm3wV0M9FaAtQJIbjy3vBM/9TDt X-Received: by 2002:a50:f311:: with SMTP id p17mr9115646edm.188.1614945374582; Fri, 05 Mar 2021 03:56:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614945374; cv=none; d=google.com; s=arc-20160816; b=eopL7DHJA5TohhJvIr9mHMyfzaA/hrCHfFfwR2XeQw+aNXs9nlbh0MWLG3nkka5nHk EKsgVtu1kgw+ct0uSdkVTIBL1Awjh5b5AYjSmkeg+5CFd7jnyz+WjYL04flDEoUkWx6O gCGcgHnyAxNnZ+DiMbU0fSPtvbq1ysp80pzwHogATX6CDKSYVylK21wJiNBBvgg7xgVL i/G3oMYWk4uxWuH10MKIqYh4M3PK0UJ1JtoyVNo6NEBYkoAvCQlmf+s7CC1/sDRw3Rpa 1nLm5KH8Q95ZwfcCqjYB2wx/z5RPLvnrYckPvYkj5tiYFmwZq/xf4Dhdldn9JEgl7QVW Nf6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=IGTdulojVqDfD4uEHxN4sJQiQBIBDS74gP8QP9Wo5Ac=; b=GYTNtb7f3nDF+w9K/6IBKowg8QsBHWMOJLl7FaUfxJgFF2aYIp3+of9lMcWQ1w0kq1 tQrHhMW/2Sz0zcxZ9mx5Q63T3IESqwvio+jWB5pGP7KZqLd5IPj9Lqj9rfz4VYP3ZssM UNTiCt5lJtwNRcAT2vweYjUgV7pcy8xQCjEWgXVvc63/HLdAtAhUWA2JWzAb54nWSUS/ w2ZuoXhKEemLJwL+JAnhzL6pMuyDge85sCtKkFhsDqSGjVSKW2B3Y6d1JfJ9X1D4Ufj0 +d+rgAYHwbQbnWPDacjQsyEGPCt75uPdc5psjeZBl4r4zhRbR3Ts7/7jwrDZy8unq4eD +l/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=mbsYFZ8b; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id zd21si1226379ejb.634.2021.03.05.03.55.51; Fri, 05 Mar 2021 03:56:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=mbsYFZ8b; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229591AbhCELxH (ORCPT + 99 others); Fri, 5 Mar 2021 06:53:07 -0500 Received: from mx2.suse.de ([195.135.220.15]:45618 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229729AbhCELwy (ORCPT ); Fri, 5 Mar 2021 06:52:54 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1614945173; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=IGTdulojVqDfD4uEHxN4sJQiQBIBDS74gP8QP9Wo5Ac=; b=mbsYFZ8bGlG0dPGdUPBHfoJUs5T9hVelb/uXsxSKMr/eWuZOxCWQ+1EEPjGTV+06u1eZwA QcUMjWuLjUGnf0VBWwn+PtZKUmZqfyTUIfTrzrYKPcHyml5zD534VQcvMzWKAKSGT9dBJ7 GNCG6jSSQGVjQkPL/iqaiWvjSduoOl8= Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 0CAEBAC54; Fri, 5 Mar 2021 11:52:53 +0000 (UTC) Date: Fri, 5 Mar 2021 12:52:52 +0100 From: Michal Hocko To: Zhou Guanghui Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, akpm@linux-foundation.org, hannes@cmpxchg.org, hughd@google.com, kirill.shutemov@linux.intel.com, npiggin@gmail.com, ziy@nvidia.com, wangkefeng.wang@huawei.com, guohanjun@huawei.com, dingtianhong@huawei.com, chenweilong@huawei.com, rui.xiang@huawei.com Subject: Re: [PATCH v2 2/2] mm/memcg: set memcg when split page Message-ID: References: <20210304074053.65527-1-zhouguanghui1@huawei.com> <20210304074053.65527-3-zhouguanghui1@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210304074053.65527-3-zhouguanghui1@huawei.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu 04-03-21 07:40:53, Zhou Guanghui wrote: > As described in the split_page function comment, for the non-compound > high order page, the sub-pages must be freed individually. If the > memcg of the fisrt page is valid, the tail pages cannot be uncharged > when be freed. > > For example, when alloc_pages_exact is used to allocate 1MB continuous > physical memory, 2MB is charged(kmemcg is enabled and __GFP_ACCOUNT is > set). When make_alloc_exact free the unused 1MB and free_pages_exact > free the applied 1MB, actually, only 4KB(one page) is uncharged. > > Therefore, the memcg of the tail page needs to be set when split page. > As already mentioned there are at least two explicit users of __GFP_ACCOUNT with alloc_exact_pages added recently. It would be good to mention that explicitly and maybe even mention 7efe8ef274024 resp. c419621873713 so that it is clear this is not just a theoretical issue. > Signed-off-by: Zhou Guanghui Acked-by: Michal Hocko > --- > mm/page_alloc.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/mm/page_alloc.c b/mm/page_alloc.c > index 3e4b29ee2b1e..3ed783e25c3c 100644 > --- a/mm/page_alloc.c > +++ b/mm/page_alloc.c > @@ -3310,6 +3310,7 @@ void split_page(struct page *page, unsigned int order) > for (i = 1; i < (1 << order); i++) > set_page_refcounted(page + i); > split_page_owner(page, 1 << order); > + split_page_memcg(page, 1 << order); > } > EXPORT_SYMBOL_GPL(split_page); > > -- > 2.25.0 > -- Michal Hocko SUSE Labs