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=-12.9 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1, USER_IN_DEF_DKIM_WL autolearn=unavailable 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 EA8BDC3404D for ; Wed, 19 Feb 2020 03:44:14 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 9844424658 for ; Wed, 19 Feb 2020 03:44:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Q3IBW1bj" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9844424658 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 499E26B0003; Tue, 18 Feb 2020 22:44:14 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 449B96B0007; Tue, 18 Feb 2020 22:44:14 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 313F16B0008; Tue, 18 Feb 2020 22:44:14 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0249.hostedemail.com [216.40.44.249]) by kanga.kvack.org (Postfix) with ESMTP id 1718C6B0003 for ; Tue, 18 Feb 2020 22:44:14 -0500 (EST) Received: from smtpin23.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 83EBC2464 for ; Wed, 19 Feb 2020 03:44:13 +0000 (UTC) X-FDA: 76505483586.23.pig48_7c24d9c2ac22b X-HE-Tag: pig48_7c24d9c2ac22b X-Filterd-Recvd-Size: 6683 Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.175]) by imf44.hostedemail.com (Postfix) with ESMTP for ; Wed, 19 Feb 2020 03:44:12 +0000 (UTC) Received: by mail-pl1-f175.google.com with SMTP id d9so8965258plo.11 for ; Tue, 18 Feb 2020 19:44:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=8yMk1rmENYxZ4Ak7kdDvWY8wqNcb6ofqoMJvwOVdmAo=; b=Q3IBW1bjFwvi4HtS64zNZH7Vt2aIPBvcJXYNnGvmm62rWgxJ36Taj6dctGqf8Wz8h1 j3ze+JJsU6etxCHyjski5b/JNc0WfoWywTJ6m0s/zMV0MtUpw+DcBJDEA3gyxRe6kVCD PBu+DUcP9c3O2IFscEsVK3IOf+w1tk2/NTSEmaxAAia5hnZLoHOOuYivCQRX8uor5ej5 YylpAn59Mvv4AnHpurfuc5Io3tHVUf4Xl+NoEA4oBhhCV9gT0Our0OEEXvF05DvW79Bg 11AEsC04tkucDZ+2vHN4w1RlrvZW382oONkuLKTlt9C0fctyNvBq22NU8CUDZCG4k5nY b6wA== 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:in-reply-to:message-id :references:user-agent:mime-version; bh=8yMk1rmENYxZ4Ak7kdDvWY8wqNcb6ofqoMJvwOVdmAo=; b=oVSKlXSx5msp2n2iUWBOcTw2dfo6BbxXxdTzpDPyBgdA6VMElI99xd/SPhEa0/XXI+ xwYnAl/wCHbl8zmcPVe59xP8rDNRhS5DI13S0ieX2Pj4kQ5e8IQ8ffgWs5sWoqqI6tSA fgwy0iya53a6EVLrOn1Rz+LG5Fla4DBUu5LGa4sKQHSAL+S6Y7ignCENsrP+n/UY1XWp EKtvYypNxctzXpK7g7S382MeWiQMXiydrMVbG6nkIxcam895QAuNbQgncnkjAIQEjbQj OOIKYmCkUFgz0QYPGmrc9xOkadXMDMVvq1oHLohx6fxZ8Q3NLrSaUYNMtCEGZZRVX5WC hiIQ== X-Gm-Message-State: APjAAAWv0mNFL5OQ1cs2OAli8cehCie92DHcM9ecu/Z6gGfVjvenXSdd Jh5Ipb5AAbmELzpY0QF0rx88WQ== X-Google-Smtp-Source: APXvYqywKJqSY/QsUSapcxVOLx/1D3vm3NcKxSmir1lWiX699L2XwwlfE4rTvVAMfeqTPD0Mh3AgKw== X-Received: by 2002:a17:90a:8547:: with SMTP id a7mr7037628pjw.0.1582083851875; Tue, 18 Feb 2020 19:44:11 -0800 (PST) Received: from [2620:15c:17:3:3a5:23a7:5e32:4598] ([2620:15c:17:3:3a5:23a7:5e32:4598]) by smtp.gmail.com with ESMTPSA id g2sm414891pgn.59.2020.02.18.19.44.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Feb 2020 19:44:11 -0800 (PST) Date: Tue, 18 Feb 2020 19:44:10 -0800 (PST) From: David Rientjes X-X-Sender: rientjes@chino.kir.corp.google.com To: Yang Shi cc: 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 In-Reply-To: Message-ID: References: User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII 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 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. > > > > spin_lock_irq(&info->lock); > > info->alloced += compound_nr(page); > > >