From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,HTML_MESSAGE,INCLUDES_PATCH,MAILING_LIST_MULTI, MENTIONS_GIT_HOSTING,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C09C6C3F2D1 for ; Thu, 5 Mar 2020 21:15:42 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 62B2220728 for ; Thu, 5 Mar 2020 21:15:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="e++3iRgJ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 62B2220728 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id ED7706B0005; Thu, 5 Mar 2020 16:15:41 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E60736B0006; Thu, 5 Mar 2020 16:15:41 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D27966B0007; Thu, 5 Mar 2020 16:15:41 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0166.hostedemail.com [216.40.44.166]) by kanga.kvack.org (Postfix) with ESMTP id B09AC6B0005 for ; Thu, 5 Mar 2020 16:15:41 -0500 (EST) Received: from smtpin13.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 5AF848248068 for ; Thu, 5 Mar 2020 21:15:41 +0000 (UTC) X-FDA: 76562565282.13.push75_88e411fa2a733 X-HE-Tag: push75_88e411fa2a733 X-Filterd-Recvd-Size: 30487 Received: from mail-yw1-f68.google.com (mail-yw1-f68.google.com [209.85.161.68]) by imf23.hostedemail.com (Postfix) with ESMTP for ; Thu, 5 Mar 2020 21:15:40 +0000 (UTC) Received: by mail-yw1-f68.google.com with SMTP id j71so173192ywb.3 for ; Thu, 05 Mar 2020 13:15:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=GU7KuVuJKzc2eGIPaUfwL/KVkQUEf93Ud2HZkrvFbrQ=; b=e++3iRgJtrgt7JANf2Rapggyatpp3VH3dG1yADbKfzZxduxMuLHVip4RLLFauFOLc8 l1nLemsA0FMGs/d4hYqmpbDfehR+814Bn8XAln53NJ5yWIJp06ljiPvhfQeuiUV2rFy3 yMerCtk7uxMqGZ6uglEJs1XsLJ9bqV5uSLqVs5vIEfGUcB6vtsYlTFHLPdYHxtuEmvmK Ie5bKpIHmiGbISTQxHyIpa1PuLENtiNsh/McIwBsEpX/r5QgrjSjKAQHCrN9tYgBOS/B uSAhJHlYUmoIW2kRl9FsIC/i7kFGHEbbwf8ulmtl6ZX5vl67eo1N+JG+p/SQbUqbvQSO mOcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=GU7KuVuJKzc2eGIPaUfwL/KVkQUEf93Ud2HZkrvFbrQ=; b=Q0iWAWUML93tLbC0hSZLSQOBrP/Avkmm8EAKU/QjaNWFF+FwNh44ehtq0rYt0XNnRt MSyhzcyNo48Lli9ejh4ho6rPjpZ+Kz4BCTBmoiQGr7RbtJqBXX7dbo0u121SBLNtLIZY uqQz1MvqPvtOiFH1LV5/h27RZH17zz+3THC/Bqx4nGb0jQhvDQA2OKI0AuIN5mPDtiL8 slebxYszhvkdm55ar1MTszl8RXckjASnNfDTSYfuYHbfUTI0uFv6xqjDZH0BT0fHpEzQ aKSLmd1BZjdWA9IaeOpif/kZC0hJzpOZrtTKqtU+P1q1e88he6FaSYoAPUhQp0u7vMAX Bl6Q== X-Gm-Message-State: ANhLgQ3HrWkUjS20o32gE9R09rimQLY3jdyUxeJDYB1jiFJnY+5qehyV 4fENGdvnOB+KSSlL9xplypzE4kR9otkEMFSjvlyK2XXd X-Google-Smtp-Source: ADFU+vsXO3Hs6Ax8bUCtof6hvRGdWhAUqQDykIYBs/azPZ7/0lcRLebS+z0HHw6X/zJsHRh5qLjjhtqShewFwIrqT0g= X-Received: by 2002:a81:1d53:: with SMTP id d80mr441927ywd.209.1583442937707; Thu, 05 Mar 2020 13:15:37 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Marshall Midden Date: Thu, 5 Mar 2020 15:15:26 -0600 Message-ID: Subject: Re: kdump twirling - does not finish - commit 326e1b8f83a4318b09033ef754f40c785aed5e68 To: linux-mm@kvack.org Cc: David Hildenbrand Content-Type: multipart/alternative; boundary="000000000000d2ff5505a02209cc" 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: --000000000000d2ff5505a02209cc Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable I wish to extend a big thanks to David Hildenbrand from redhat regarding a comment (whereupon we lost the mailing list), asking if I had upgraded makedumpfile. And thanks to Mark Rustad (@ intel) for several suggestions -- like using "make defconfig" and having just a few items added (MD_RAID1, DM_UEVENT, and XFS) - and what does it do on a VM. I have learnt more things to try before reaching out to the community. A five month delay from the code checked into kernel.org and makedumpfile updated -- data point interpolation suspended because my brain hurts. ;) Okay, for my v5.3. with 10 local patches -- the compiled makedumpfile fixes the kdump twirling @ 100%. Author: Marshall Midden Date: Mon Sep 16 17:20:53 2019 -0500 PE-2713 Move to released kernel v5.3 from release candidate v5.3-rc8. For v5.6-rc4 it also works. *whew* [image: Screen Shot 2020-03-05 at 14.26.10.png] git clone https://git.code.sf.net/p/makedumpfile/code makedumpfile [fix Makefile, etc...]... makedumpfile -v makedumpfile: version 1.6.7 (released on 16 Jan 2020) Author: Kazuhito Hagio Date: Tue Jan 14 15:30:02 2020 -0500 [PATCH] Support newer kernels up to v5.4 Support newer kernels as follows: - 5.2, 5.3, 5.4 (x86_64 SPARSEMEM) - 5.4 (x86 FLATMEM, SPARSEMEM) On Wed, Mar 4, 2020 at 11:03 AM Marshall Midden wrote: > I know a translator is required - trying... Mark - is this better than > typical? > > Problem: kdump is not finishing, hangs twirling ... iKVM > Found: Power failure. Qlogic/Cavium/Marvell driver crash, but no kernel > dump. v5.3.8+local. > Reproduce: Boot, "echo c > /proc/sysrq-trigger" > Last known working release: v5.2.x (any of them). > First release failure: v5.3-rc1 > Tried many versions up to v5.6-rc4 (2020-03-01). > > Repository: > https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git > System: Supermicro X10 dual socket x86_64, 64g/256g/512g (different > systems/MB/CPUs). > UserLand: RedHat7.5 > Tried (did not fix) kexec-tools fetched Feb 25th, 2020 from: > git://git.kernel.org/pub/scm/utils/kernel/kexec/kexec-tools.git > .config: No modules, except those listed below (only 10 "=3Dm"). > No modules in initramfs, /etc/dracut.conf.d/xxxx: > omit_drivers+=3D"qla2xxx nfs_layout_flexfiles" > omit_drivers+=3D" tcm_loop tcm_fc target_core_mod iscsi_target_mod > target_core_file" > omit_drivers+=3D" target_core_iblock target_core_mod target_core_pscs= i" > > Commit where problem appeared (git bisect): > commit 326e1b8f83a4318b09033ef754f40c785aed5e68 > Author: Dan Williams > Date: Thu Jul 18 15:58:00 2019 -0700 > > -------------------------------------------------------------------------= ----- > -rw------- 1 root root 2174976 Feb 28 13:33 vmcore-incomplete > -rw-r--r-- 1 root root 87611 Feb 28 13:33 vmcore-dmesg.txt > verses > -rw------- 1 root root 1186929986 Mar 3 18:57 vmcore > -rw-r--r-- 1 root root 181709 Mar 3 18:57 vmcore-dmesg.txt > > -------------------------------------------------------------------------= ----- > What am I breaking -- if I comment out the usage of early_section(ms) > in file mm/sparse.c -- although kdump's seems to work fine, etc. > // bool section_is_early =3D early_section(ms); > ... > // if (!section_is_early) { > kfree(ms->usage); > ms->usage =3D NULL; > // } > > -------------------------------------------------------------------------= ----- > Humor: > commit 5f9e832c137075045d15cd6899ab0505cfb2ca4b (tag: v5.3-rc1) > Author: Linus Torvalds > Date: Sun Jul 21 14:05:38 2019 -0700 > Linus 5.3-rc1 > ^ > Horror: > No one else has run into this since the end of July? > > -------------------------------------------------------------------------= ----- > Full git show below: > > commit 326e1b8f83a4318b09033ef754f40c785aed5e68 > Author: Dan Williams > Date: Thu Jul 18 15:58:00 2019 -0700 > > mm/sparsemem: introduce a SECTION_IS_EARLY flag > > In preparation for sub-section hotplug, track whether a given section > was created during early memory initialization, or later via memory > hotplug. This distinction is needed to maintain the coarse expectati= on > that pfn_valid() returns true for any pfn within a given section even > if > that section has pages that are reserved from the page allocator. > > For example one of the of goals of subsection hotplug is to support > cases where the system physical memory layout collides System RAM and > PMEM within a section. Several pfn_valid() users expect to just chec= k > if a section is valid, but they are not careful to check if the given > pfn is within a "System RAM" boundary and instead expect pgdat > information to further validate the pfn. > > Rather than unwind those paths to make their pfn_valid() queries more > precise a follow on patch uses the SECTION_IS_EARLY flag to maintain > the > traditional expectation that pfn_valid() returns true for all early > sections. > > Link: > https://lore.kernel.org/lkml/1560366952-10660-1-git-send-email-cai@lca.pw= / > Link: > http://lkml.kernel.org/r/156092350358.979959.5817209875548072819.stgit@dw= illia2-desk3.amr.corp.intel.com > Signed-off-by: Dan Williams > Reported-by: Qian Cai > Tested-by: Aneesh Kumar K.V > [ppc64] > Reviewed-by: Oscar Salvador > Cc: Michal Hocko > Cc: Logan Gunthorpe > Cc: David Hildenbrand > Cc: Pavel Tatashin > Cc: Jane Chu > Cc: Jeff Moyer > Cc: J=C3=A9r=C3=B4me Glisse > Cc: Jonathan Corbet > Cc: Mike Rapoport > Cc: Toshi Kani > Cc: Vlastimil Babka > Cc: Wei Yang > Cc: Jason Gunthorpe > Cc: Christoph Hellwig > Signed-off-by: Andrew Morton > Signed-off-by: Linus Torvalds > > diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h > index 2520336bdfd1..4be40634238b 100644 > --- a/include/linux/mmzone.h > +++ b/include/linux/mmzone.h > @@ -1260,7 +1260,8 @@ extern size_t mem_section_usage_size(void); > #define SECTION_MARKED_PRESENT (1UL<<0) > #define SECTION_HAS_MEM_MAP (1UL<<1) > #define SECTION_IS_ONLINE (1UL<<2) > -#define SECTION_MAP_LAST_BIT (1UL<<3) > +#define SECTION_IS_EARLY (1UL<<3) > +#define SECTION_MAP_LAST_BIT (1UL<<4) > #define SECTION_MAP_MASK (~(SECTION_MAP_LAST_BIT-1)) > #define SECTION_NID_SHIFT 3 > > @@ -1286,6 +1287,11 @@ static inline int valid_section(struct mem_section > *section) > return (section && (section->section_mem_map & > SECTION_HAS_MEM_MAP)); > } > > +static inline int early_section(struct mem_section *section) > +{ > + return (section && (section->section_mem_map & SECTION_IS_EARLY))= ; > +} > + > static inline int valid_section_nr(unsigned long nr) > { > return valid_section(__nr_to_section(nr)); > diff --git a/mm/sparse.c b/mm/sparse.c > index 41bef8e1f65c..6d23a526279a 100644 > --- a/mm/sparse.c > +++ b/mm/sparse.c > @@ -288,11 +288,11 @@ struct page *sparse_decode_mem_map(unsigned long > coded_mem_map, unsigned long pn > > static void __meminit sparse_init_one_section(struct mem_section *ms, > unsigned long pnum, struct page *mem_map, > - struct mem_section_usage *usage) > + struct mem_section_usage *usage, unsigned long flags) > { > ms->section_mem_map &=3D ~SECTION_MAP_MASK; > - ms->section_mem_map |=3D sparse_encode_mem_map(mem_map, pnum) | > - > SECTION_HAS_MEM_MAP; > + ms->section_mem_map |=3D sparse_encode_mem_map(mem_map, pnum) > + | SECTION_HAS_MEM_MAP | flags; > ms->usage =3D usage; > } > > @@ -497,7 +497,8 @@ static void __init sparse_init_nid(int nid, unsigned > long pnum_begin, > goto failed; > } > check_usemap_section_nr(nid, usage); > - sparse_init_one_section(__nr_to_section(pnum), pnum, map, > usage); > + sparse_init_one_section(__nr_to_section(pnum), pnum, map, > usage, > + SECTION_IS_EARLY); > usage =3D (void *) usage + mem_section_usage_size(); > } > sparse_buffer_fini(); > @@ -732,7 +733,7 @@ int __meminit sparse_add_one_section(int nid, unsigne= d > long start_pfn, > > set_section_nid(section_nr, nid); > section_mark_present(ms); > - sparse_init_one_section(ms, section_nr, memmap, usage); > + sparse_init_one_section(ms, section_nr, memmap, usage, 0); > > out: > if (ret < 0) { > @@ -772,19 +773,16 @@ static inline void clear_hwpoisoned_pages(struct > page *memmap, int nr_pages) > } > #endif > > -static void free_section_usage(struct page *memmap, > +static void free_section_usage(struct mem_section *ms, struct page > *memmap, > struct mem_section_usage *usage, struct vmem_altmap > *altmap) > { > - struct page *usage_page; > - > if (!usage) > return; > > - usage_page =3D virt_to_page(usage); > /* > * Check to see if allocation came from hot-plug-add > */ > - if (PageSlab(usage_page) || PageCompound(usage_page)) { > + if (!early_section(ms)) { > kfree(usage); > if (memmap) > __kfree_section_memmap(memmap, altmap); > @@ -816,6 +814,6 @@ void sparse_remove_one_section(struct mem_section *ms= , > unsigned long map_offset, > > clear_hwpoisoned_pages(memmap + map_offset, > PAGES_PER_SECTION - map_offset); > - free_section_usage(memmap, usage, altmap); > + free_section_usage(ms, memmap, usage, altmap); > } > #endif /* CONFIG_MEMORY_HOTPLUG */ > > --000000000000d2ff5505a02209cc Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
I wish to extend a big thanks to David Hildenbrand fr= om redhat regarding a comment (whereupon we lost the mailing list), asking = if I had upgraded makedumpfile.
And thanks to Mark Rustad (@ = intel) for several suggestions -- like using "make defconfig" and= having just a few items added (MD_RAID1, DM_UEVENT, and XFS) - and what do= es it do on a VM. I have learnt more things to try before reaching out to t= he community.

A five month delay from the code che= cked into kernel.org and makedumpfile upd= ated -- data point interpolation suspended because my brain hurts. ;)
<= /div>

Okay, for my v5.3. with 10 local patches --=C2=A0 = the compiled makedumpfile fixes the kdump twirling @ 100%.=C2=A0
=
Author: Marshall Midden &l= t;m4@parseclabs.com<= /a>>
Date: =C2=A0 Mon Sep 16 17:20:53 2019 -0500
=C2=A0 =C2=A0 PE-= 2713 Move to released kernel v5.3 from release candidate v5.3-rc8.

makedumpfile -v
=
makedumpfile: version 1.6.7 (released on 16= Jan 2020)
Author: Kazuhito Hagio <k-hagio-ab@nec.com>Date: =C2=A0 Tue Jan 14 15:30:02 2020 -0500
=C2=A0 =C2=A0 [PATCH] Suppo= rt newer kernels up to v5.4
=C2=A0 =C2=A0 Support newer kernels as follo= ws:
=C2=A0 =C2=A0 =C2=A0 - 5.2, 5.3, 5.4 =C2=A0(x86_64 SPARSEMEM)
=C2= =A0 =C2=A0 =C2=A0 - 5.4 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(x86 FLATM= EM, SPARSEMEM)

On Wed, Mar 4, 2020 at 11:03 AM Marshall M= idden <marshallmidden@gmail.= com> wrote:
I know a translator is required - trying... Mark - is t= his better than typical?

Problem: kdump is not finishing, hangs twir= ling ... iKVM
Found: Power failure. Qlogic/Cavium/Marvell driver cr= ash, but no kernel dump.=C2=A0 v5.3.8+local.
Reproduce: Boot, "ec= ho c > /proc/sysrq-trigger"
Last known working release: v5.2.x (= any of them).
First release failure: v5.3-rc1
Tried many versions up = to v5.6-rc4 (2020-03-01).

Repository: https://gi= t.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
System: Super= micro X10 dual socket x86_64, 64g/256g/512g (different systems/MB/CPUs).UserLand: RedHat7.5
Tried (did not fix) kexec-tools fetched Feb 25th, 2= 020 from:
=C2=A0 =C2=A0 git://git.kernel.org/pub/scm= /utils/kernel/kexec/kexec-tools.git
.config: No modules, except thos= e listed below (only 10 "=3Dm").
No modules in initramfs, /etc= /dracut.conf.d/xxxx:
=C2=A0 =C2=A0 omit_drivers+=3D"qla2xxx nfs_lay= out_flexfiles"
=C2=A0 =C2=A0 omit_drivers+=3D" tcm_loop tcm_fc= target_core_mod iscsi_target_mod target_core_file"
=C2=A0 =C2=A0 o= mit_drivers+=3D" target_core_iblock target_core_mod target_core_pscsi&= quot;

Commit where problem appeared (git bisect):
=C2=A0 =C2=A0 c= ommit 326e1b8f83a4318b09033ef754f40c785aed5e68
=C2=A0 =C2=A0 Author: Dan= Williams <dan.j.williams@intel.com>
=C2=A0 =C2=A0 Date: =C2=A0 Thu Jul 18 = 15:58:00 2019 -0700
----------------------------------------------------= --------------------------
-rw------- 1 root root 2174976 Feb 28 13:33 v= mcore-incomplete
-rw-r--r-- 1 root root =C2=A0 87611 Feb 28 13:33 vmcore= -dmesg.txt
verses
-rw------- 1 root root 1186929986 Mar =C2=A03 18:57= vmcore
-rw-r--r-- 1 root root =C2=A0 =C2=A0 181709 Mar =C2=A03 18:57 vm= core-dmesg.txt
---------------------------------------------------------= ---------------------
What am I breaking -- if I comment out the usage o= f early_section(ms)
in file mm/sparse.c -- although kdump's seems to= work fine, etc.
// =C2=A0 =C2=A0 =C2=A0= bool section_is_early =3D early_section(ms);
...
// =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if (!section_is_early) {
=C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 kfree= (ms->usage);
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 ms->usage =3D NULL;
// =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0}
---------------------------------= ---------------------------------------------
Humor:
=C2=A0 =C2=A0 co= mmit 5f9e832c137075045d15cd6899ab0505cfb2ca4b (tag: v5.3-rc1)
=C2=A0 =C2= =A0 Author: Linus Torvalds <torvalds@linux-foundation.org>
=C2=A0 =C2= =A0 Date: =C2=A0 Sun Jul 21 14:05:38 2019 -0700
=C2=A0 =C2=A0 =C2=A0 =C2= =A0 Linus 5.3-rc1
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ^
Horror:=
=C2=A0 =C2=A0 No one else has run into this since the end of July?
<= div>-----------------------------------------------------------------------= -------
Full git show below:

commit 326e1b8f83a4318b09033e= f754f40c785aed5e68
Author: Dan Williams <dan.j.williams@intel.com>
Date:= =C2=A0 Thu Jul 18 15:58:00 2019 -0700

=C2=A0 =C2=A0 mm/sparsemem: i= ntroduce a SECTION_IS_EARLY flag

=C2=A0 =C2=A0 In preparation for su= b-section hotplug, track whether a given section
=C2=A0 =C2=A0 was creat= ed during early memory initialization, or later via memory
=C2=A0 =C2=A0= hotplug.=C2=A0 This distinction is needed to maintain the coarse expectati= on
=C2=A0 =C2=A0 that pfn_valid() returns true for any pfn within a give= n section even if
=C2=A0 =C2=A0 that section has pages that are reserved= from the page allocator.

=C2=A0 =C2=A0 For example one of the of go= als of subsection hotplug is to support
=C2=A0 =C2=A0 cases where the sy= stem physical memory layout collides System RAM and
=C2=A0 =C2=A0 PMEM w= ithin a section.=C2=A0 Several pfn_valid() users expect to just check
= =C2=A0 =C2=A0 if a section is valid, but they are not careful to check if t= he given
=C2=A0 =C2=A0 pfn is within a "System RAM" boundary a= nd instead expect pgdat
=C2=A0 =C2=A0 information to further validate th= e pfn.

=C2=A0 =C2=A0 Rather than unwind those paths to make their pf= n_valid() queries more
=C2=A0 =C2=A0 precise a follow on patch uses the = SECTION_IS_EARLY flag to maintain the
=C2=A0 =C2=A0 traditional expectat= ion that pfn_valid() returns true for all early
=C2=A0 =C2=A0 sections.<= br>
=C2=A0 =C2=A0 Link: https://lore.kerne= l.org/lkml/1560366952-10660-1-git-send-email-cai@lca.pw/
=C2=A0 =C2= =A0 Link: http:= //lkml.kernel.org/r/156092350358.979959.5817209875548072819.stgit@dwillia2-= desk3.amr.corp.intel.com
=C2=A0 =C2=A0 Signed-off-by: Dan Williams &= lt;dan.j.will= iams@intel.com>
=C2=A0 =C2=A0 Reported-by: Qian Cai <cai@lca.pw>
=C2=A0 =C2= =A0 Tested-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com> =C2=A0 =C2=A0 = =C2=A0 =C2=A0[ppc64]
=C2=A0 =C2=A0 Reviewed-by: Oscar Salvador <osalvador@suse.de>=
=C2=A0 =C2=A0 Cc: Michal Hocko <mhocko@suse.com>
=C2=A0 =C2=A0 Cc: Logan Gunthor= pe <logang@delt= atee.com>
=C2=A0 =C2=A0 Cc: David Hildenbrand <david@redhat.com>
=C2=A0 = =C2=A0 Cc: Pavel Tatashin <pasha.tatashin@soleen.com>
=C2=A0 =C2=A0 Cc: Ja= ne Chu <jane.ch= u@oracle.com>
=C2=A0 =C2=A0 Cc: Jeff Moyer <jmoyer@redhat.com>
=C2=A0 = =C2=A0 Cc: J=C3=A9r=C3=B4me Glisse <jglisse@redhat.com>
=C2=A0 =C2=A0 Cc: Jonatha= n Corbet <corbet@lwn= .net>
=C2=A0 =C2=A0 Cc: Mike Rapoport <rppt@linux.ibm.com>
=C2=A0 =C2= =A0 Cc: Toshi Kani <toshi.kani@hpe.com>
=C2=A0 =C2=A0 Cc: Vlastimil Babka <vbabka@suse.cz>
= =C2=A0 =C2=A0 Cc: Wei Yang <richardw.yang@linux.intel.com>
=C2=A0 =C2= =A0 Cc: Jason Gunthorpe <jgg@mellanox.com>
=C2=A0 =C2=A0 Cc: Christoph Hellwig <= hch@lst.de>
=C2= =A0 =C2=A0 Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
=C2=A0= =C2=A0 Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
=
diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
index 2= 520336bdfd1..4be40634238b 100644
--- a/include/linux/mmzone.h
+++ b/i= nclude/linux/mmzone.h
@@ -1260,7 +1260,8 @@ extern size_t mem_section_us= age_size(void);
=C2=A0#define =C2=A0 =C2=A0 =C2=A0 =C2=A0SECTION_MARKED_= PRESENT =C2=A0(1UL<<0)
=C2=A0#define SECTION_HAS_MEM_MAP =C2=A0 = =C2=A0(1UL<<1)
=C2=A0#define SECTION_IS_ONLINE =C2=A0 =C2=A0 =C2= =A0(1UL<<2)
-#define SECTION_MAP_LAST_BIT =C2=A0 (1UL<<3)+#define SECTION_IS_EARLY =C2=A0 =C2=A0 =C2=A0 (1UL<<3)
+#define = SECTION_MAP_LAST_BIT =C2=A0 (1UL<<4)
=C2=A0#define SECTION_MAP_MAS= K =C2=A0 =C2=A0 =C2=A0 (~(SECTION_MAP_LAST_BIT-1))
=C2=A0#define SECTION= _NID_SHIFT =C2=A0 =C2=A0 =C2=A03

@@ -1286,6 +1287,11 @@ static inlin= e int valid_section(struct mem_section *section)
=C2=A0 =C2=A0 =C2=A0 = =C2=A0 return (section && (section->section_mem_map & SECTIO= N_HAS_MEM_MAP));
=C2=A0}

+static inline int early_section(struct = mem_section *section)
+{
+ =C2=A0 =C2=A0 =C2=A0 return (section &= & (section->section_mem_map & SECTION_IS_EARLY));
+}
+
= =C2=A0static inline int valid_section_nr(unsigned long nr)
=C2=A0{
= =C2=A0 =C2=A0 =C2=A0 =C2=A0 return valid_section(__nr_to_section(nr));
d= iff --git a/mm/sparse.c b/mm/sparse.c
index 41bef8e1f65c..6d23a526279a 1= 00644
--- a/mm/sparse.c
+++ b/mm/sparse.c
@@ -288,11 +288,11 @@ st= ruct page *sparse_decode_mem_map(unsigned long coded_mem_map, unsigned long= pn

=C2=A0static void __meminit sparse_init_one_section(struct mem_s= ection *ms,
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 unsi= gned long pnum, struct page *mem_map,
- =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 struct mem_section_usage *usage)
+ =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 struct mem_section_usage *usage, unsigned l= ong flags)
=C2=A0{
=C2=A0 =C2=A0 =C2=A0 =C2=A0 ms->section_mem_map= &=3D ~SECTION_MAP_MASK;
- =C2=A0 =C2=A0 =C2=A0 ms->section_mem_m= ap |=3D sparse_encode_mem_map(mem_map, pnum) |
- =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 SECTION_HAS_MEM_MAP;
+ =C2=A0 =C2=A0 =C2=A0 ms->= section_mem_map |=3D sparse_encode_mem_map(mem_map, pnum)
+ =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | SECTION_HAS_MEM_MAP | flags;
= =C2=A0 =C2=A0 =C2=A0 =C2=A0 ms->usage =3D usage;
=C2=A0}

@@ -4= 97,7 +497,8 @@ static void __init sparse_init_nid(int nid, unsigned long pn= um_begin,
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 goto failed;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 }
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 check_usemap_section_nr(nid, usage);
- =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 sparse_init_one_section(__nr_to_section(pnum), pnu= m, map, usage);
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 spars= e_init_one_section(__nr_to_section(pnum), pnum, map, usage,
+ =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 SECTION_IS_EARLY);
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 usage =3D (void *) usage + mem_section_usage_size(= );
=C2=A0 =C2=A0 =C2=A0 =C2=A0 }
=C2=A0 =C2=A0 =C2=A0 =C2=A0 sparse_b= uffer_fini();
@@ -732,7 +733,7 @@ int __meminit sparse_add_one_section(i= nt nid, unsigned long start_pfn,

=C2=A0 =C2=A0 =C2=A0 =C2=A0 set_sec= tion_nid(section_nr, nid);
=C2=A0 =C2=A0 =C2=A0 =C2=A0 section_mark_pres= ent(ms);
- =C2=A0 =C2=A0 =C2=A0 sparse_init_one_section(ms, section_nr, = memmap, usage);
+ =C2=A0 =C2=A0 =C2=A0 sparse_init_one_section(ms, secti= on_nr, memmap, usage, 0);

=C2=A0out:
=C2=A0 =C2=A0 =C2=A0 =C2=A0 = if (ret < 0) {
@@ -772,19 +773,16 @@ static inline void clear_= hwpoisoned_pages(struct page *memmap, int nr_pages)
=C2=A0}
=C2=A0#en= dif

-static void free_section_usage(struct page *memmap,
+static = void free_section_usage(struct mem_section *ms, struct page *memmap,
=C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 struct mem_section_usa= ge *usage, struct vmem_altmap *altmap)
=C2=A0{
- =C2=A0 =C2=A0 =C2=A0= struct page *usage_page;
-
=C2=A0 =C2=A0 =C2=A0 =C2=A0 if (!usage)=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 return;

- = =C2=A0 =C2=A0 =C2=A0 usage_page =3D virt_to_page(usage);
=C2=A0 =C2=A0 = =C2=A0 =C2=A0 /*
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0* Check to see if all= ocation came from hot-plug-add
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0*/
-= =C2=A0 =C2=A0 =C2=A0 if (PageSlab(usage_page) || PageCompound(usage_page))= {
+ =C2=A0 =C2=A0 =C2=A0 if (!early_section(ms)) {
=C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 kfree(usage);
=C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if (memmap)
=C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 __kfree_sect= ion_memmap(memmap, altmap);
@@ -816,6 +814,6 @@ void sparse_remove_one_s= ection(struct mem_section *ms, unsigned long map_offset,

=C2=A0 =C2= =A0 =C2=A0 =C2=A0 clear_hwpoisoned_pages(memmap + map_offset,
=C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 P= AGES_PER_SECTION - map_offset);
- =C2=A0 =C2=A0 =C2=A0 free_section_usag= e(memmap, usage, altmap);
+ =C2=A0 =C2=A0 =C2=A0 free_section_usage(ms, = memmap, usage, altmap);
=C2=A0}
=C2=A0#endif /* CONFIG_MEMORY_HOTPLUG= */

--000000000000d2ff5505a02209cc--