On Tue, Apr 04, 2017 at 11:11:27PM +0100, Matthew Auld wrote: > In its current form huge-pages through shmemfs are controlled at the > super-block level, and are currently disabled by default, so to enable > huge-pages for a shmem backed gem object we would need to re-mount the > fs with the huge= argument, but for drm the mount is not user visible, > so good luck with that. The other option is the global sysfs knob > shmem_enabled which exposes the same huge= options, with the addition of > DENY and FORCE. > > Neither option seems really workable, what we probably want is to able > to control the use of huge-pages at the time of pinning the backing > storage for a particular gem object, and only where it makes sense given > the size of the object. One caveat is when we write into the page cache > prior to pinning the backing storage. I played around with a bunch of > ideas but in the end just settled with driver overridable huge option > embedded in shmem_inode_info. Thoughts? > > Signed-off-by: Matthew Auld <matthew.auld@xxxxxxxxx> You need to Cc: mm folks and mailing lists for this. Ask scripts/get_maintainers.pl for the full list please. Otherwise this can't ever land (and we're looking at along time of bikeshedding anyway). -Daniel > --- > include/linux/shmem_fs.h | 1 + > mm/shmem.c | 10 ++++++++-- > 2 files changed, 9 insertions(+), 2 deletions(-) > > diff --git a/include/linux/shmem_fs.h b/include/linux/shmem_fs.h > index a7d6bd2a918f..001be751420d 100644 > --- a/include/linux/shmem_fs.h > +++ b/include/linux/shmem_fs.h > @@ -21,6 +21,7 @@ struct shmem_inode_info { > struct shared_policy policy; /* NUMA memory alloc policy */ > struct simple_xattrs xattrs; /* list of xattrs */ > struct inode vfs_inode; > + bool huge; /* driver override shmem_huge */ > }; > > struct shmem_sb_info { > diff --git a/mm/shmem.c b/mm/shmem.c > index e67d6ba4e98e..879a9e514afe 100644 > --- a/mm/shmem.c > +++ b/mm/shmem.c > @@ -1723,6 +1723,9 @@ static int shmem_getpage_gfp(struct inode *inode, pgoff_t index, > /* shmem_symlink() */ > if (mapping->a_ops != &shmem_aops) > goto alloc_nohuge; > + /* driver override shmem_huge */ > + if (info->huge) > + goto alloc_huge; > if (shmem_huge == SHMEM_HUGE_DENY || sgp_huge == SGP_NOHUGE) > goto alloc_nohuge; > if (shmem_huge == SHMEM_HUGE_FORCE) > @@ -2000,6 +2003,7 @@ unsigned long shmem_get_unmapped_area(struct file *file, > unsigned long inflated_len; > unsigned long inflated_addr; > unsigned long inflated_offset; > + struct shmem_inode_info *info = SHMEM_I(file_inode(file)); > > if (len > TASK_SIZE) > return -ENOMEM; > @@ -2016,7 +2020,7 @@ unsigned long shmem_get_unmapped_area(struct file *file, > if (addr > TASK_SIZE - len) > return addr; > > - if (shmem_huge == SHMEM_HUGE_DENY) > + if (!info->huge && shmem_huge == SHMEM_HUGE_DENY) > return addr; > if (len < HPAGE_PMD_SIZE) > return addr; > @@ -2030,7 +2034,7 @@ unsigned long shmem_get_unmapped_area(struct file *file, > if (uaddr) > return addr; > > - if (shmem_huge != SHMEM_HUGE_FORCE) { > + if (!info->huge && shmem_huge != SHMEM_HUGE_FORCE) { > struct super_block *sb; > > if (file) { > @@ -4034,6 +4038,8 @@ bool shmem_huge_enabled(struct vm_area_struct *vma) > loff_t i_size; > pgoff_t off; > > + if (SHMEM_I(inode)->huge) > + return true; > if (shmem_huge == SHMEM_HUGE_FORCE) > return true; > if (shmem_huge == SHMEM_HUGE_DENY) > -- > 2.9.3 > > _______________________________________________ > Intel-gfx mailing list > Intel-gfx@xxxxxxxxxxxxxxxxxxxxx > https://lists.freedesktop.org/mailman/listinfo/intel-gfx -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list Intel-gfx@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/intel-gfx