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=-3.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,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 32ECCC11D04 for ; Thu, 20 Feb 2020 13:11:37 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id C6D40206ED for ; Thu, 20 Feb 2020 13:11:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=shutemov-name.20150623.gappssmtp.com header.i=@shutemov-name.20150623.gappssmtp.com header.b="crFreDBE" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C6D40206ED Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=shutemov.name Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 289536B0005; Thu, 20 Feb 2020 08:11:36 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 238A66B0006; Thu, 20 Feb 2020 08:11:36 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 128C66B0007; Thu, 20 Feb 2020 08:11:36 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0237.hostedemail.com [216.40.44.237]) by kanga.kvack.org (Postfix) with ESMTP id E92C86B0005 for ; Thu, 20 Feb 2020 08:11:35 -0500 (EST) Received: from smtpin16.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 8258D181AEF1E for ; Thu, 20 Feb 2020 13:11:35 +0000 (UTC) X-FDA: 76510542150.16.uncle62_2aeaa5b845613 X-HE-Tag: uncle62_2aeaa5b845613 X-Filterd-Recvd-Size: 7435 Received: from mail-lj1-f195.google.com (mail-lj1-f195.google.com [209.85.208.195]) by imf25.hostedemail.com (Postfix) with ESMTP for ; Thu, 20 Feb 2020 13:11:34 +0000 (UTC) Received: by mail-lj1-f195.google.com with SMTP id a13so4132128ljm.10 for ; Thu, 20 Feb 2020 05:11:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shutemov-name.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=95x/svoIHvKtwThYjiFAhoANuT+9jaK/n8hE5y8HQuM=; b=crFreDBEqFDDkMhb8t3wiTSXcSXwcMBXrtLRBgy/EB6JgvFI6XWm7x1/wOie4gsbXL QQ3QUTJ54ZQaY7DLyG0eMDhKW78NMtF0EpKV24KUqJAkpHjg8Unrzjo+h6ky+AFW6w2A 2cswn+BY3t7POXQu0hky4IgR2elmaN4migYzFs2WLjXV9imgcdbO5zf+rJEPXHq/b80S DxB/WY+cbZK3AP5wy95Bxtl1lU+u53iV1tcCYhIPUmcdswhSOkvoqCu1k+2OFctN8IlA oEYCzCmBsQCOym4VAMEm/FRo6zwAdtAGRmD61x+6BtVfCPZSk0yBaTr+Ih8D5DGdQUfE u75A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=95x/svoIHvKtwThYjiFAhoANuT+9jaK/n8hE5y8HQuM=; b=jTjcG4A5fiqNn5cz+N6ssenUDHngX5F/+K/5xzVJThJ1VEqf7yg0v5qY2DdW1620ss 0ce8RMhIXg5oy1wGOD6ybDsgSHcDk0yvT89Ev+HvWGgkIB3QwmYXgQkbcQA6ahCggp9w UleRC915WUlGpKeeDLX8W/oIHmP6pED1zkLNWAp42JOKb1afqkfajpzFkGdZlseRwnWS A7hTcmh/m0ZJwuADVJKKcQGYjd3EPjK8nBXkyOVGYL5psdcvJbqR33dGs9sj/9hP70/O I7g/oHozKPOk6ejhC7OL940QPCrGd25Em3aXxrZ7+etKKSsqdK35ogR2hP7bFBT56bSL n9fw== X-Gm-Message-State: APjAAAXXCeBu+BFQQ0ZUUcaxjnXP7LroAnQ7WpR6w3YPx54z7a86vYKW w03JKLAO3kMJ0xwhjVHuEPv1PQ== X-Google-Smtp-Source: APXvYqwHcoB79WTtbZlwQ7P2hFgI1BkSfCjBHhn1dayq2xGKeB0Z18obfHCYvUiqt8PFH2LvliAXjw== X-Received: by 2002:a2e:8e84:: with SMTP id z4mr18170854ljk.207.1582204293381; Thu, 20 Feb 2020 05:11:33 -0800 (PST) Received: from box.localdomain ([86.57.175.117]) by smtp.gmail.com with ESMTPSA id n13sm1784076lji.91.2020.02.20.05.11.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Feb 2020 05:11:32 -0800 (PST) Received: by box.localdomain (Postfix, from userid 1000) id 0B508100FBB; Thu, 20 Feb 2020 16:12:02 +0300 (+03) Date: Thu, 20 Feb 2020 16:12:02 +0300 From: "Kirill A. Shutemov" To: Yang Shi Cc: David Rientjes , Andrew Morton , "Kirill A. Shutemov" , Mike Rapoport , Jeremy Cline , Linux Kernel Mailing List , Linux MM Subject: Re: [patch 1/2] mm, shmem: add thp fault alloc and fallback stats Message-ID: <20200220131202.i77zt3zj53mimrnu@box> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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: On Wed, Feb 19, 2020 at 09:01:23AM -0800, Yang Shi wrote: > On Tue, Feb 18, 2020 at 7:44 PM David Rientjes wrote: > > > > On Tue, 18 Feb 2020, Yang Shi wrote: > > > > > > diff --git a/mm/shmem.c b/mm/shmem.c > > > > --- a/mm/shmem.c > > > > +++ b/mm/shmem.c > > > > @@ -1502,9 +1502,8 @@ static struct page *shmem_alloc_page(gfp_t gfp, > > > > return page; > > > > } > > > > > > > > -static struct page *shmem_alloc_and_acct_page(gfp_t gfp, > > > > - struct inode *inode, > > > > - pgoff_t index, bool huge) > > > > +static struct page *shmem_alloc_and_acct_page(gfp_t gfp, struct inode *inode, > > > > + pgoff_t index, bool fault, bool huge) > > > > { > > > > struct shmem_inode_info *info = SHMEM_I(inode); > > > > struct page *page; > > > > @@ -1518,9 +1517,11 @@ static struct page *shmem_alloc_and_acct_page(gfp_t gfp, > > > > if (!shmem_inode_acct_block(inode, nr)) > > > > goto failed; > > > > > > > > - if (huge) > > > > + if (huge) { > > > > page = shmem_alloc_hugepage(gfp, info, index); > > > > - else > > > > + if (!page && fault) > > > > + count_vm_event(THP_FAULT_FALLBACK); > > > > + } else > > > > page = shmem_alloc_page(gfp, info, index); > > > > if (page) { > > > > __SetPageLocked(page); > > > > @@ -1832,11 +1833,10 @@ static int shmem_getpage_gfp(struct inode *inode, pgoff_t index, > > > > } > > > > > > > > alloc_huge: > > > > - page = shmem_alloc_and_acct_page(gfp, inode, index, true); > > > > + page = shmem_alloc_and_acct_page(gfp, inode, index, vmf, true); > > > > if (IS_ERR(page)) { > > > > alloc_nohuge: > > > > - page = shmem_alloc_and_acct_page(gfp, inode, > > > > - index, false); > > > > + page = shmem_alloc_and_acct_page(gfp, inode, index, vmf, false); > > > > } > > > > if (IS_ERR(page)) { > > > > int retry = 5; > > > > @@ -1871,8 +1871,11 @@ static int shmem_getpage_gfp(struct inode *inode, pgoff_t index, > > > > > > > > error = mem_cgroup_try_charge_delay(page, charge_mm, gfp, &memcg, > > > > PageTransHuge(page)); > > > > - if (error) > > > > + if (error) { > > > > + if (vmf && PageTransHuge(page)) > > > > + count_vm_event(THP_FAULT_FALLBACK); > > > > goto unacct; > > > > + } > > > > error = shmem_add_to_page_cache(page, mapping, hindex, > > > > NULL, gfp & GFP_RECLAIM_MASK); > > > > if (error) { > > > > @@ -1883,6 +1886,8 @@ static int shmem_getpage_gfp(struct inode *inode, pgoff_t index, > > > > mem_cgroup_commit_charge(page, memcg, false, > > > > PageTransHuge(page)); > > > > lru_cache_add_anon(page); > > > > + if (vmf && PageTransHuge(page)) > > > > + count_vm_event(THP_FAULT_ALLOC); > > > > > > I think shmem THP alloc is accounted to THP_FILE_ALLOC. And it has > > > been accounted by shmem_add_to_page_cache(). So, it sounds like a > > > double count. > > > > > > > I think we can choose to either include file allocations into both > > thp_fault_alloc and thp_fault_fallback or we can exclude them from both of > > them. I don't think we can account for only one of them. > > How's about the 3rd option, adding THP_FILE_FALLBACK. I like this option. Problem with THP_FAULT_* is that shmem_getpage_gfp() is called not only from fault path, but also from syscalls. -- Kirill A. Shutemov