Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1424963
| From | "Kirill A. Shutemov" <kirill@shutemov.name> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCHv9-rebased2 28/37] shmem: get_unmapped_area align huge page |
| Date | 2016-06-17 13:40 +0200 |
| Message-ID | <rL0hX-5Wp-9@gated-at.bofh.it> (permalink) |
| References | <rKX0K-3ZY-29@gated-at.bofh.it> <rKX0K-3ZY-27@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On Fri, Jun 17, 2016 at 04:06:33PM +0800, Hillf Danton wrote:
> >
> > +unsigned long shmem_get_unmapped_area(struct file *file,
> > + unsigned long uaddr, unsigned long len,
> > + unsigned long pgoff, unsigned long flags)
> > +{
> > + unsigned long (*get_area)(struct file *,
> > + unsigned long, unsigned long, unsigned long, unsigned long);
> > + unsigned long addr;
> > + unsigned long offset;
> > + unsigned long inflated_len;
> > + unsigned long inflated_addr;
> > + unsigned long inflated_offset;
> > +
> > + if (len > TASK_SIZE)
> > + return -ENOMEM;
> > +
> > + get_area = current->mm->get_unmapped_area;
> > + addr = get_area(file, uaddr, len, pgoff, flags);
> > +
> > + if (!IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE))
> > + return addr;
> > + if (IS_ERR_VALUE(addr))
> > + return addr;
> > + if (addr & ~PAGE_MASK)
> > + return addr;
> > + if (addr > TASK_SIZE - len)
> > + return addr;
> > +
> > + if (shmem_huge == SHMEM_HUGE_DENY)
> > + return addr;
> > + if (len < HPAGE_PMD_SIZE)
> > + return addr;
> > + if (flags & MAP_FIXED)
> > + return addr;
> > + /*
> > + * Our priority is to support MAP_SHARED mapped hugely;
> > + * and support MAP_PRIVATE mapped hugely too, until it is COWed.
> > + * But if caller specified an address hint, respect that as before.
> > + */
> > + if (uaddr)
> > + return addr;
> > +
> > + if (shmem_huge != SHMEM_HUGE_FORCE) {
> > + struct super_block *sb;
> > +
> > + if (file) {
> > + VM_BUG_ON(file->f_op != &shmem_file_operations);
> > + sb = file_inode(file)->i_sb;
> > + } else {
> > + /*
> > + * Called directly from mm/mmap.c, or drivers/char/mem.c
> > + * for "/dev/zero", to create a shared anonymous object.
> > + */
> > + if (IS_ERR(shm_mnt))
> > + return addr;
> > + sb = shm_mnt->mnt_sb;
> > + }
> > + if (SHMEM_SB(sb)->huge != SHMEM_HUGE_NEVER)
> > + return addr;
>
> Try to ask for a larger arena if huge page is not disabled for
> the mount(s/!=/==/)?
<facepalm>
I mostly test with SHMEM_HUGE_FORCE as it puts more stress on the system.
Fixup:
diff --git a/mm/shmem.c b/mm/shmem.c
index e2c6b6e8387a..3f4ebe84ef61 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -1979,7 +1979,7 @@ unsigned long shmem_get_unmapped_area(struct file *file,
return addr;
sb = shm_mnt->mnt_sb;
}
- if (SHMEM_SB(sb)->huge != SHMEM_HUGE_NEVER)
+ if (SHMEM_SB(sb)->huge == SHMEM_HUGE_NEVER)
return addr;
}
--
Kirill A. Shutemov
Back to linux.kernel | Previous | Next — Previous in thread | Find similar | Unroll thread
Re: [PATCHv9-rebased2 28/37] shmem: get_unmapped_area align huge page "Hillf Danton" <hillf.zj@alibaba-inc.com> - 2016-06-17 10:10 +0200 Re: [PATCHv9-rebased2 28/37] shmem: get_unmapped_area align huge page "Kirill A. Shutemov" <kirill@shutemov.name> - 2016-06-17 13:40 +0200
csiph-web