Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1365755 > unrolled thread
| Started by | Mike Kravetz <mike.kravetz@oracle.com> |
|---|---|
| First post | 2016-03-29 03:20 +0200 |
| Last post | 2016-03-31 18:50 +0200 |
| Articles | 5 — 3 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
[RFC PATCH 1/2] mm/hugetlbfs: Attempt PUD_SIZE mapping alignment if PMD sharing enabled Mike Kravetz <mike.kravetz@oracle.com> - 2016-03-29 03:20 +0200
Re: [RFC PATCH 1/2] mm/hugetlbfs: Attempt PUD_SIZE mapping alignment if PMD sharing enabled "Hillf Danton" <hillf.zj@alibaba-inc.com> - 2016-03-29 06:00 +0200
Re: [RFC PATCH 1/2] mm/hugetlbfs: Attempt PUD_SIZE mapping alignment if PMD sharing enabled Mike Kravetz <mike.kravetz@oracle.com> - 2016-03-29 18:40 +0200
Re: [RFC PATCH 1/2] mm/hugetlbfs: Attempt PUD_SIZE mapping alignment if PMD sharing enabled Naoya Horiguchi <n-horiguchi@ah.jp.nec.com> - 2016-03-31 04:30 +0200
Re: [RFC PATCH 1/2] mm/hugetlbfs: Attempt PUD_SIZE mapping alignment if PMD sharing enabled Mike Kravetz <mike.kravetz@oracle.com> - 2016-03-31 18:50 +0200
| From | Mike Kravetz <mike.kravetz@oracle.com> |
|---|---|
| Date | 2016-03-29 03:20 +0200 |
| Subject | [RFC PATCH 1/2] mm/hugetlbfs: Attempt PUD_SIZE mapping alignment if PMD sharing enabled |
| Message-ID | <rhQu6-77q-9@gated-at.bofh.it> |
When creating a hugetlb mapping, attempt PUD_SIZE alignment if the
following conditions are met:
- Address passed to mmap or shmat is NULL
- The mapping is flaged as shared
- The mapping is at least PUD_SIZE in length
If a PUD_SIZE aligned mapping can not be created, then fall back to a
huge page size mapping.
Signed-off-by: Mike Kravetz <mike.kravetz@oracle.com>
---
fs/hugetlbfs/inode.c | 29 +++++++++++++++++++++++++++--
1 file changed, 27 insertions(+), 2 deletions(-)
diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index 540ddc9..22b2e38 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -175,6 +175,17 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
struct vm_area_struct *vma;
struct hstate *h = hstate_file(file);
struct vm_unmapped_area_info info;
+ bool pud_size_align = false;
+ unsigned long ret_addr;
+
+ /*
+ * If PMD sharing is enabled, align to PUD_SIZE to facilitate
+ * sharing. Only attempt alignment if no address was passed in,
+ * flags indicate sharing and size is big enough.
+ */
+ if (IS_ENABLED(CONFIG_ARCH_WANT_HUGE_PMD_SHARE) &&
+ !addr && flags & MAP_SHARED && len >= PUD_SIZE)
+ pud_size_align = true;
if (len & ~huge_page_mask(h))
return -EINVAL;
@@ -199,9 +210,23 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
info.length = len;
info.low_limit = TASK_UNMAPPED_BASE;
info.high_limit = TASK_SIZE;
- info.align_mask = PAGE_MASK & ~huge_page_mask(h);
+ if (pud_size_align)
+ info.align_mask = PAGE_MASK & (PUD_SIZE - 1);
+ else
+ info.align_mask = PAGE_MASK & ~huge_page_mask(h);
info.align_offset = 0;
- return vm_unmapped_area(&info);
+ ret_addr = vm_unmapped_area(&info);
+
+ /*
+ * If failed with PUD_SIZE alignment, try again with huge page
+ * size alignment.
+ */
+ if ((ret_addr & ~PAGE_MASK) && pud_size_align) {
+ info.align_mask = PAGE_MASK & ~huge_page_mask(h);
+ ret_addr = vm_unmapped_area(&info);
+ }
+
+ return ret_addr;
}
#endif
--
2.4.3
[toc] | [next] | [standalone]
| From | "Hillf Danton" <hillf.zj@alibaba-inc.com> |
|---|---|
| Date | 2016-03-29 06:00 +0200 |
| Message-ID | <rhSYV-fy-9@gated-at.bofh.it> |
| In reply to | #1365755 |
>
> When creating a hugetlb mapping, attempt PUD_SIZE alignment if the
> following conditions are met:
> - Address passed to mmap or shmat is NULL
> - The mapping is flaged as shared
> - The mapping is at least PUD_SIZE in length
> If a PUD_SIZE aligned mapping can not be created, then fall back to a
> huge page size mapping.
>
> Signed-off-by: Mike Kravetz <mike.kravetz@oracle.com>
> ---
> fs/hugetlbfs/inode.c | 29 +++++++++++++++++++++++++++--
> 1 file changed, 27 insertions(+), 2 deletions(-)
>
> diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
> index 540ddc9..22b2e38 100644
> --- a/fs/hugetlbfs/inode.c
> +++ b/fs/hugetlbfs/inode.c
> @@ -175,6 +175,17 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
> struct vm_area_struct *vma;
> struct hstate *h = hstate_file(file);
> struct vm_unmapped_area_info info;
> + bool pud_size_align = false;
> + unsigned long ret_addr;
> +
> + /*
> + * If PMD sharing is enabled, align to PUD_SIZE to facilitate
> + * sharing. Only attempt alignment if no address was passed in,
> + * flags indicate sharing and size is big enough.
> + */
> + if (IS_ENABLED(CONFIG_ARCH_WANT_HUGE_PMD_SHARE) &&
> + !addr && flags & MAP_SHARED && len >= PUD_SIZE)
> + pud_size_align = true;
>
> if (len & ~huge_page_mask(h))
> return -EINVAL;
> @@ -199,9 +210,23 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
> info.length = len;
> info.low_limit = TASK_UNMAPPED_BASE;
> info.high_limit = TASK_SIZE;
> - info.align_mask = PAGE_MASK & ~huge_page_mask(h);
> + if (pud_size_align)
> + info.align_mask = PAGE_MASK & (PUD_SIZE - 1);
> + else
> + info.align_mask = PAGE_MASK & ~huge_page_mask(h);
> info.align_offset = 0;
> - return vm_unmapped_area(&info);
> + ret_addr = vm_unmapped_area(&info);
> +
> + /*
> + * If failed with PUD_SIZE alignment, try again with huge page
> + * size alignment.
> + */
Can we avoid going another round as long as it is a file with
the PUD page size?
Hillf
> + if ((ret_addr & ~PAGE_MASK) && pud_size_align) {
> + info.align_mask = PAGE_MASK & ~huge_page_mask(h);
> + ret_addr = vm_unmapped_area(&info);
> + }
> +
> + return ret_addr;
> }
> #endif
>
> --
> 2.4.3
[toc] | [prev] | [next] | [standalone]
| From | Mike Kravetz <mike.kravetz@oracle.com> |
|---|---|
| Date | 2016-03-29 18:40 +0200 |
| Subject | Re: [RFC PATCH 1/2] mm/hugetlbfs: Attempt PUD_SIZE mapping alignment if PMD sharing enabled |
| Message-ID | <ri4Qq-sQ-5@gated-at.bofh.it> |
| In reply to | #1365831 |
On 03/28/2016 08:50 PM, Hillf Danton wrote:
>>
>> When creating a hugetlb mapping, attempt PUD_SIZE alignment if the
>> following conditions are met:
>> - Address passed to mmap or shmat is NULL
>> - The mapping is flaged as shared
>> - The mapping is at least PUD_SIZE in length
>> If a PUD_SIZE aligned mapping can not be created, then fall back to a
>> huge page size mapping.
>>
>> Signed-off-by: Mike Kravetz <mike.kravetz@oracle.com>
>> ---
>> fs/hugetlbfs/inode.c | 29 +++++++++++++++++++++++++++--
>> 1 file changed, 27 insertions(+), 2 deletions(-)
>>
>> diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
>> index 540ddc9..22b2e38 100644
>> --- a/fs/hugetlbfs/inode.c
>> +++ b/fs/hugetlbfs/inode.c
>> @@ -175,6 +175,17 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
>> struct vm_area_struct *vma;
>> struct hstate *h = hstate_file(file);
>> struct vm_unmapped_area_info info;
>> + bool pud_size_align = false;
>> + unsigned long ret_addr;
>> +
>> + /*
>> + * If PMD sharing is enabled, align to PUD_SIZE to facilitate
>> + * sharing. Only attempt alignment if no address was passed in,
>> + * flags indicate sharing and size is big enough.
>> + */
>> + if (IS_ENABLED(CONFIG_ARCH_WANT_HUGE_PMD_SHARE) &&
>> + !addr && flags & MAP_SHARED && len >= PUD_SIZE)
>> + pud_size_align = true;
>>
>> if (len & ~huge_page_mask(h))
>> return -EINVAL;
>> @@ -199,9 +210,23 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
>> info.length = len;
>> info.low_limit = TASK_UNMAPPED_BASE;
>> info.high_limit = TASK_SIZE;
>> - info.align_mask = PAGE_MASK & ~huge_page_mask(h);
>> + if (pud_size_align)
>> + info.align_mask = PAGE_MASK & (PUD_SIZE - 1);
>> + else
>> + info.align_mask = PAGE_MASK & ~huge_page_mask(h);
>> info.align_offset = 0;
>> - return vm_unmapped_area(&info);
>> + ret_addr = vm_unmapped_area(&info);
>> +
>> + /*
>> + * If failed with PUD_SIZE alignment, try again with huge page
>> + * size alignment.
>> + */
>
> Can we avoid going another round as long as it is a file with
> the PUD page size?
Yes, that brings up a good point.
Since we only do PMD sharing with PMD_SIZE huge pages, that should be
part of the check as to whether we try PUD_SIZE alignment. The initial
check should be expanded as follows:
if (IS_ENABLED(CONFIG_ARCH_WANT_HUGE_PMD_SHARE) && !addr &&
flags & MAP_SHARED && huge_page_size(h) == PMD_SIZE && len >= PUD_SIZE)
pud_size_align = true;
In that case, pud_size_align remains false and we do not retry.
--
Mike Kravetz
>
> Hillf
>> + if ((ret_addr & ~PAGE_MASK) && pud_size_align) {
>> + info.align_mask = PAGE_MASK & ~huge_page_mask(h);
>> + ret_addr = vm_unmapped_area(&info);
>> + }
>> +
>> + return ret_addr;
>> }
>> #endif
>>
>> --
>> 2.4.3
>
[toc] | [prev] | [next] | [standalone]
| From | Naoya Horiguchi <n-horiguchi@ah.jp.nec.com> |
|---|---|
| Date | 2016-03-31 04:30 +0200 |
| Subject | Re: [RFC PATCH 1/2] mm/hugetlbfs: Attempt PUD_SIZE mapping alignment if PMD sharing enabled |
| Message-ID | <riAwV-6pz-1@gated-at.bofh.it> |
| In reply to | #1365755 |
On Mon, Mar 28, 2016 at 06:12:49PM -0700, Mike Kravetz wrote: > When creating a hugetlb mapping, attempt PUD_SIZE alignment if the > following conditions are met: > - Address passed to mmap or shmat is NULL > - The mapping is flaged as shared > - The mapping is at least PUD_SIZE in length > If a PUD_SIZE aligned mapping can not be created, then fall back to a > huge page size mapping. It would be kinder if the patch description includes why this change. Simply "to facilitate pmd sharing" is helpful for someone who read "git log". > > Signed-off-by: Mike Kravetz <mike.kravetz@oracle.com> > --- > fs/hugetlbfs/inode.c | 29 +++++++++++++++++++++++++++-- > 1 file changed, 27 insertions(+), 2 deletions(-) > > diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c > index 540ddc9..22b2e38 100644 > --- a/fs/hugetlbfs/inode.c > +++ b/fs/hugetlbfs/inode.c > @@ -175,6 +175,17 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr, > struct vm_area_struct *vma; > struct hstate *h = hstate_file(file); > struct vm_unmapped_area_info info; > + bool pud_size_align = false; > + unsigned long ret_addr; > + > + /* > + * If PMD sharing is enabled, align to PUD_SIZE to facilitate > + * sharing. Only attempt alignment if no address was passed in, > + * flags indicate sharing and size is big enough. > + */ > + if (IS_ENABLED(CONFIG_ARCH_WANT_HUGE_PMD_SHARE) && > + !addr && flags & MAP_SHARED && len >= PUD_SIZE) > + pud_size_align = true; This code will have duplicates in the next patch, so how about checking this in a separate check routine? Thanks, Naoya Horiguchi
[toc] | [prev] | [next] | [standalone]
| From | Mike Kravetz <mike.kravetz@oracle.com> |
|---|---|
| Date | 2016-03-31 18:50 +0200 |
| Subject | Re: [RFC PATCH 1/2] mm/hugetlbfs: Attempt PUD_SIZE mapping alignment if PMD sharing enabled |
| Message-ID | <riNXb-7Uj-1@gated-at.bofh.it> |
| In reply to | #1367755 |
On 03/30/2016 07:18 PM, Naoya Horiguchi wrote: > On Mon, Mar 28, 2016 at 06:12:49PM -0700, Mike Kravetz wrote: >> When creating a hugetlb mapping, attempt PUD_SIZE alignment if the >> following conditions are met: >> - Address passed to mmap or shmat is NULL >> - The mapping is flaged as shared >> - The mapping is at least PUD_SIZE in length >> If a PUD_SIZE aligned mapping can not be created, then fall back to a >> huge page size mapping. > > It would be kinder if the patch description includes why this change. > Simply "to facilitate pmd sharing" is helpful for someone who read > "git log". Ok, will do. > >> >> Signed-off-by: Mike Kravetz <mike.kravetz@oracle.com> >> --- >> fs/hugetlbfs/inode.c | 29 +++++++++++++++++++++++++++-- >> 1 file changed, 27 insertions(+), 2 deletions(-) >> >> diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c >> index 540ddc9..22b2e38 100644 >> --- a/fs/hugetlbfs/inode.c >> +++ b/fs/hugetlbfs/inode.c >> @@ -175,6 +175,17 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr, >> struct vm_area_struct *vma; >> struct hstate *h = hstate_file(file); >> struct vm_unmapped_area_info info; >> + bool pud_size_align = false; >> + unsigned long ret_addr; >> + >> + /* >> + * If PMD sharing is enabled, align to PUD_SIZE to facilitate >> + * sharing. Only attempt alignment if no address was passed in, >> + * flags indicate sharing and size is big enough. >> + */ >> + if (IS_ENABLED(CONFIG_ARCH_WANT_HUGE_PMD_SHARE) && >> + !addr && flags & MAP_SHARED && len >= PUD_SIZE) >> + pud_size_align = true; > > This code will have duplicates in the next patch, so how about checking > this in a separate check routine? Good suggestion, thanks -- Mike Kravetz > > Thanks, > Naoya Horiguchi >
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web