From: Mike Kravetz <mike.kravetz@oracle.com>
To: Muchun Song <songmuchun@bytedance.com>
Cc: akpm@linux-foundation.org, duanxiongchun@bytedance.com,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org
Subject: Re: [PATCH] mm: sparsemem: fix missing higher order allocation splitting
Date: Wed, 22 Jun 2022 16:32:09 -0700 [thread overview]
Message-ID: <YrOmeTHagxHQqUxM@monkey> (raw)
In-Reply-To: <20220620023019.94257-1-songmuchun@bytedance.com>
On 06/20/22 10:30, Muchun Song wrote:
> Higher order allocations for vmemmap pages from buddy allocator must be
> able to be treated as indepdenent small pages as they can be freed
> individually by the caller. There is no problem for higher order vmemmap
> pages allocated at boot time since each individual small page will be
> initialized at boot time. However, it will be an issue for memory hotplug
> case since those higher order vmemmap pages are allocated from buddy
> allocator without initializing each individual small page's refcount. The
> system will panic in put_page_testzero() when CONFIG_DEBUG_VM is enabled
> if the vmemmap page is freed.
>
> Fixes: d8d55f5616cf ("mm: sparsemem: use page table lock to protect kernel pmd operations")
> Cc: <stable@vger.kernel.org>
> Signed-off-by: Muchun Song <songmuchun@bytedance.com>
> ---
> mm/sparse-vmemmap.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
Thanks for fixing,
Reviewed-by: Mike Kravetz <mike.kravetz@oracle.com>
--
Mike Kravetz
>
> diff --git a/mm/sparse-vmemmap.c b/mm/sparse-vmemmap.c
> index 652f11a05749..ebb489fcf07c 100644
> --- a/mm/sparse-vmemmap.c
> +++ b/mm/sparse-vmemmap.c
> @@ -78,6 +78,14 @@ static int __split_vmemmap_huge_pmd(pmd_t *pmd, unsigned long start)
>
> spin_lock(&init_mm.page_table_lock);
> if (likely(pmd_leaf(*pmd))) {
> + /*
> + * Higher order allocations from buddy allocator must be able to
> + * be treated as indepdenent small pages (as they can be freed
> + * individually).
> + */
> + if (!PageReserved(page))
> + split_page(page, get_order(PMD_SIZE));
> +
> /* Make pte visible before pmd. See comment in pmd_install(). */
> smp_wmb();
> pmd_populate_kernel(&init_mm, pmd, pgtable);
> --
> 2.11.0
>
prev parent reply other threads:[~2022-06-22 23:32 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-20 2:30 Muchun Song
2022-06-22 23:32 ` Mike Kravetz [this message]
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=YrOmeTHagxHQqUxM@monkey \
--to=mike.kravetz@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=duanxiongchun@bytedance.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=songmuchun@bytedance.com \
--cc=stable@vger.kernel.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