From: Song Liu <songliubraving@fb.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: "linux-mm@kvack.org" <linux-mm@kvack.org>,
Kernel Team <Kernel-team@fb.com>,
Yang Shi <yang.shi@linux.alibaba.com>,
"Kirill A . Shutemov" <kirill.shutemov@linux.intel.com>,
Hugh Dickins <hughd@google.com>, Vlastimil Babka <vbabka@suse.cz>,
Rik van Riel <riel@surriel.com>
Subject: Re: [PATCH] mm: thp: passing correct vm_flags to hugepage_vma_check
Date: Sun, 1 Jul 2018 06:31:36 +0000 [thread overview]
Message-ID: <F6855BF6-20DE-4AC8-8DA8-116F1AF52DBE@fb.com> (raw)
In-Reply-To: <20180629192503.b41ce9e68d5c267595677a0d@linux-foundation.org>
> On Jun 29, 2018, at 7:25 PM, Andrew Morton <akpm@linux-foundation.org> wrote:
>
> On Fri, 29 Jun 2018 11:17:52 -0700 Song Liu <songliubraving@fb.com> wrote:
>
>> Back in May, I sent patch similar to 02b75dc8160d:
>>
>> https://patchwork.kernel.org/patch/10416233/ (v1)
>>
>> This patch got positive feedback. However, I realized there is a problem,
>> that vma->vm_flags in khugepaged_enter_vma_merge() is stale. The separate
>> argument vm_flags contains the latest value. Therefore, it is
>> necessary to pass this vm_flags into hugepage_vma_check(). To fix this
>> problem, I resent v2 and v3 of the work:
>>
>> https://patchwork.kernel.org/patch/10419527/ (v2)
>> https://patchwork.kernel.org/patch/10433937/ (v3)
>>
>> To my surprise, after I thought we all agreed on v3 of the work. Yang's
>> patch, which is similar to correct looking (but wrong) v1, got applied.
>> So we still have the issue of stale vma->vm_flags. This patch fixes this
>> issue. Please apply.
>
> That's a ueful history lesson but most of it isn't relevant to this
> change. So I'd suggest this changelog:
>
> : khugepaged_enter_vma_merge() passes a stale vma->vm_flags to
> : hugepage_vma_check(). The argument vm_flags contains the latest value.
> : Therefore, it is necessary to pass this vm_flags into
> : hugepage_vma_check().
This looks good. Thanks!
> Also, please (as always) tell us the user-visible runtime effects of
> this bug so that others can decide which kernel(s) need the fix?
With this bug, madvise(MADV_HUGEPAGE) for mmap files in shmem fails to
put memory in huge pages. Here is an example of failed madvise():
/* mount /dev/shm with huge=advise:
* mount -o remount,huge=advise /dev/shm */
/* create file /dev/shm/huge */
#define HUGE_FILE "/dev/shm/huge"
fd = open(HUGE_FILE, O_RDONLY);
ptr = mmap(NULL, FILE_SIZE, PROT_READ, MAP_PRIVATE, fd, 0);
ret = madvise(ptr, FILE_SIZE, MADV_HUGEPAGE);
madvise() will return 0, but this memory region is never put in huge
page (check from /proc/meminfo: ShmemHugePages).
Thanks,
Song
prev parent reply other threads:[~2018-07-01 6:46 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-29 18:17 Song Liu
2018-06-29 18:26 ` Rik van Riel
2018-06-29 19:05 ` Yang Shi
2018-06-30 2:25 ` Andrew Morton
2018-07-01 6:31 ` Song Liu [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=F6855BF6-20DE-4AC8-8DA8-116F1AF52DBE@fb.com \
--to=songliubraving@fb.com \
--cc=Kernel-team@fb.com \
--cc=akpm@linux-foundation.org \
--cc=hughd@google.com \
--cc=kirill.shutemov@linux.intel.com \
--cc=linux-mm@kvack.org \
--cc=riel@surriel.com \
--cc=vbabka@suse.cz \
--cc=yang.shi@linux.alibaba.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