From: David Hildenbrand <david@redhat.com> To: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, devel@linuxdriverproject.org, linux-fsdevel@vger.kernel.org, linux-pm@vger.kernel.org, xen-devel@lists.xenproject.org, kexec-ml <kexec@lists.infradead.org>, pv-drivers@vmware.com, Kazuhito Hagio <k-hagio@ab.jp.nec.com>, David Hildenbrand <david@redhat.com> Subject: [PATCH v2] makedumpfile: exclude pages that are logically offline Date: Thu, 22 Nov 2018 11:09:38 +0100 [thread overview] Message-ID: <20181122100938.5567-1-david@redhat.com> (raw) In-Reply-To: <20181122100627.5189-1-david@redhat.com> Linux marks pages that are logically offline via a page flag (map count). Such pages e.g. include pages infated as part of a balloon driver or pages that were not actually onlined when onlining the whole section. While the hypervisor usually allows to read such inflated memory, we basically read and dump data that is completely irrelevant. Also, this might result in quite some overhead in the hypervisor. In addition, we saw some problems under Hyper-V, whereby we can crash the kernel by dumping, when reading memory of a partially onlined memory segment (for memory added by the Hyper-V balloon driver). Therefore, don't read and dump pages that are marked as being logically offline. Signed-off-by: David Hildenbrand <david@redhat.com> --- v1 -> v2: - Fix PAGE_BUDDY_MAPCOUNT_VALUE vs. PAGE_OFFLINE_MAPCOUNT_VALUE makedumpfile.c | 34 ++++++++++++++++++++++++++++++---- makedumpfile.h | 1 + 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/makedumpfile.c b/makedumpfile.c index 8923538..a5f2ea9 100644 --- a/makedumpfile.c +++ b/makedumpfile.c @@ -88,6 +88,7 @@ mdf_pfn_t pfn_cache_private; mdf_pfn_t pfn_user; mdf_pfn_t pfn_free; mdf_pfn_t pfn_hwpoison; +mdf_pfn_t pfn_offline; mdf_pfn_t num_dumped; @@ -249,6 +250,21 @@ isHugetlb(unsigned long dtor) && (SYMBOL(free_huge_page) == dtor)); } +static int +isOffline(unsigned long flags, unsigned int _mapcount) +{ + if (NUMBER(PAGE_OFFLINE_MAPCOUNT_VALUE) == NOT_FOUND_NUMBER) + return FALSE; + + if (flags & (1UL << NUMBER(PG_slab))) + return FALSE; + + if (_mapcount == (int)NUMBER(PAGE_OFFLINE_MAPCOUNT_VALUE)) + return TRUE; + + return FALSE; +} + static int is_cache_page(unsigned long flags) { @@ -2287,6 +2303,8 @@ write_vmcoreinfo_data(void) WRITE_NUMBER("PG_hwpoison", PG_hwpoison); WRITE_NUMBER("PAGE_BUDDY_MAPCOUNT_VALUE", PAGE_BUDDY_MAPCOUNT_VALUE); + WRITE_NUMBER("PAGE_OFFLINE_MAPCOUNT_VALUE", + PAGE_OFFLINE_MAPCOUNT_VALUE); WRITE_NUMBER("phys_base", phys_base); WRITE_NUMBER("HUGETLB_PAGE_DTOR", HUGETLB_PAGE_DTOR); @@ -2687,6 +2705,7 @@ read_vmcoreinfo(void) READ_SRCFILE("pud_t", pud_t); READ_NUMBER("PAGE_BUDDY_MAPCOUNT_VALUE", PAGE_BUDDY_MAPCOUNT_VALUE); + READ_NUMBER("PAGE_OFFLINE_MAPCOUNT_VALUE", PAGE_OFFLINE_MAPCOUNT_VALUE); READ_NUMBER("phys_base", phys_base); #ifdef __aarch64__ READ_NUMBER("VA_BITS", VA_BITS); @@ -6041,6 +6060,12 @@ __exclude_unnecessary_pages(unsigned long mem_map, else if (isHWPOISON(flags)) { pfn_counter = &pfn_hwpoison; } + /* + * Exclude pages that are logically offline. + */ + else if (isOffline(flags, _mapcount)) { + pfn_counter = &pfn_offline; + } /* * Unexcludable page */ @@ -7522,7 +7547,7 @@ write_elf_pages_cyclic(struct cache_data *cd_header, struct cache_data *cd_page) */ if (info->flag_cyclic) { pfn_zero = pfn_cache = pfn_cache_private = 0; - pfn_user = pfn_free = pfn_hwpoison = 0; + pfn_user = pfn_free = pfn_hwpoison = pfn_offline = 0; pfn_memhole = info->max_mapnr; } @@ -8804,7 +8829,7 @@ write_kdump_pages_and_bitmap_cyclic(struct cache_data *cd_header, struct cache_d * Reset counter for debug message. */ pfn_zero = pfn_cache = pfn_cache_private = 0; - pfn_user = pfn_free = pfn_hwpoison = 0; + pfn_user = pfn_free = pfn_hwpoison = pfn_offline = 0; pfn_memhole = info->max_mapnr; /* @@ -9749,7 +9774,7 @@ print_report(void) pfn_original = info->max_mapnr - pfn_memhole; pfn_excluded = pfn_zero + pfn_cache + pfn_cache_private - + pfn_user + pfn_free + pfn_hwpoison; + + pfn_user + pfn_free + pfn_hwpoison + pfn_offline; shrinking = (pfn_original - pfn_excluded) * 100; shrinking = shrinking / pfn_original; @@ -9763,6 +9788,7 @@ print_report(void) REPORT_MSG(" User process data pages : 0x%016llx\n", pfn_user); REPORT_MSG(" Free pages : 0x%016llx\n", pfn_free); REPORT_MSG(" Hwpoison pages : 0x%016llx\n", pfn_hwpoison); + REPORT_MSG(" Offline pages : 0x%016llx\n", pfn_offline); REPORT_MSG(" Remaining pages : 0x%016llx\n", pfn_original - pfn_excluded); REPORT_MSG(" (The number of pages is reduced to %lld%%.)\n", @@ -9790,7 +9816,7 @@ print_mem_usage(void) pfn_original = info->max_mapnr - pfn_memhole; pfn_excluded = pfn_zero + pfn_cache + pfn_cache_private - + pfn_user + pfn_free + pfn_hwpoison; + + pfn_user + pfn_free + pfn_hwpoison + pfn_offline; shrinking = (pfn_original - pfn_excluded) * 100; shrinking = shrinking / pfn_original; total_size = info->page_size * pfn_original; diff --git a/makedumpfile.h b/makedumpfile.h index f02f86d..e3a2b29 100644 --- a/makedumpfile.h +++ b/makedumpfile.h @@ -1927,6 +1927,7 @@ struct number_table { long PG_hwpoison; long PAGE_BUDDY_MAPCOUNT_VALUE; + long PAGE_OFFLINE_MAPCOUNT_VALUE; long SECTION_SIZE_BITS; long MAX_PHYSMEM_BITS; long HUGETLB_PAGE_DTOR; -- 2.17.2
WARNING: multiple messages have this Message-ID (diff)
From: David Hildenbrand <david@redhat.com> To: linux-mm@kvack.org Cc: Kazuhito Hagio <k-hagio@ab.jp.nec.com>, linux-pm@vger.kernel.org, pv-drivers@vmware.com, linux-doc@vger.kernel.org, kexec-ml <kexec@lists.infradead.org>, linux-kernel@vger.kernel.org, xen-devel@lists.xenproject.org, linux-fsdevel@vger.kernel.org, devel@linuxdriverproject.org, David Hildenbrand <david@redhat.com> Subject: [PATCH v2] makedumpfile: exclude pages that are logically offline Date: Thu, 22 Nov 2018 11:09:38 +0100 [thread overview] Message-ID: <20181122100938.5567-1-david@redhat.com> (raw) In-Reply-To: <20181122100627.5189-1-david@redhat.com> Linux marks pages that are logically offline via a page flag (map count). Such pages e.g. include pages infated as part of a balloon driver or pages that were not actually onlined when onlining the whole section. While the hypervisor usually allows to read such inflated memory, we basically read and dump data that is completely irrelevant. Also, this might result in quite some overhead in the hypervisor. In addition, we saw some problems under Hyper-V, whereby we can crash the kernel by dumping, when reading memory of a partially onlined memory segment (for memory added by the Hyper-V balloon driver). Therefore, don't read and dump pages that are marked as being logically offline. Signed-off-by: David Hildenbrand <david@redhat.com> --- v1 -> v2: - Fix PAGE_BUDDY_MAPCOUNT_VALUE vs. PAGE_OFFLINE_MAPCOUNT_VALUE makedumpfile.c | 34 ++++++++++++++++++++++++++++++---- makedumpfile.h | 1 + 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/makedumpfile.c b/makedumpfile.c index 8923538..a5f2ea9 100644 --- a/makedumpfile.c +++ b/makedumpfile.c @@ -88,6 +88,7 @@ mdf_pfn_t pfn_cache_private; mdf_pfn_t pfn_user; mdf_pfn_t pfn_free; mdf_pfn_t pfn_hwpoison; +mdf_pfn_t pfn_offline; mdf_pfn_t num_dumped; @@ -249,6 +250,21 @@ isHugetlb(unsigned long dtor) && (SYMBOL(free_huge_page) == dtor)); } +static int +isOffline(unsigned long flags, unsigned int _mapcount) +{ + if (NUMBER(PAGE_OFFLINE_MAPCOUNT_VALUE) == NOT_FOUND_NUMBER) + return FALSE; + + if (flags & (1UL << NUMBER(PG_slab))) + return FALSE; + + if (_mapcount == (int)NUMBER(PAGE_OFFLINE_MAPCOUNT_VALUE)) + return TRUE; + + return FALSE; +} + static int is_cache_page(unsigned long flags) { @@ -2287,6 +2303,8 @@ write_vmcoreinfo_data(void) WRITE_NUMBER("PG_hwpoison", PG_hwpoison); WRITE_NUMBER("PAGE_BUDDY_MAPCOUNT_VALUE", PAGE_BUDDY_MAPCOUNT_VALUE); + WRITE_NUMBER("PAGE_OFFLINE_MAPCOUNT_VALUE", + PAGE_OFFLINE_MAPCOUNT_VALUE); WRITE_NUMBER("phys_base", phys_base); WRITE_NUMBER("HUGETLB_PAGE_DTOR", HUGETLB_PAGE_DTOR); @@ -2687,6 +2705,7 @@ read_vmcoreinfo(void) READ_SRCFILE("pud_t", pud_t); READ_NUMBER("PAGE_BUDDY_MAPCOUNT_VALUE", PAGE_BUDDY_MAPCOUNT_VALUE); + READ_NUMBER("PAGE_OFFLINE_MAPCOUNT_VALUE", PAGE_OFFLINE_MAPCOUNT_VALUE); READ_NUMBER("phys_base", phys_base); #ifdef __aarch64__ READ_NUMBER("VA_BITS", VA_BITS); @@ -6041,6 +6060,12 @@ __exclude_unnecessary_pages(unsigned long mem_map, else if (isHWPOISON(flags)) { pfn_counter = &pfn_hwpoison; } + /* + * Exclude pages that are logically offline. + */ + else if (isOffline(flags, _mapcount)) { + pfn_counter = &pfn_offline; + } /* * Unexcludable page */ @@ -7522,7 +7547,7 @@ write_elf_pages_cyclic(struct cache_data *cd_header, struct cache_data *cd_page) */ if (info->flag_cyclic) { pfn_zero = pfn_cache = pfn_cache_private = 0; - pfn_user = pfn_free = pfn_hwpoison = 0; + pfn_user = pfn_free = pfn_hwpoison = pfn_offline = 0; pfn_memhole = info->max_mapnr; } @@ -8804,7 +8829,7 @@ write_kdump_pages_and_bitmap_cyclic(struct cache_data *cd_header, struct cache_d * Reset counter for debug message. */ pfn_zero = pfn_cache = pfn_cache_private = 0; - pfn_user = pfn_free = pfn_hwpoison = 0; + pfn_user = pfn_free = pfn_hwpoison = pfn_offline = 0; pfn_memhole = info->max_mapnr; /* @@ -9749,7 +9774,7 @@ print_report(void) pfn_original = info->max_mapnr - pfn_memhole; pfn_excluded = pfn_zero + pfn_cache + pfn_cache_private - + pfn_user + pfn_free + pfn_hwpoison; + + pfn_user + pfn_free + pfn_hwpoison + pfn_offline; shrinking = (pfn_original - pfn_excluded) * 100; shrinking = shrinking / pfn_original; @@ -9763,6 +9788,7 @@ print_report(void) REPORT_MSG(" User process data pages : 0x%016llx\n", pfn_user); REPORT_MSG(" Free pages : 0x%016llx\n", pfn_free); REPORT_MSG(" Hwpoison pages : 0x%016llx\n", pfn_hwpoison); + REPORT_MSG(" Offline pages : 0x%016llx\n", pfn_offline); REPORT_MSG(" Remaining pages : 0x%016llx\n", pfn_original - pfn_excluded); REPORT_MSG(" (The number of pages is reduced to %lld%%.)\n", @@ -9790,7 +9816,7 @@ print_mem_usage(void) pfn_original = info->max_mapnr - pfn_memhole; pfn_excluded = pfn_zero + pfn_cache + pfn_cache_private - + pfn_user + pfn_free + pfn_hwpoison; + + pfn_user + pfn_free + pfn_hwpoison + pfn_offline; shrinking = (pfn_original - pfn_excluded) * 100; shrinking = shrinking / pfn_original; total_size = info->page_size * pfn_original; diff --git a/makedumpfile.h b/makedumpfile.h index f02f86d..e3a2b29 100644 --- a/makedumpfile.h +++ b/makedumpfile.h @@ -1927,6 +1927,7 @@ struct number_table { long PG_hwpoison; long PAGE_BUDDY_MAPCOUNT_VALUE; + long PAGE_OFFLINE_MAPCOUNT_VALUE; long SECTION_SIZE_BITS; long MAX_PHYSMEM_BITS; long HUGETLB_PAGE_DTOR; -- 2.17.2 _______________________________________________ kexec mailing list kexec@lists.infradead.org http://lists.infradead.org/mailman/listinfo/kexec
next prev parent reply other threads:[~2018-11-22 10:09 UTC|newest] Thread overview: 75+ messages / expand[flat|nested] mbox.gz Atom feed top 2018-11-22 10:06 [PATCH v2 0/8] mm/kdump: allow to exclude pages that are logically offline David Hildenbrand 2018-11-22 10:06 ` David Hildenbrand 2018-11-22 10:06 ` David Hildenbrand 2018-11-22 10:06 ` [PATCH v2 1/8] mm: balloon: update comment about isolation/migration/compaction David Hildenbrand 2018-11-22 10:06 ` David Hildenbrand 2018-11-22 10:06 ` David Hildenbrand 2018-11-22 10:06 ` [PATCH v2 2/8] mm: convert PG_balloon to PG_offline David Hildenbrand 2018-11-22 10:06 ` David Hildenbrand 2018-11-22 10:06 ` David Hildenbrand 2018-11-22 10:06 ` David Hildenbrand 2018-11-22 10:06 ` [PATCH v2 3/8] kexec: export PG_offline to VMCOREINFO David Hildenbrand 2018-11-22 10:06 ` David Hildenbrand 2018-11-22 10:06 ` David Hildenbrand 2019-03-11 9:04 ` Dave Young 2019-03-11 9:04 ` Dave Young 2019-03-11 9:04 ` Dave Young 2019-03-11 9:55 ` David Hildenbrand 2019-03-11 9:55 ` David Hildenbrand 2019-03-11 9:55 ` David Hildenbrand 2019-03-11 10:04 ` Dave Young 2019-03-11 10:04 ` Dave Young 2019-03-11 10:04 ` Dave Young 2018-11-22 10:06 ` David Hildenbrand 2018-11-22 10:06 ` [PATCH v2 4/8] xen/balloon: mark inflated pages PG_offline David Hildenbrand 2018-11-22 10:06 ` David Hildenbrand 2018-11-23 13:41 ` Juergen Gross 2018-11-23 13:41 ` Juergen Gross 2018-11-23 13:41 ` Juergen Gross 2018-11-23 13:41 ` Juergen Gross 2018-11-22 10:06 ` David Hildenbrand 2018-11-22 10:06 ` [PATCH v2 5/8] hv_balloon: " David Hildenbrand 2018-11-22 10:06 ` David Hildenbrand 2018-11-22 10:06 ` David Hildenbrand 2018-11-22 10:06 ` [PATCH v2 6/8] vmw_balloon: " David Hildenbrand 2018-11-22 10:06 ` David Hildenbrand 2018-11-22 10:06 ` David Hildenbrand 2018-11-22 10:06 ` [PATCH v2 7/8] PM / Hibernate: use pfn_to_online_page() David Hildenbrand 2018-11-22 10:06 ` David Hildenbrand 2018-11-22 10:06 ` David Hildenbrand 2018-11-22 10:06 ` [PATCH v2 8/8] PM / Hibernate: exclude all PageOffline() pages David Hildenbrand 2018-11-22 10:06 ` David Hildenbrand 2018-11-22 10:06 ` David Hildenbrand 2018-11-22 10:09 ` [PATCH v2] makedumpfile: exclude pages that are logically offline David Hildenbrand 2018-11-22 10:09 ` David Hildenbrand [this message] 2018-11-22 10:09 ` David Hildenbrand 2018-11-27 16:32 ` Kazuhito Hagio 2018-11-27 16:32 ` Kazuhito Hagio 2018-11-27 16:32 ` Kazuhito Hagio 2019-03-07 8:41 ` David Hildenbrand 2019-03-07 8:41 ` David Hildenbrand 2019-03-07 8:41 ` David Hildenbrand 2019-03-11 16:40 ` Kazuhito Hagio 2019-03-11 16:40 ` Kazuhito Hagio 2019-03-11 16:40 ` Kazuhito Hagio 2018-11-27 16:32 ` Kazuhito Hagio 2019-02-27 5:32 ` [PATCH v2 0/8] mm/kdump: allow to " Dave Young 2019-02-27 5:32 ` Dave Young 2019-02-27 5:32 ` Dave Young 2019-02-28 19:45 ` Andrew Morton 2019-02-28 19:45 ` Andrew Morton 2019-02-28 19:45 ` Andrew Morton 2019-02-28 19:45 ` Andrew Morton 2019-02-28 19:54 ` Boris Ostrovsky 2019-02-28 19:54 ` Boris Ostrovsky 2019-02-28 19:54 ` Boris Ostrovsky 2019-02-28 19:54 ` Boris Ostrovsky 2019-03-04 6:21 ` Dave Young 2019-03-04 6:21 ` Dave Young 2019-03-04 6:21 ` Dave Young 2019-03-04 6:21 ` Dave Young 2019-03-04 7:14 ` Juergen Gross [not found] ` <20190304062118.GA31037-0VdLhd/A9Pl+NNSt+8eSiB/sF2h8X+2i0E9HWUfgJXw@public.gmane.org> 2019-03-04 7:14 ` Juergen Gross 2019-03-04 7:14 ` Juergen Gross 2019-03-04 7:14 ` Juergen Gross 2019-02-27 5:32 ` Dave Young
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20181122100938.5567-1-david@redhat.com \ --to=david@redhat.com \ --cc=devel@linuxdriverproject.org \ --cc=k-hagio@ab.jp.nec.com \ --cc=kexec@lists.infradead.org \ --cc=linux-doc@vger.kernel.org \ --cc=linux-fsdevel@vger.kernel.org \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-mm@kvack.org \ --cc=linux-pm@vger.kernel.org \ --cc=pv-drivers@vmware.com \ --cc=xen-devel@lists.xenproject.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.