From: Muchun Song <songmuchun@bytedance.com>
To: Michal Hocko <mhocko@kernel.org>
Cc: mike.kravetz@oracle.com,
Andrew Morton <akpm@linux-foundation.org>,
Linux Memory Management List <linux-mm@kvack.org>,
LKML <linux-kernel@vger.kernel.org>,
Jianchao Guo <guojianchao@bytedance.com>
Subject: Re: [Phishing Risk] [External] Re: [PATCH] mm/hugetlb: add mempolicy check in the reservation routine
Date: Fri, 24 Jul 2020 17:04:28 +0800 [thread overview]
Message-ID: <CAMZfGtWUkW3AViM+vy6ffb44s_vjm0p0aXi=jdLkqKmN9HWJFA@mail.gmail.com> (raw)
In-Reply-To: <20200724073942.GE4061@dhcp22.suse.cz>
On Fri, Jul 24, 2020 at 3:39 PM Michal Hocko <mhocko@kernel.org> wrote:
>
> On Thu 23-07-20 15:44:17, 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
>
> Cpusets and mempolicy interaction has always been a nightmare and
Yeah, I agree with you.
> semantic might get really awkward in some cases. In this case I am not
> really sure anybody really does soemthing like that but anyway...
Someone may like to use numactl to bind memory nodes. So I think
that it is better to add a mempolicy check.
>
> [...]
>
> > -static unsigned int cpuset_mems_nr(unsigned int *array)
> > +static nodemask_t *mempolicy_current_bind_nodemask(void)
> > +{
> > + struct mempolicy *mpol;
> > + nodemask_t *nodemask;
> > +
> > + mpol = get_task_policy(current);
> > + if (mpol->mode == MPOL_BIND)
> > + nodemask = &mpol->v.nodes;
> > + else
> > + nodemask = NULL;
> > +
> > + return nodemask;
> > +}
>
> We already have policy_nodemask which tries to do this. Is there any
> reason to not reuse it?
Yeah, we can reuse it, I didn't know it before. Thanks.
> --
> Michal Hocko
> SUSE Labs
--
Yours,
Muchun
prev parent reply other threads:[~2020-07-24 9:05 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-23 7:44 Muchun Song
2020-07-24 7:39 ` Michal Hocko
2020-07-24 9:04 ` Muchun Song [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='CAMZfGtWUkW3AViM+vy6ffb44s_vjm0p0aXi=jdLkqKmN9HWJFA@mail.gmail.com' \
--to=songmuchun@bytedance.com \
--cc=akpm@linux-foundation.org \
--cc=guojianchao@bytedance.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@kernel.org \
--cc=mike.kravetz@oracle.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