mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-31 12:10:52 -04:00
mm: reintroduce and deprecate rlimit based access for SHM_HUGETLB
Allow non root users with sufficient mlock rlimits to be able to allocate hugetlb backed shm for now. Deprecate this though. This is being deprecated because the mlock based rlimit checks for SHM_HUGETLB is not consistent with mmap based huge page allocations. Signed-off-by: Ravikiran Thirumalai <[email protected]> Reviewed-by: Mel Gorman <[email protected]> Cc: William Lee Irwin III <[email protected]> Cc: Adam Litke <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
This commit is contained in:
parent
8a0bdec194
commit
2584e51732
2 changed files with 23 additions and 2 deletions
|
|
@ -949,6 +949,7 @@ static int can_do_hugetlb_shm(void)
|
|||
struct file *hugetlb_file_setup(const char *name, size_t size, int acctflag)
|
||||
{
|
||||
int error = -ENOMEM;
|
||||
int unlock_shm = 0;
|
||||
struct file *file;
|
||||
struct inode *inode;
|
||||
struct dentry *dentry, *root;
|
||||
|
|
@ -958,8 +959,14 @@ struct file *hugetlb_file_setup(const char *name, size_t size, int acctflag)
|
|||
if (!hugetlbfs_vfsmount)
|
||||
return ERR_PTR(-ENOENT);
|
||||
|
||||
if (!can_do_hugetlb_shm())
|
||||
return ERR_PTR(-EPERM);
|
||||
if (!can_do_hugetlb_shm()) {
|
||||
if (user_shm_lock(size, user)) {
|
||||
unlock_shm = 1;
|
||||
WARN_ONCE(1,
|
||||
"Using mlock ulimits for SHM_HUGETLB deprecated\n");
|
||||
} else
|
||||
return ERR_PTR(-EPERM);
|
||||
}
|
||||
|
||||
root = hugetlbfs_vfsmount->mnt_root;
|
||||
quick_string.name = name;
|
||||
|
|
@ -999,6 +1006,8 @@ out_inode:
|
|||
out_dentry:
|
||||
dput(dentry);
|
||||
out_shm_unlock:
|
||||
if (unlock_shm)
|
||||
user_shm_unlock(size, user);
|
||||
return ERR_PTR(error);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue