From patchwork Fri Mar 6 22:22:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Rientjes X-Patchwork-Id: 11424723 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4BE07138D for ; Fri, 6 Mar 2020 22:22:37 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 0BD8C20714 for ; Fri, 6 Mar 2020 22:22:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="euevNUnR" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0BD8C20714 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 2A35B6B0006; Fri, 6 Mar 2020 17:22:36 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 254196B0007; Fri, 6 Mar 2020 17:22:36 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 16A8A6B0008; Fri, 6 Mar 2020 17:22:36 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0078.hostedemail.com [216.40.44.78]) by kanga.kvack.org (Postfix) with ESMTP id 003A76B0006 for ; Fri, 6 Mar 2020 17:22:35 -0500 (EST) Received: from smtpin12.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id B4F1A180AD804 for ; Fri, 6 Mar 2020 22:22:35 +0000 (UTC) X-FDA: 76566362670.12.field62_33bbe3cfa2440 X-Spam-Summary: 2,0,0,5228320fed7de65e,d41d8cd98f00b204,rientjes@google.com,,RULES_HIT:41:355:379:800:960:968:973:988:989:1260:1277:1313:1314:1345:1437:1516:1518:1535:1543:1593:1594:1711:1730:1747:1777:1792:1801:2393:2559:2562:3138:3139:3140:3141:3142:3152:3354:3865:3867:3868:3871:3872:3874:4117:4605:5007:6119:6261:6653:7903:8957:9592:10004:10400:10450:10455:11026:11232:11473:11657:11658:11914:12043:12297:12438:12517:12519:13161:13229:13439:14181:14659:14721:19904:19999:21080:21433:21444:21451:21627:21795:21990:30003:30051:30054:30060:30070,0,RBL:209.85.214.196:@google.com:.lbl8.mailshell.net-66.100.201.100 62.18.0.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:24,LUA_SUMMARY:none X-HE-Tag: field62_33bbe3cfa2440 X-Filterd-Recvd-Size: 6557 Received: from mail-pl1-f196.google.com (mail-pl1-f196.google.com [209.85.214.196]) by imf44.hostedemail.com (Postfix) with ESMTP for ; Fri, 6 Mar 2020 22:22:35 +0000 (UTC) Received: by mail-pl1-f196.google.com with SMTP id b22so1422439pls.12 for ; Fri, 06 Mar 2020 14:22:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:user-agent:mime-version; bh=yq1LlWXfgFVbN1dN7FhDu/ZG8whSBUXn1voZBs312pU=; b=euevNUnR9uilPzjMJkibgbzoltDVJCpY61LgqxaYH6BTonL0HIkck4scTwN9KrPHwB U1fQ05HIElb2V/zA8kMiDvQo9vfmGmwUjAJg0zEZKmZy0UyVoWup97a6IzDwSEkYgGVY wyJ9dvecckunSCuDgCsXT9izi2FD2kBu0Jhi23Ah+HiO89MCharnA0agkzXJjdAFq+UL HkFXFOGz1DciQIlyPlJ7vIumhmq+WHOXi503VG/Os7UB5KQiQJOZrq0MxB/Ca7Q3/X2H 260nirY0ZACoQhYlL1YEdRT2GWaJTX8yIHCBiVKcTt7Zoe/0JKrrpH2R2c+kPYBzoM0F UC6A== 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:user-agent :mime-version; bh=yq1LlWXfgFVbN1dN7FhDu/ZG8whSBUXn1voZBs312pU=; b=b4aqnf2KVT4hGUAWx92Fcymhcha4H5YNnZ+GJZiF1kNhQ38mf8ROFcsI2lkf6qFCWJ VzwzPno4Z+GlhKn7SIGJt+hho+mo4m+3Fjp6fZ0NyfqngOQrfw6M4r4Q7Q7Ba+WkioJJ eOoqihucQ4Zn3dRvDJhkszirBj+bXhWH8aer7kiugqVFdfHAgAVxboOAJBDxHHv2YQlE pkLP7iW95yIYAczS8/LEujrGljZnMPER000jfvbYtSKVCIlhloDOeOWarHghwshHRR6G 0CzqicvxGdiQHQQuMMdON0Mgf9svffH/altVALq9KrEGbOYXArIy7KWP62D5jFIbN497 a2Bw== X-Gm-Message-State: ANhLgQ381X2jXP7+/6EGNXakNJ5SUvPD0cj+B2H2VtAC4J+M16BICYI1 Pzo/cOsVjiSIXXdPgeqxB4oqYw== X-Google-Smtp-Source: ADFU+vtl+VdsMHnoS3xzYLEpNEMejM0HbgJXg8kWeEc+p/hRmDM5OVJrSvhDxDtqhAwTsC3mpZscEw== X-Received: by 2002:a17:902:8f8a:: with SMTP id z10mr5213289plo.169.1583533354024; Fri, 06 Mar 2020 14:22:34 -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 m70sm10598029pje.45.2020.03.06.14.22.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Mar 2020 14:22:33 -0800 (PST) Date: Fri, 6 Mar 2020 14:22:32 -0800 (PST) From: David Rientjes X-X-Sender: rientjes@chino.kir.corp.google.com To: Andrew Morton cc: Yang Shi , "Kirill A. Shutemov" , "Kirill A. Shutemov" , Mike Rapoport , Jeremy Cline , Linux Kernel Mailing List , Linux MM Subject: [patch 1/2] mm, shmem: add vmstat for hugepage fallback Message-ID: User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 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: The existing thp_fault_fallback indicates when thp attempts to allocate a hugepage but fails, or if the hugepage cannot be charged to the mem cgroup hierarchy. Extend this to shmem as well. Adds a new thp_file_fallback to complement thp_file_alloc that gets incremented when a hugepage is attempted to be allocated but fails, or if it cannot be charged to the mem cgroup hierarchy. Additionally, remove the check for CONFIG_TRANSPARENT_HUGE_PAGECACHE from shmem_alloc_hugepage() since it is only called with this configuration option. Signed-off-by: David Rientjes Acked-by: Kirill A. Shutemov --- Documentation/admin-guide/mm/transhuge.rst | 4 ++++ include/linux/vm_event_item.h | 2 ++ mm/shmem.c | 10 ++++++---- mm/vmstat.c | 1 + 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/Documentation/admin-guide/mm/transhuge.rst b/Documentation/admin-guide/mm/transhuge.rst --- a/Documentation/admin-guide/mm/transhuge.rst +++ b/Documentation/admin-guide/mm/transhuge.rst @@ -319,6 +319,10 @@ thp_file_alloc is incremented every time a file huge page is successfully allocated. +thp_file_fallback + is incremented if a file huge page is attempted to be allocated + but fails and instead falls back to using small pages. + thp_file_mapped is incremented every time a file huge page is mapped into user address space. diff --git a/include/linux/vm_event_item.h b/include/linux/vm_event_item.h --- a/include/linux/vm_event_item.h +++ b/include/linux/vm_event_item.h @@ -76,6 +76,7 @@ enum vm_event_item { PGPGIN, PGPGOUT, PSWPIN, PSWPOUT, THP_COLLAPSE_ALLOC, THP_COLLAPSE_ALLOC_FAILED, THP_FILE_ALLOC, + THP_FILE_FALLBACK, THP_FILE_MAPPED, THP_SPLIT_PAGE, THP_SPLIT_PAGE_FAILED, @@ -115,6 +116,7 @@ enum vm_event_item { PGPGIN, PGPGOUT, PSWPIN, PSWPOUT, #ifndef CONFIG_TRANSPARENT_HUGEPAGE #define THP_FILE_ALLOC ({ BUILD_BUG(); 0; }) +#define THP_FILE_FALLBACK ({ BUILD_BUG(); 0; }) #define THP_FILE_MAPPED ({ BUILD_BUG(); 0; }) #endif diff --git a/mm/shmem.c b/mm/shmem.c --- a/mm/shmem.c +++ b/mm/shmem.c @@ -1472,9 +1472,6 @@ static struct page *shmem_alloc_hugepage(gfp_t gfp, pgoff_t hindex; struct page *page; - if (!IS_ENABLED(CONFIG_TRANSPARENT_HUGE_PAGECACHE)) - return NULL; - hindex = round_down(index, HPAGE_PMD_NR); if (xa_find(&mapping->i_pages, &hindex, hindex + HPAGE_PMD_NR - 1, XA_PRESENT)) @@ -1486,6 +1483,8 @@ static struct page *shmem_alloc_hugepage(gfp_t gfp, shmem_pseudo_vma_destroy(&pvma); if (page) prep_transhuge_page(page); + else + count_vm_event(THP_FILE_FALLBACK); return page; } @@ -1871,8 +1870,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 (PageTransHuge(page)) + count_vm_event(THP_FILE_FALLBACK); goto unacct; + } error = shmem_add_to_page_cache(page, mapping, hindex, NULL, gfp & GFP_RECLAIM_MASK); if (error) { diff --git a/mm/vmstat.c b/mm/vmstat.c --- a/mm/vmstat.c +++ b/mm/vmstat.c @@ -1257,6 +1257,7 @@ const char * const vmstat_text[] = { "thp_collapse_alloc", "thp_collapse_alloc_failed", "thp_file_alloc", + "thp_file_fallback", "thp_file_mapped", "thp_split_page", "thp_split_page_failed",