Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1582513pxb; Mon, 8 Mar 2021 00:48:50 -0800 (PST) X-Google-Smtp-Source: ABdhPJz5fHA0W1AQ6JuULdcLuluuARfzEDxjU++px15gTOOCjwqPg0L0SLlEpenbsdEeu3f8LcIW X-Received: by 2002:aa7:dbd3:: with SMTP id v19mr18550511edt.314.1615193329899; Mon, 08 Mar 2021 00:48:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615193329; cv=none; d=google.com; s=arc-20160816; b=KROJRBDJ6Pb0MU46gSSxH5wXzlfZ/xfLz6JZsWwKZlJbDZMxncW6gWvtNZkK0O1W2C JHC3dcVQqVNyZrw1hGKcVAOKPtb3iW4Bs1Q1o9wAttWbul3PJInBvJYVJbuoo0kceRNr 32yKbvrB06tjFAVW4yxyx8bhw5/3Kn1gky7/SjCwj+TcpOjil9+JsIInM8C6DJGygsZb HyP13ViFwjz4hq7NFiNS44nr9G3RaIzOsEFQBhh0A0+qpg7/T4lZ3kT7AR+7WiGrO3gX 0GyZUadtXEqm2LomFUKOLig5yM7O/DOM/78Td/uJidmgj9ngbraZzfI/KjQd0ZTeCPxU OExw== 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=IQsvUx1bc3HFAYXXFvyw7hGdS+2IRJnswNDb2Qjo34s=; b=AQFo1y5cODSEAD9QRGO/CgbxsIY49IyFawUY8kyYZU6qnbOWu2HLDHp/faqly/rtam S4NeZl8aSakLCjB9AGDtEP4DC0XYCwYhBF35iCMsizC9xCxdmgZJXDYnpbdg2MzczSWd cXvy5KsK/Yf16xFPUkZQhv3Qy57U087qiSvQIlvMdSdjpheIKL8jRuqSEzaNqct+Zldb pRQcrOFx9GBPBl1F4mzGMZmUbl0yLLtIpaQL3hZv2phP21pCq7AUoGmO0kB3+rGLTqHl TmA2+RYoeJhUKd5/36Jau/QFRtT+R/XJTKlQ2oWGud5EbjhHsL5pWRwQLY+3AR80TcTK 39+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=PLdDqTyv; 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 a6si6827630edu.356.2021.03.08.00.48.27; Mon, 08 Mar 2021 00:48:49 -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=PLdDqTyv; 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 S232315AbhCHImD (ORCPT + 99 others); Mon, 8 Mar 2021 03:42:03 -0500 Received: from mx2.suse.de ([195.135.220.15]:51258 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232274AbhCHIlm (ORCPT ); Mon, 8 Mar 2021 03:41:42 -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=1615192901; 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=IQsvUx1bc3HFAYXXFvyw7hGdS+2IRJnswNDb2Qjo34s=; b=PLdDqTyvNh44Ko31OLNkhQ4lo2iW9kZb39drwp7Ug4ZL5qvM0LFz9RcF6zAonW5aAxx5Ok iBhillVC6cvC7rgKI8x9y/+HV379hZA5TU7oXWi8SoPY4mPBzOECsszlW87YDvAkfhRAs8 h+Tnu48JBm7b+qsoVBrrvVXYgCNEENQ= Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 02E72AC0C; Mon, 8 Mar 2021 08:41:41 +0000 (UTC) Date: Mon, 8 Mar 2021 09:41:38 +0100 From: Michal Hocko To: Andrew Morton Cc: Zhou Guanghui , linux-kernel@vger.kernel.org, linux-mm@kvack.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> <20210305155840.4bb6dea4fb473d9ffbe49c99@linux-foundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210305155840.4bb6dea4fb473d9ffbe49c99@linux-foundation.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri 05-03-21 15:58:40, Andrew Morton wrote: > On Fri, 5 Mar 2021 12:52:52 +0100 Michal Hocko wrote: > > > 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. > > I added > > : Michel: > : > : There are at least two explicit users of __GFP_ACCOUNT with > : alloc_exact_pages added recently. See 7efe8ef274024 ("KVM: arm64: > : Allocate stage-2 pgd pages with GFP_KERNEL_ACCOUNT") and c419621873713 > : ("KVM: s390: Add memcg accounting to KVM allocations"), so this is not > : just a theoretical issue. > > And should we cc:stable on this one? Somebody more familiar with iommu dma allocation layer should have a look as well (__iommu_dma_alloc_pages) so that we know whether there are kernels outside of the above two ones mentioned above that need a fix. But in general this sounds like a good fit for the stable tree. -- Michal Hocko SUSE Labs