From: Andrew Morton <akpm@linux-foundation.org>
To: Muchun Song <songmuchun@bytedance.com>
Cc: mike.kravetz@oracle.com, David Rientjes <rientjes@google.com>,
mgorman@suse.de, Michel Lespinasse <walken@google.com>,
Linux Memory Management List <linux-mm@kvack.org>,
Michal Hocko <mhocko@kernel.org>,
LKML <linux-kernel@vger.kernel.org>, Baoquan He <bhe@redhat.com>
Subject: Re: [PATCH v4] mm/hugetlb: add mempolicy check in the reservation routine
Date: Thu, 6 Aug 2020 18:22:56 -0700 [thread overview]
Message-ID: <20200806182256.7aab51726cd91301d53cff2d@linux-foundation.org> (raw)
In-Reply-To: <CAMZfGtVE4BJppEHrh=+E4+mo+K5Q9M5q+oBv64q_94x0YyGpqA@mail.gmail.com>
On Thu, 6 Aug 2020 15:45:14 +0800 Muchun Song <songmuchun@bytedance.com> wrote:
> On Tue, Jul 28, 2020 at 11:49 AM Muchun Song <songmuchun@bytedance.com> wrote:
> >
> > In the reservation routine, we only check whether the cpuset meets
> > the memory allocation requirements. But we ignore the mempolicy of
> > MPOL_BIND case. If someone mmap hugetlb succeeds, but the subsequent
> > memory allocation may fail due to mempolicy restrictions and receives
> > the SIGBUS signal. This can be reproduced by the follow steps.
> >
> > 1) Compile the test case.
> > cd tools/testing/selftests/vm/
> > gcc map_hugetlb.c -o map_hugetlb
> >
> > 2) Pre-allocate huge pages. Suppose there are 2 numa nodes in the
> > system. Each node will pre-allocate one huge page.
> > echo 2 > /proc/sys/vm/nr_hugepages
> >
> > 3) Run test case(mmap 4MB). We receive the SIGBUS signal.
> > numactl --membind=0 ./map_hugetlb 4
> >
> > With this patch applied, the mmap will fail in the step 3) and throw
> > "mmap: Cannot allocate memory".
> >
> > Signed-off-by: Muchun Song <songmuchun@bytedance.com>
> > Reported-by: Jianchao Guo <guojianchao@bytedance.com>
> > Suggested-by: Michal Hocko <mhocko@kernel.org>
> > Reviewed-by: Mike Kravetz <mike.kravetz@oracle.com>
>
> Hi Andrew,
>
> Any comments or forgot to add this to the queue for the
> merge window?
I think Baoquan He's comment threw me off.
I worry about the use of `current' in mempolicy.h. It's the first time
this header has referenced current and the patch forgot to include
sched.h to get the definition. Presumably it works by accident. I
could toss in the #include but sometimes that blows up.
But it's unlikely that we'll be getting circular includes or other such
nastiness between those two header files, so fingers crossed...
--- a/include/linux/mempolicy.h~mm-hugetlb-add-mempolicy-check-in-the-reservation-routine-fix
+++ a/include/linux/mempolicy.h
@@ -6,7 +6,7 @@
#ifndef _LINUX_MEMPOLICY_H
#define _LINUX_MEMPOLICY_H 1
-
+#include <linux/sched.h>
#include <linux/mmzone.h>
#include <linux/dax.h>
#include <linux/slab.h>
_
prev parent reply other threads:[~2020-08-07 1:23 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-28 3:49 Muchun Song
2020-07-28 13:24 ` Baoquan He
2020-07-28 14:16 ` [External] " Muchun Song
2020-07-28 16:46 ` Mike Kravetz
2020-07-29 10:33 ` Baoquan He
2020-08-06 7:45 ` Muchun Song
2020-08-07 1:22 ` Andrew Morton [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=20200806182256.7aab51726cd91301d53cff2d@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=bhe@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mgorman@suse.de \
--cc=mhocko@kernel.org \
--cc=mike.kravetz@oracle.com \
--cc=rientjes@google.com \
--cc=songmuchun@bytedance.com \
--cc=walken@google.com \
/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