From: Michal Hocko <mhocko@kernel.org>
To: "C.Wehrmeyer" <c.wehrmeyer@gmx.de>
Cc: Mike Kravetz <mike.kravetz@oracle.com>,
linux-mm@kvack.org, linux-kernel <linux-kernel@vger.kernel.org>,
Andrea Arcangeli <aarcange@redhat.com>,
"Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>,
Vlastimil Babka <vbabka@suse.cz>
Subject: Re: PROBLEM: Remapping hugepages mappings causes kernel to return EINVAL
Date: Mon, 23 Oct 2017 18:13:16 +0200 [thread overview]
Message-ID: <20171023161316.ajrxgd2jzo3u52eu@dhcp22.suse.cz> (raw)
In-Reply-To: <b6cbb960-d0f1-0630-a2a1-e00bab4af0a1@gmx.de>
On Mon 23-10-17 16:00:13, C.Wehrmeyer wrote:
[...]
> > And that is what we have THP for...
>
> Then I might have been using it incorrectly? I've been digging through
> Documentation/vm/transhuge.txt after your initial pointing out, and verified
> that the kernel uses THPs pretty much always, without the usage of madvise:
>
> # cat /sys/kernel/mm/transparent_hugepage/enabled
> [always] madvise never
OK
> And just to be very sure I've added:
>
> if (madvise(buf1,ALLOC_SIZE_1,MADV_HUGEPAGE)) {
> errno_tmp = errno;
> fprintf(stderr,"madvise: %u\n",errno_tmp);
> goto out;
> }
>
> /*Make sure the mapping is actually used*/
> memset(buf1,'!',ALLOC_SIZE_1);
Is the buffer aligned to 2MB?
> /*Give me time for monitoring*/
> sleep(2000);
>
> right after the mmap call. I've also made sure that nothing is being
> optimised away by the compiler. With a 2MiB mapping being requested this
> should be a good opportunity for the kernel, and yet when I try to figure
> out how many THPs my processes uses:
>
> $ cat /proc/21986/smaps | grep 'AnonHuge'
>
> I just end up with lots of:
>
> AnonHugePages: 0 kB
>
> And cat /proc/meminfo | grep 'Huge' doesn't change significantly as well. Am
> I just doing something wrong here, or shouldn't I trust the THP mechanisms
> to actually allocate hugepages for me?
If the mapping is aligned properly then the rest is up to system and
availability of large physically contiguous memory blocks.
> > General purpose allocator playing with hugetlb
> > pages is rather tricky and I would be really cautious there. I would
> > rather play with THP to reduce the TLB footprint.
>
> May one ask why you'd recommend to be cautious here? I understand that
> actual huge pages can slow down certain things - swapping comes to mind
> immediately, which is probably the reason why Linux (used to?) lock such
> pages in memory as well.
THP shouldn't cause any significant slowdown or other issues (these
days). The main reason for the static pre allocated huge pages pool
(hugetlb) was a guarantee of the huge pages availability. Such a
pool has not been reclaimable. This brings an obvious issues, e.g.
unreclaimable huge pages will reduce the amount of usable memory for the
rest of the system so you should really think how much to reserve to not
get into memory short situations. That makes a general purpose hugetlb
pages usage rather challenging.
THP on the other hand can come and go as the system is able to
create/keep them without userspace involvement. You can hint a range by
madvise and the system will try harder to give you THP.
--
Michal Hocko
SUSE Labs
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2017-10-23 16:13 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <93684e4b-9e60-ef3a-ba62-5719fdf7cff9@gmx.de>
2017-10-19 7:34 ` C.Wehrmeyer
2017-10-20 22:42 ` Mike Kravetz
2017-10-23 11:42 ` Michal Hocko
2017-10-23 12:22 ` C.Wehrmeyer
2017-10-23 12:41 ` Michal Hocko
2017-10-23 14:00 ` C.Wehrmeyer
2017-10-23 16:13 ` Michal Hocko [this message]
2017-10-23 16:46 ` C.Wehrmeyer
2017-10-23 16:57 ` Michal Hocko
2017-10-23 17:52 ` C.Wehrmeyer
2017-10-23 18:02 ` Michal Hocko
2017-10-24 7:41 ` C.Wehrmeyer
2017-10-24 8:12 ` Michal Hocko
2017-10-24 8:32 ` C.Wehrmeyer
2017-10-27 14:29 ` Vlastimil Babka
2017-10-27 17:06 ` Mike Kravetz
2017-10-27 17:31 ` Kirill A. Shutemov
2017-10-23 18:51 ` Mike Kravetz
2017-10-24 8:09 ` C.Wehrmeyer
2017-10-07 1:58 C.Wehrmeyer
2017-10-09 16:47 ` 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=20171023161316.ajrxgd2jzo3u52eu@dhcp22.suse.cz \
--to=mhocko@kernel.org \
--cc=aarcange@redhat.com \
--cc=c.wehrmeyer@gmx.de \
--cc=kirill.shutemov@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mike.kravetz@oracle.com \
--cc=vbabka@suse.cz \
/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