From patchwork Fri Feb 23 03:03:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Christoph Lameter (Ampere)" X-Patchwork-Id: 10236855 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C6CBA602DC for ; Fri, 23 Feb 2018 03:04:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BA823287B1 for ; Fri, 23 Feb 2018 03:04:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AE89C28871; Fri, 23 Feb 2018 03:04:08 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 29E7D287B1 for ; Fri, 23 Feb 2018 03:04:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750776AbeBWDEH (ORCPT ); Thu, 22 Feb 2018 22:04:07 -0500 Received: from resqmta-ch2-08v.sys.comcast.net ([69.252.207.40]:56440 "EHLO resqmta-ch2-08v.sys.comcast.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750916AbeBWDEG (ORCPT ); Thu, 22 Feb 2018 22:04:06 -0500 Received: from resomta-ch2-01v.sys.comcast.net ([69.252.207.97]) by resqmta-ch2-08v.sys.comcast.net with ESMTP id p3eXed3tX0P0Wp3eXe1paT; Fri, 23 Feb 2018 03:04:05 +0000 Received: from gentwo.org ([98.222.162.64]) by resomta-ch2-01v.sys.comcast.net with SMTP id p3eVewEW02NaUp3eWeKfNC; Fri, 23 Feb 2018 03:04:05 +0000 Received: by gentwo.org (Postfix, from userid 1001) id 2B3011160847; Thu, 22 Feb 2018 21:03:57 -0600 (CST) Message-Id: <20180223030357.110597093@linux.com> User-Agent: quilt/0.63-1 Date: Thu, 22 Feb 2018 21:03:48 -0600 From: cl@linux.com From: Christoph Lameter To: Mel Gorman Cc: Matthew Wilcox Cc: linux-mm@kvack.org Cc: linux-rdma@vger.kernel.org CC: akpm@linux-foundation.org Cc: Thomas Schoebel-Theuer Cc: andi@firstfloor.org Cc: Rik van Riel Cc: Michal Hocko Cc: Guy Shattah Cc: Anshuman Khandual Cc: Michal Nazarewicz Cc: Vlastimil Babka Cc: David Nellans Cc: Laura Abbott Cc: Pavel Machek Cc: Dave Hansen Cc: Mike Kravetz Cc: Zi Yan Subject: [PATCH 2/2] Page order diagnostics References: <20180223030346.707128614@linux.com> MIME-Version: 1.0 Content-Disposition: inline; filename=order_stats X-CMAE-Envelope: MS4wfMCxAC5mlbp2sr8Fp/wmu/nb3NEzaZb/Cqb0SELK2awOnksSP7hkAjfj/0rN/Iecf0CAL9B5pxxJEH1WWghCn8XWzSCHnWZUJQW2Co4c+M3bM5cGUm6u eptAIaxTxuiJcgAp8MSjgV8LeuimN45sUaLosvL6Zo0neKnJ+I6/FsFnTTY+NOQPe96NQA02cBAUos7xwomKmi9Le81VrFokvIjq/KFSjOSuzkk3VSrb6ssQ Mjw1iwoGzRpzIwxpp/Xa80HqLJ9nzdL6cYFA/PULWAc68f5iRRUsW9juNxBSd+pQV3EOXHJhs4SlDiQ0mF3UAHIhBTe5KXMj1Xiy3l5wd6sHaphGpLah6OY3 jnxzTikZhofM4nzACqhL9dLjlEXNooIrAY/9D2beWl8/txxuDBCMfDEj7C/siuQx2HPjaHxlNkfPF9kxwkkXCg0SnbKlLVLhvCkcnRuyONUuWj5NtYEyyVJj bsy2/uzfTW6wWSV9VwWeHL2pSN4LBgGKxLzC9l8r41BeA/lCcZBuZvNlwSrccXYgUglyQH5hZx2Jx4dFnrK6Q0CpRPfgfYz9Q+TxWxD8hpApLb3SrPzKKcRG yYBT3d+aO3s26fjNwI2bjFd2cDDJV1ipYF0Cy0buiHLPPTl1uWyR8cK/1cSSgUZt4GzcDz0D1j5Jv6sE5S4D8A58D4sBWOH9/HpAoz7m3wgeCrDTIZGEfuUv dmzd3AWtjDY= Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP rfc->v1 - Fix missing , in the #ifdef section It is beneficial to know about the contiguous memory segments available on a system and the number of allocations failing for each page order. This patch adds details per order statistics to /proc/meminfo so the current memory use can be determined. Also adds counters to /proc/vmstat to show allocation failures for each page order. Signed-off-by: Christoph Laeter --- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Index: linux/include/linux/mmzone.h =================================================================== --- linux.orig/include/linux/mmzone.h +++ linux/include/linux/mmzone.h @@ -185,6 +185,10 @@ enum node_stat_item { NR_VMSCAN_IMMEDIATE, /* Prioritise for reclaim when writeback ends */ NR_DIRTIED, /* page dirtyings since bootup */ NR_WRITTEN, /* page writings since bootup */ +#ifdef CONFIG_ORDER_STATS + NR_ORDER, + NR_ORDER_MAX = NR_ORDER + MAX_ORDER - 1, +#endif NR_VM_NODE_STAT_ITEMS }; Index: linux/mm/page_alloc.c =================================================================== --- linux.orig/mm/page_alloc.c +++ linux/mm/page_alloc.c @@ -832,6 +832,10 @@ static inline void __free_one_page(struc VM_BUG_ON_PAGE(pfn & ((1 << order) - 1), page); VM_BUG_ON_PAGE(bad_range(zone, page), page); +#ifdef CONFIG_ORDER_STATS + dec_node_page_state(page, NR_ORDER + order); +#endif + continue_merging: while (order < max_order - 1) { buddy_pfn = __find_buddy_pfn(pfn, order); @@ -1289,6 +1293,9 @@ static void __init __free_pages_boot_cor page_zone(page)->managed_pages += nr_pages; set_page_refcounted(page); __free_pages(page, order); +#ifdef CONFIG_ORDER_STATS + inc_node_page_state(page, NR_ORDER + order); +#endif } #if defined(CONFIG_HAVE_ARCH_EARLY_PFN_TO_NID) || \ @@ -1861,6 +1868,9 @@ struct page *__rmqueue_smallest(struct z rmv_page_order(page); area->nr_free--; expand(zone, page, order, current_order, area, migratetype); +#ifdef CONFIG_ORDER_STATS + inc_node_page_state(page, NR_ORDER + order); +#endif set_pcppage_migratetype(page, migratetype); return page; } @@ -4175,6 +4185,11 @@ nopage: fail: warn_alloc(gfp_mask, ac->nodemask, "page allocation failure: order:%u", order); + +#ifdef CONFIG_ORDER_STATS + count_vm_event(ORDER0_ALLOC_FAIL + order); +#endif + got_pg: return page; } Index: linux/fs/proc/meminfo.c =================================================================== --- linux.orig/fs/proc/meminfo.c +++ linux/fs/proc/meminfo.c @@ -51,6 +51,7 @@ static int meminfo_proc_show(struct seq_ long available; unsigned long pages[NR_LRU_LISTS]; int lru; + int order; si_meminfo(&i); si_swapinfo(&i); @@ -155,6 +156,11 @@ static int meminfo_proc_show(struct seq_ global_zone_page_state(NR_FREE_CMA_PAGES)); #endif +#ifdef CONFIG_ORDER_STATS + for (order= 0; order < MAX_ORDER; order++) + seq_printf(m, "Order%2d Pages: %5lu\n", + order, global_node_page_state(NR_ORDER + order)); +#endif hugetlb_report_meminfo(m); arch_report_meminfo(m); Index: linux/mm/Kconfig =================================================================== --- linux.orig/mm/Kconfig +++ linux/mm/Kconfig @@ -752,6 +752,15 @@ config PERCPU_STATS information includes global and per chunk statistics, which can be used to help understand percpu memory usage. +config ORDER_STATS + bool "Statistics for different sized allocations" + default n + help + Create statistics about the contiguous memory segments allocated + through the page allocator. This creates statistics about the + memory segments in use in /proc/meminfo and the node meminfo files + as well as allocation failure statistics in /proc/vmstat. + config GUP_BENCHMARK bool "Enable infrastructure for get_user_pages_fast() benchmarking" default n Index: linux/include/linux/vm_event_item.h =================================================================== --- linux.orig/include/linux/vm_event_item.h +++ linux/include/linux/vm_event_item.h @@ -111,6 +111,10 @@ enum vm_event_item { PGPGIN, PGPGOUT, PS SWAP_RA, SWAP_RA_HIT, #endif +#ifdef CONFIG_ORDER_STATS + ORDER0_ALLOC_FAIL, + ORDER_MAX_FAIL = ORDER0_ALLOC_FAIL + MAX_ORDER -1, +#endif NR_VM_EVENT_ITEMS }; Index: linux/mm/vmstat.c =================================================================== --- linux.orig/mm/vmstat.c +++ linux/mm/vmstat.c @@ -1289,6 +1289,52 @@ const char * const vmstat_text[] = { "swap_ra", "swap_ra_hit", #endif +#ifdef CONFIG_ORDER_STATS + "order0_failure", + "order1_failure", + "order2_failure", + "order3_failure", + "order4_failure", + "order5_failure", + "order6_failure", + "order7_failure", + "order8_failure", + "order9_failure", + "order10_failure", +#ifdef CONFIG_FORCE_MAX_ZONEORDER +#if MAX_ORDER > 11 + "order11_failure", +#endif +#if MAX_ORDER > 12 + "order12_failure", +#endif +#if MAX_ORDER > 13 + "order13_failure", +#endif +#if MAX_ORDER > 14 + "order14_failure", +#endif +#if MAX_ORDER > 15 + "order15_failure", +#endif +#if MAX_ORDER > 16 + "order16_failure", +#endif +#if MAX_ORDER > 17 + "order17_failure", +#endif +#if MAX_ORDER > 18 + "order18_failure", +#endif +#if MAX_ORDER > 19 + "order19_failure", +#endif +#if MAX_ORDER > 20 +#error Please add more lines... +#endif + +#endif /* CONFIG_FORCE_MAX_ZONEORDER */ +#endif /* CONFIG_ORDER_STATS */ #endif /* CONFIG_VM_EVENTS_COUNTERS */ }; #endif /* CONFIG_PROC_FS || CONFIG_SYSFS || CONFIG_NUMA */