Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752780AbbKYO66 (ORCPT ); Wed, 25 Nov 2015 09:58:58 -0500 Received: from mail-wm0-f43.google.com ([74.125.82.43]:33583 "EHLO mail-wm0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751689AbbKYO64 (ORCPT ); Wed, 25 Nov 2015 09:58:56 -0500 Date: Wed, 25 Nov 2015 15:58:54 +0100 From: Michal Hocko To: Vlastimil Babka Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrew Morton , Joonsoo Kim , Minchan Kim , Sasha Levin , "Kirill A. Shutemov" , Mel Gorman Subject: Re: [PATCH v2 7/9] mm, page_owner: dump page owner info from dump_page() Message-ID: <20151125145853.GM27283@dhcp22.suse.cz> References: <1448368581-6923-1-git-send-email-vbabka@suse.cz> <1448368581-6923-8-git-send-email-vbabka@suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1448368581-6923-8-git-send-email-vbabka@suse.cz> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2762 Lines: 77 On Tue 24-11-15 13:36:19, Vlastimil Babka wrote: > The page_owner mechanism is useful for dealing with memory leaks. By reading > /sys/kernel/debug/page_owner one can determine the stack traces leading to > allocations of all pages, and find e.g. a buggy driver. > > This information might be also potentially useful for debugging, such as the > VM_BUG_ON_PAGE() calls to dump_page(). So let's print the stored info from > dump_page(). > > Example output: > > page:ffffea0002868a00 count:1 mapcount:0 mapping:ffff8800bba8e958 index:0x63a22c > flags: 0x1fffff80000060(lru|active) > page dumped because: VM_BUG_ON_PAGE(1) > page->mem_cgroup:ffff880138efdc00 > page allocated via order 0, migratetype Movable, gfp_mask 0x2420848(GFP_NOFS|GFP_NOFAIL|GFP_HARDWALL|GFP_MOVABLE) > [] __alloc_pages_nodemask+0x15a/0xa30 > [] alloc_pages_current+0x88/0x120 > [] __page_cache_alloc+0xe6/0x120 > [] pagecache_get_page+0x56/0x200 > [] __getblk_slow+0xd2/0x2b0 > [] __getblk_gfp+0x40/0x50 > [] jbd2_journal_get_descriptor_buffer+0x3e/0x90 [jbd2] > [] jbd2_journal_commit_transaction+0x8e3/0x1870 [jbd2] > page has been migrated, last migrate reason: compaction Nice! This can be really helpful. > Signed-off-by: Vlastimil Babka Appart from a typo below, looks good to me Acked-by: Michal Hocko [...] > +void __dump_page_owner(struct page *page) > +{ > + struct page_ext *page_ext = lookup_page_ext(page); > + struct stack_trace trace = { > + .nr_entries = page_ext->nr_entries, > + .entries = &page_ext->trace_entries[0], > + }; > + gfp_t gfp_mask = page_ext->gfp_mask; > + int mt = gfpflags_to_migratetype(gfp_mask); > + > + if (!test_bit(PAGE_EXT_OWNER, &page_ext->flags)) { > + pr_alert("page_owner info is not active (free page?)\n"); > + return; > + } > + ; Typo? > + pr_alert("page allocated via order %u, migratetype %s, gfp_mask 0x%x", > + page_ext->order, migratetype_names[mt], gfp_mask); > + dump_gfpflag_names(gfp_mask); > + print_stack_trace(&trace, 0); > + > + if (page_ext->last_migrate_reason != -1) > + pr_alert("page has been migrated, last migrate reason: %s\n", > + migrate_reason_names[page_ext->last_migrate_reason]); > +} > + > static ssize_t > read_page_owner(struct file *file, char __user *buf, size_t count, loff_t *ppos) > { > -- > 2.6.3 -- Michal Hocko SUSE Labs -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/