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.9 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, 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 94780C10DCE for ; Fri, 6 Mar 2020 17:24:16 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 4D9F820658 for ; Fri, 6 Mar 2020 17:24:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="g8MbbuGf" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4D9F820658 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id F41AD6B0006; Fri, 6 Mar 2020 12:24:15 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id EF2C66B000A; Fri, 6 Mar 2020 12:24:15 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E086A6B006E; Fri, 6 Mar 2020 12:24:15 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0139.hostedemail.com [216.40.44.139]) by kanga.kvack.org (Postfix) with ESMTP id CA5BE6B0006 for ; Fri, 6 Mar 2020 12:24:15 -0500 (EST) Received: from smtpin23.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 8304E5DD8 for ; Fri, 6 Mar 2020 17:24:15 +0000 (UTC) X-FDA: 76565610870.23.wax95_423a0b238ec33 X-HE-Tag: wax95_423a0b238ec33 X-Filterd-Recvd-Size: 7492 Received: from mail-ed1-f65.google.com (mail-ed1-f65.google.com [209.85.208.65]) by imf34.hostedemail.com (Postfix) with ESMTP for ; Fri, 6 Mar 2020 17:24:14 +0000 (UTC) Received: by mail-ed1-f65.google.com with SMTP id n18so3377559edw.9 for ; Fri, 06 Mar 2020 09:24:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=WZVF3WeW7a9wrdSl0zBcs9raA78Uf8UokFbAXMs0MtY=; b=g8MbbuGfSPFiXaKugqYxPbsI+w1HDaJneroTSsByaWf9QRcxgtnRqXWjdFLdwGQ+NG AMoljN6kLEhM9XqiFZViwOtz4THPxiF+zMkHIoxAKRJ70yI79J0zpc7iNgLOvZoOwLO3 h8+w9+UBXn5J/ytjOtHGJ8zaLSI38Mv+DEiQiHcWOx4Ew8XHC007awxBQzAEdrX3+kfb qH1oumcl+U4aldZHNfmEJHOoNA6KZhtjrJSuutd+9qjRlnNECX7wb0T0h/fnMnjmFEfB 6usF1E3yTLbc6+Sda0Cq//wYp/ZVg7jMqIWnaejkuO1tNLs5rRONZJ1c1PbpC2sVLA3h 7EDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=WZVF3WeW7a9wrdSl0zBcs9raA78Uf8UokFbAXMs0MtY=; b=kprBnMO5ALnHYX0p+7yZdUwoDym6y4PBQ6MzV/UdYyTEYSDCvl4zIjrKRMv0fHOlnw 7BhmZr2D5gzWqm15EJe4Ii6vF0ObJaAhfduoClOZvjdreHCZFyuOYOTiRO28aey2wWEQ D60XTUo0iSxxhUXkqDZVMO+3zPV0k+nieNC8/qWor7NH5piTp6JKi+jmJog1oZVb0Kue di6HviW5EpB4bq1Ybfl3/ETsYBLedxN8Cl8mdb9IbIV+5AGvunaG0rULufNLM7xWnArm rPGFFXV7nbnLSgrlmRR+hMSl4MipEek+ZCMaK92+CrSwcM0pp+fUaLeewIl3wvOVkLrF rgsA== X-Gm-Message-State: ANhLgQ0nM4HVsFleQwcdH04wFVz+QaG4G0QUI9bOH9ZicrXybFnga4Uj qN/fhVmAilP/K9niIZiSVfAMBuTmTjkdVvRPDbg= X-Google-Smtp-Source: ADFU+vuoGR+71ZPoCut+EzCCatlJeD6qgkXezcS9qWz5QI/UUTv/UpbGhdYIFjKJIRV7iaq6SK4g/NSoYScbpb9n7y0= X-Received: by 2002:a17:906:1cc2:: with SMTP id i2mr3962727ejh.283.1583515453642; Fri, 06 Mar 2020 09:24:13 -0800 (PST) MIME-Version: 1.0 References: <20200220131202.i77zt3zj53mimrnu@box> In-Reply-To: <20200220131202.i77zt3zj53mimrnu@box> From: Yang Shi Date: Fri, 6 Mar 2020 09:23:59 -0800 Message-ID: Subject: Re: [patch 1/2] mm, shmem: add thp fault alloc and fallback stats To: "Kirill A. Shutemov" Cc: David Rientjes , Andrew Morton , "Kirill A. Shutemov" , Mike Rapoport , Jeremy Cline , Linux Kernel Mailing List , Linux MM Content-Type: text/plain; charset="UTF-8" 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 Thu, Feb 20, 2020 at 5:11 AM Kirill A. Shutemov wrote: > > 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. I found another usecase for THP_FILE_FALLBACK. I wanted to measure file THP allocation success rate in our uecase. It looks nr_file_alloc / (nr_file_alloc + nr_file_fallback) is the most simple way. David, are you still working on this patch? > > -- > Kirill A. Shutemov