From: David Hildenbrand <david@redhat.com>
To: Alastair D'Silva <alastair@au1.ibm.com>, alastair@d-silva.org
Cc: Andrew Morton <akpm@linux-foundation.org>,
Oscar Salvador <osalvador@suse.com>,
Michal Hocko <mhocko@suse.com>,
Pavel Tatashin <pasha.tatashin@soleen.com>,
Wei Yang <richard.weiyang@gmail.com>,
Juergen Gross <jgross@suse.com>, Qian Cai <cai@lca.pw>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@kernel.org>,
Josh Poimboeuf <jpoimboe@redhat.com>,
Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>,
Jiri Kosina <jkosina@suse.cz>,
Peter Zijlstra <peterz@infradead.org>,
Mukesh Ojha <mojha@codeaurora.org>,
Arun KS <arunks@codeaurora.org>,
Mike Rapoport <rppt@linux.vnet.ibm.com>,
Baoquan He <bhe@redhat.com>,
Logan Gunthorpe <logang@deltatee.com>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/5] mm: don't hide potentially null memmap pointer in sparse_remove_one_section
Date: Mon, 17 Jun 2019 09:26:07 +0200 [thread overview]
Message-ID: <e3dd8031-2091-4d65-7c76-0ec7283f92f5@redhat.com> (raw)
In-Reply-To: <20190617043635.13201-3-alastair@au1.ibm.com>
On 17.06.19 06:36, Alastair D'Silva wrote:
> From: Alastair D'Silva <alastair@d-silva.org>
>
> By adding offset to memmap before passing it in to clear_hwpoisoned_pages,
> is hides a potentially null memmap from the null check inside
> clear_hwpoisoned_pages.
>
> This patch passes the offset to clear_hwpoisoned_pages instead, allowing
> memmap to successfully peform it's null check.
>
> Signed-off-by: Alastair D'Silva <alastair@d-silva.org>
> ---
> mm/sparse.c | 12 +++++++-----
> 1 file changed, 7 insertions(+), 5 deletions(-)
>
> diff --git a/mm/sparse.c b/mm/sparse.c
> index 104a79fedd00..66a99da9b11b 100644
> --- a/mm/sparse.c
> +++ b/mm/sparse.c
> @@ -746,12 +746,14 @@ int __meminit sparse_add_one_section(int nid, unsigned long start_pfn,
> kfree(usemap);
> __kfree_section_memmap(memmap, altmap);
> }
> +
> return ret;
> }
>
> #ifdef CONFIG_MEMORY_HOTREMOVE
> #ifdef CONFIG_MEMORY_FAILURE
> -static void clear_hwpoisoned_pages(struct page *memmap, int nr_pages)
> +static void clear_hwpoisoned_pages(struct page *memmap,
> + unsigned long map_offset, int nr_pages)
> {
> int i;
>
> @@ -767,7 +769,7 @@ static void clear_hwpoisoned_pages(struct page *memmap, int nr_pages)
> if (atomic_long_read(&num_poisoned_pages) == 0)
> return;
>
> - for (i = 0; i < nr_pages; i++) {
> + for (i = map_offset; i < nr_pages; i++) {
> if (PageHWPoison(&memmap[i])) {
> atomic_long_sub(1, &num_poisoned_pages);
> ClearPageHWPoison(&memmap[i]);
> @@ -775,7 +777,8 @@ static void clear_hwpoisoned_pages(struct page *memmap, int nr_pages)
> }
> }
> #else
> -static inline void clear_hwpoisoned_pages(struct page *memmap, int nr_pages)
> +static inline void clear_hwpoisoned_pages(struct page *memmap,
> + unsigned long map_offset, int nr_pages)
I somewhat dislike that map_offset modifies nr_pages internally.
I would prefer decoupling both and passing the actual number of pages to
clear instead:
clear_hwpoisoned_pages(memmap, map_offset,
PAGES_PER_SECTION - map_offset);
> {
> }
> #endif
> @@ -822,8 +825,7 @@ void sparse_remove_one_section(struct zone *zone, struct mem_section *ms,
> ms->pageblock_flags = NULL;
> }
>
> - clear_hwpoisoned_pages(memmap + map_offset,
> - PAGES_PER_SECTION - map_offset);
> + clear_hwpoisoned_pages(memmap, map_offset, PAGES_PER_SECTION);
> free_section_usemap(memmap, usemap, altmap);
> }
> #endif /* CONFIG_MEMORY_HOTREMOVE */
>
--
Thanks,
David / dhildenb
next prev parent reply other threads:[~2019-06-17 7:26 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-17 4:36 [PATCH 0/5] mm: Cleanup & allow modules to hotplug memory Alastair D'Silva
2019-06-17 4:36 ` [PATCH 1/5] mm: Trigger bug on if a section is not found in __section_nr Alastair D'Silva
2019-06-17 6:46 ` Mike Rapoport
2019-06-17 4:36 ` [PATCH 2/5] mm: don't hide potentially null memmap pointer in sparse_remove_one_section Alastair D'Silva
2019-06-17 6:49 ` Mike Rapoport
2019-06-17 7:26 ` David Hildenbrand [this message]
2019-06-17 4:36 ` [PATCH 3/5] mm: Don't manually decrement num_poisoned_pages Alastair D'Silva
2019-06-17 6:52 ` Mike Rapoport
2019-06-17 7:17 ` David Hildenbrand
2019-06-17 4:36 ` [PATCH 4/5] mm/hotplug: Avoid RCU stalls when removing large amounts of memory Alastair D'Silva
2019-06-17 6:53 ` Mike Rapoport
2019-06-17 6:58 ` Alastair D'Silva
2019-06-17 7:47 ` Michal Hocko
2019-06-17 7:57 ` Alastair D'Silva
2019-06-17 8:21 ` Michal Hocko
2019-06-17 15:49 ` Oscar Salvador
2019-06-17 4:36 ` [PATCH 5/5] mm/hotplug: export try_online_node Alastair D'Silva
2019-06-17 6:59 ` Peter Zijlstra
2019-06-17 7:05 ` Alastair D'Silva
2019-06-17 7:15 ` Christoph Hellwig
2019-06-17 8:00 ` Alastair D'Silva
2019-06-17 13:14 ` 'Christoph Hellwig'
2019-06-17 7:16 ` Michal Hocko
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=e3dd8031-2091-4d65-7c76-0ec7283f92f5@redhat.com \
--to=david@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=alastair@au1.ibm.com \
--cc=alastair@d-silva.org \
--cc=arunks@codeaurora.org \
--cc=bhe@redhat.com \
--cc=cai@lca.pw \
--cc=jgross@suse.com \
--cc=jkosina@suse.cz \
--cc=jpoimboe@redhat.com \
--cc=konrad.wilk@oracle.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=logang@deltatee.com \
--cc=mhocko@suse.com \
--cc=mingo@kernel.org \
--cc=mojha@codeaurora.org \
--cc=osalvador@suse.com \
--cc=pasha.tatashin@soleen.com \
--cc=peterz@infradead.org \
--cc=richard.weiyang@gmail.com \
--cc=rppt@linux.vnet.ibm.com \
--cc=tglx@linutronix.de \
/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: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox