linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: "HORIGUCHI NAOYA(堀口 直也)" <naoya.horiguchi@nec.com>
To: David Hildenbrand <david@redhat.com>
Cc: Naoya Horiguchi <naoya.horiguchi@linux.dev>,
	"linux-mm@kvack.org" <linux-mm@kvack.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Muchun Song <songmuchun@bytedance.com>,
	Miaohe Lin <linmiaohe@huawei.com>,
	Matthew Wilcox <willy@infradead.org>,
	Michal Hocko <mhocko@suse.com>, Yang Shi <shy828301@gmail.com>
Subject: Re: [PATCH] mm/huge_memory: use pfn_to_online_page() in split_huge_pages_all()
Date: Thu, 8 Sep 2022 02:39:38 +0000	[thread overview]
Message-ID: <20220908023936.GA1491221@hori.linux.bs1.fc.nec.co.jp> (raw)
In-Reply-To: <3896f675-7bd1-91e5-160e-a40cce06c214@redhat.com>

On Wed, Sep 07, 2022 at 02:39:02PM +0200, David Hildenbrand wrote:
> On 07.09.22 14:11, Naoya Horiguchi wrote:
...
> > ---
> >  From 8a5c284df732943065d23838090d15c94cd10395 Mon Sep 17 00:00:00 2001
> > From: Naoya Horiguchi <naoya.horiguchi@nec.com>
> > Date: Wed, 7 Sep 2022 20:58:44 +0900
> > Subject: [PATCH] mm/huge_memory: use pfn_to_online_page() in
> >   split_huge_pages_all()
> > 
> > NULL pointer dereference is triggered when calling thp split via debugfs
> > on the system with offlined memory blocks.  With debug option enabled,
> > the following kernel messages are printed out:
> > 
> >    page:00000000467f4890 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x121c000
> >    flags: 0x17fffc00000000(node=0|zone=2|lastcpupid=0x1ffff)
> >    raw: 0017fffc00000000 0000000000000000 dead000000000122 0000000000000000
> >    raw: 0000000000000000 0000000000000000 00000001ffffffff 0000000000000000
> >    page dumped because: unmovable page
> >    page:000000007d7ab72e is uninitialized and poisoned
> >    page dumped because: VM_BUG_ON_PAGE(PagePoisoned(p))
> >    ------------[ cut here ]------------
> >    kernel BUG at include/linux/mm.h:1248!
> >    invalid opcode: 0000 [#1] PREEMPT SMP PTI
> >    CPU: 16 PID: 20964 Comm: bash Tainted: G          I        6.0.0-rc3-foll-numa+ #41
> >    ...
> >    RIP: 0010:split_huge_pages_write+0xcf4/0xe30
> > 
> > This shows that page_to_nid() in page_zone() is unexpectedly called for an
> > offlined memmap.
> > 
> > Use pfn_to_online_page() to get struct page in PFN walker.
> > 
> > Fixes: 49071d436b51 ("thp: add debugfs handle to split all huge pages")
> > Suggested-by: David Hildenbrand <david@redhat.com>
> 
> Feel free to use
> 
> Co-developed-by: David Hildenbrand <david@redhat.com>
> Signed-off-by: David Hildenbrand <david@redhat.com>

Sure, I'll add these.

> instead
> 
> > Signed-off-by: Naoya Horiguchi <naoya.horiguchi@nec.com>
> > Cc: <stable@vger.kernel.org>
> > ---
> >   mm/huge_memory.c | 7 ++-----
> >   1 file changed, 2 insertions(+), 5 deletions(-)
> > 
> > diff --git a/mm/huge_memory.c b/mm/huge_memory.c
> > index 5fa2ba86dae4..03149a8f46f9 100644
> > --- a/mm/huge_memory.c
> > +++ b/mm/huge_memory.c
> > @@ -2894,11 +2894,8 @@ static void split_huge_pages_all(void)
> >   		max_zone_pfn = zone_end_pfn(zone);
> >   		for (pfn = zone->zone_start_pfn; pfn < max_zone_pfn; pfn++) {
> >   			int nr_pages;
> 
> Add an empty line here please, while at it.

Added it.

> > -			if (!pfn_valid(pfn))
> > -				continue;
> > -
> > -			page = pfn_to_page(pfn);
> > -			if (!get_page_unless_zero(page))
> > +			page = pfn_to_online_page(pfn);
> > +			if (!page || !get_page_unless_zero(page))
> >   				continue;
> >   			if (zone != page_zone(page))
> 
> Can you send the patch "officially" as well? Thanks

Yes, I'll send this later in the normal patch submission manner.

Thanks,
Naoya Horiguchi

  reply	other threads:[~2022-09-08  2:39 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-07 10:08 [BUG report] kernel NULL pointer dereference in split_huge_page with offlined memory block Naoya Horiguchi
2022-09-07 10:23 ` David Hildenbrand
2022-09-07 10:26   ` David Hildenbrand
2022-09-07 12:11     ` [PATCH] mm/huge_memory: use pfn_to_online_page() in split_huge_pages_all() Naoya Horiguchi
2022-09-07 12:39       ` David Hildenbrand
2022-09-08  2:39         ` HORIGUCHI NAOYA(堀口 直也) [this message]
2022-09-07 17:10       ` Yang Shi
2022-09-07 17:32       ` Michal Hocko
2022-09-07 20:57       ` Andrew Morton
2022-09-08  2:47         ` HORIGUCHI NAOYA(堀口 直也)
2022-09-08  6:14           ` David Hildenbrand
2022-09-08  6:31             ` HORIGUCHI NAOYA(堀口 直也)
2022-09-08  2:19       ` Miaohe Lin
2022-09-08  3:06         ` HORIGUCHI NAOYA(堀口 直也)
2022-09-08  3:25           ` Miaohe Lin
2022-09-08  7:07             ` Michal Hocko
2022-09-09  0:27               ` Miaohe Lin
2022-09-09  9:03                 ` David Hildenbrand
2022-09-08  3:28       ` Oscar Salvador

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=20220908023936.GA1491221@hori.linux.bs1.fc.nec.co.jp \
    --to=naoya.horiguchi@nec.com \
    --cc=akpm@linux-foundation.org \
    --cc=david@redhat.com \
    --cc=linmiaohe@huawei.com \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@suse.com \
    --cc=naoya.horiguchi@linux.dev \
    --cc=shy828301@gmail.com \
    --cc=songmuchun@bytedance.com \
    --cc=willy@infradead.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: 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;
as well as URLs for NNTP newsgroup(s).