linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Mike Kravetz <mike.kravetz@oracle.com>
To: Muchun Song <songmuchun@bytedance.com>,
	akpm@linux-foundation.org, mhocko@kernel.org
Cc: rientjes@google.com, mgorman@suse.de, walken@google.com,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	Jianchao Guo <guojianchao@bytedance.com>
Subject: Re: [PATCH v3] mm/hugetlb: add mempolicy check in the reservation routine
Date: Mon, 27 Jul 2020 16:09:11 -0700	[thread overview]
Message-ID: <b2dd0138-ed3e-c704-0625-6b6158d5b434@oracle.com> (raw)
In-Reply-To: <20200725080749.70470-1-songmuchun@bytedance.com>

On 7/25/20 1:07 AM, Muchun Song 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>

Thank you Muchun and Michal,

This patch forced me to once again look at the bad the interaction of
hugetlb reservations and cpusets or mempolicy.  This new code will help
produce a quick failure as described in the commit message, and it does
not make existing interactions any worse.

Reviewed-by: Mike Kravetz <mike.kravetz@oracle.com>

-- 
Mike Kravetz


  reply	other threads:[~2020-07-27 23:09 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-25  8:07 [PATCH v3] mm/hugetlb: add mempolicy check in the reservation routine Muchun Song
2020-07-27 23:09 ` Mike Kravetz [this message]
2020-07-28  0:19 ` Andrew Morton
2020-07-28  2:40   ` [External] " Muchun Song
2020-07-28  2:42   ` Mike Kravetz

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=b2dd0138-ed3e-c704-0625-6b6158d5b434@oracle.com \
    --to=mike.kravetz@oracle.com \
    --cc=akpm@linux-foundation.org \
    --cc=guojianchao@bytedance.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mgorman@suse.de \
    --cc=mhocko@kernel.org \
    --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;
as well as URLs for NNTP newsgroup(s).