Received: by 10.223.185.116 with SMTP id b49csp5054933wrg; Wed, 7 Mar 2018 05:46:44 -0800 (PST) X-Google-Smtp-Source: AG47ELvgcqRn1Ou8tZrYWRTMqQNkQCTSX2N7kFXnPy0Jh5YPpTASa6chpObsqkd3j/kX6Kfzd+ap X-Received: by 2002:a17:902:47aa:: with SMTP id r39-v6mr20083173pld.72.1520430404376; Wed, 07 Mar 2018 05:46:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520430404; cv=none; d=google.com; s=arc-20160816; b=HWRc5zLuueaUl/NEJFEOlJr+KzjYJY4Uv/O5nNFlJjPCmQF4b0AnrkVcQXADzeIRUe jr4VGdVluUBuWBp2b0ZC9Dv2uz/2spPvHIb1vzIHST6yD18o511JqoHdK6IWtnEvvcSX bi+jJYITVnFcRNLSAvmWNiClhCQXWO5TERkOkRMWRynbbIg2aUzy5AkMSxvMvtvHexOZ YR5b5YsnGi0GGPWAUWvVUl4ANQEBvv59sG/TrJ/oXelsTwEnsfuAW3UMy7sOOtcCtAJq G8zo+1cVjYXirEhm13clIngceDooAqyqlU1q8AGgjy6XtNiMXYDRtCQW9S/rcSZAVqGd fywg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=Wj/qYORJvEFQ19/NMSeFxX/rAbvAeaD1vFzKcbrWzes=; b=qhbJMw6comrh3bKj14+cxxHgSxOpHEqCOnbiK8I1RLGs076RylDzZViA1KTd95lkhH yoXeUJgliWDtQqLyFRxzMyNGx4btMAyI+K3ENftOyOQwNaQVJh6wVOeNaP1v2V/uJaD+ GxyYB3OyN1z1YHVGjHnBB1swb8r583CTUn40SJ2kKv8wyYk272cgviserzSkPalG+SRE jRSscREfTraXiLDsqEHtiMJM9IKKFlaRB3digNLNjeytYPBKtxV+iZcZe1Uq/s0bZrwd NN8V+wDJLR1uMkSJ7ilM6Lra3osgmdgTf37NUbAoHCXzvP+fjxU3CNxMciwfHw3WR75K IfKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=EgoglP4h; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k24si13943033pfh.151.2018.03.07.05.46.30; Wed, 07 Mar 2018 05:46:44 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=EgoglP4h; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754456AbeCGNoy (ORCPT + 99 others); Wed, 7 Mar 2018 08:44:54 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:59060 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754416AbeCGNos (ORCPT ); Wed, 7 Mar 2018 08:44:48 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=References:In-Reply-To:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=Wj/qYORJvEFQ19/NMSeFxX/rAbvAeaD1vFzKcbrWzes=; b=EgoglP4hzAA9adu+4G5IuO7V5 +/bG37Xk1IZEc/5ziexyz5XD3myN7sUnuhAAKXnu9OXJZePa/0t/wM0m0XoU9s7Pi+9v7sWgARWab shfnL+fgXH6kz/8oahRwBcTzYFyVpDULVVLk6+zinPLnk1XGBBG4z+DFoJAjpLB6+8NW6ITpyJGSt IbKlIvJOiiXoODu0R1o7ZhrCpY3Jv26juFtRzSQUeOk4Pzb+DFo+QkT4Acycj5gaMqiDFoyQKbDyX 6BahVBr6cr0IgoNGf/oYsvZDVYhBeFx00T4CKR2ZN4x1SU1WufQSQxbVYcBb0SGg+Fx3tdADf/Z8t Dfrc+Vxxg==; Received: from willy by bombadil.infradead.org with local (Exim 4.89 #1 (Red Hat Linux)) id 1etZN9-00005H-NL; Wed, 07 Mar 2018 13:44:47 +0000 From: Matthew Wilcox To: linux-mm@kvack.org Cc: Matthew Wilcox , linux-kernel@vger.kernel.org Subject: [PATCH v5 3/4] mm: Mark pages allocated through vmalloc Date: Wed, 7 Mar 2018 05:44:42 -0800 Message-Id: <20180307134443.32646-4-willy@infradead.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180307134443.32646-1-willy@infradead.org> References: <20180307134443.32646-1-willy@infradead.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Matthew Wilcox Use a bit in page_type to mark pages which have been allocated through vmalloc. This can be helpful when debugging crashdumps or analysing memory fragmentation. Add a KPF flag to report these pages to userspace and update page-types.c to interpret that flag. Signed-off-by: Matthew Wilcox Acked-by: Kirill A. Shutemov --- fs/proc/page.c | 2 ++ include/linux/page-flags.h | 6 ++++++ include/uapi/linux/kernel-page-flags.h | 2 +- mm/vmalloc.c | 2 ++ tools/vm/page-types.c | 1 + 5 files changed, 12 insertions(+), 1 deletion(-) diff --git a/fs/proc/page.c b/fs/proc/page.c index 1491918a33c3..c9757af919a3 100644 --- a/fs/proc/page.c +++ b/fs/proc/page.c @@ -154,6 +154,8 @@ u64 stable_page_flags(struct page *page) if (PageBalloon(page)) u |= 1 << KPF_BALLOON; + if (PageVmalloc(page)) + u |= 1 << KPF_VMALLOC; if (page_is_idle(page)) u |= 1 << KPF_IDLE; diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h index be3cd45efeb6..1503d314bb3d 100644 --- a/include/linux/page-flags.h +++ b/include/linux/page-flags.h @@ -643,6 +643,7 @@ PAGEFLAG_FALSE(DoubleMap) #define PG_buddy 0x00000080 #define PG_balloon 0x00000100 #define PG_kmemcg 0x00000200 +#define PG_vmalloc 0x00000400 #define PageType(page, flag) \ ((page->page_type & (PAGE_TYPE_BASE | flag)) == PAGE_TYPE_BASE) @@ -681,6 +682,11 @@ PAGE_TYPE_OPS(Balloon, balloon) */ PAGE_TYPE_OPS(Kmemcg, kmemcg) +/* + * Pages allocated through vmalloc are tagged with this bit. + */ +PAGE_TYPE_OPS(Vmalloc, vmalloc) + extern bool is_free_buddy_page(struct page *page); __PAGEFLAG(Isolated, isolated, PF_ANY); diff --git a/include/uapi/linux/kernel-page-flags.h b/include/uapi/linux/kernel-page-flags.h index fa139841ec18..5f1735ff05b3 100644 --- a/include/uapi/linux/kernel-page-flags.h +++ b/include/uapi/linux/kernel-page-flags.h @@ -35,6 +35,6 @@ #define KPF_BALLOON 23 #define KPF_ZERO_PAGE 24 #define KPF_IDLE 25 - +#define KPF_VMALLOC 26 #endif /* _UAPILINUX_KERNEL_PAGE_FLAGS_H */ diff --git a/mm/vmalloc.c b/mm/vmalloc.c index ebff729cc956..3bc0538fc21b 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -1536,6 +1536,7 @@ static void __vunmap(const void *addr, int deallocate_pages) struct page *page = area->pages[i]; BUG_ON(!page); + __ClearPageVmalloc(page); __free_pages(page, 0); } @@ -1705,6 +1706,7 @@ static void *__vmalloc_area_node(struct vm_struct *area, gfp_t gfp_mask, area->nr_pages = i; goto fail; } + __SetPageVmalloc(page); area->pages[i] = page; if (gfpflags_allow_blocking(gfp_mask|highmem_mask)) cond_resched(); diff --git a/tools/vm/page-types.c b/tools/vm/page-types.c index a8783f48f77f..116f59eff5e2 100644 --- a/tools/vm/page-types.c +++ b/tools/vm/page-types.c @@ -131,6 +131,7 @@ static const char * const page_flag_names[] = { [KPF_KSM] = "x:ksm", [KPF_THP] = "t:thp", [KPF_BALLOON] = "o:balloon", + [KPF_VMALLOC] = "V:vmalloc", [KPF_ZERO_PAGE] = "z:zero_page", [KPF_IDLE] = "i:idle_page", -- 2.16.1