History

mm,hugetlb: remove mlock ulimit for SHM_HUGETLB

Commit 21a3c273f88c ("mm, hugetlb: add thread name and pid to SHM_HUGETLB mlock rlimit warning") marked this as deprecated in 2012, but it is not deleted yet. Mike says he still sees that message in log files on occasion, so maybe we should preserve this warning. Also remove hugetlbfs related user_shm_unlock in ipc/shm.c and remove the user_shm_unlock after out.

zhangyiru committed 5 years ago

Commit 83c1fd71 parent 51b8c1f5 files · +13 −31Browse files

Unified · Split

5 files
  1. fs/hugetlbfs/inode.c +8 −15
  2. include/linux/hugetlb.h +2 −4
  3. ipc/shm.c +1 −7
  4. mm/memfd.c +1 −3
  5. mm/mmap.c +1 −2
fs/hugetlbfs/inode.c+8−15
@@ -1446,8 +1446,8 @@ static int get_hstate_idx(int page_size_log) · 1445 unmodified lines
14461446 * otherwise hugetlb_reserve_pages reserves one less hugepages than intended.
14471447 */
14481448 struct file *hugetlb_file_setup(const char *name, size_t size,
1449− vm_flags_t acctflag, struct ucounts **ucounts,
1450− int creat_flags, int page_size_log)
1449+ vm_flags_t acctflag, int creat_flags,
1450+ int page_size_log)
14511451 {
14521452 struct inode *inode;
14531453 struct vfsmount *mnt;
@@ -1458,22 +1458,19 @@ struct file *hugetlb_file_setup(const char *name, size_t size, · 4 unmodified lines
14581458 if (hstate_idx < 0)
14591459 return ERR_PTR(-ENODEV);
14601460
1461− *ucounts = NULL;
14621461 mnt = hugetlbfs_vfsmount[hstate_idx];
14631462 if (!mnt)
14641463 return ERR_PTR(-ENOENT);
14651464
14661465 if (creat_flags == HUGETLB_SHMFS_INODE && !can_do_hugetlb_shm()) {
1467− *ucounts = current_ucounts();
1468− if (user_shm_lock(size, *ucounts)) {
1469− task_lock(current);
1470− pr_warn_once("%s (%d): Using mlock ulimits for SHM_HUGETLB is deprecated\n",
1466+ struct ucounts *ucounts = current_ucounts();
1467+
1468+ if (user_shm_lock(size, ucounts)) {
1469+ pr_warn_once("%s (%d): Using mlock ulimits for SHM_HUGETLB is obsolete\n",
14711470 current->comm, current->pid);
1472− task_unlock(current);
1473− } else {
1474− *ucounts = NULL;
1475− return ERR_PTR(-EPERM);
1471+ user_shm_unlock(size, ucounts);
14761472 }
1473+ return ERR_PTR(-EPERM);
14771474 }
14781475
14791476 file = ERR_PTR(-ENOSPC);
@@ -1498,10 +1495,6 @@ struct file *hugetlb_file_setup(const char *name, size_t size, · 18 unmodified lines
14981495
14991496 iput(inode);
15001497 out:
1501− if (*ucounts) {
1502− user_shm_unlock(size, *ucounts);
1503− *ucounts = NULL;
1504− }
15051498 return file;
15061499 }
15071500
include/linux/hugetlb.h+2−4
@@ -477,8 +477,7 @@ static inline struct hugetlbfs_inode_info *HUGETLBFS_I(struct inode *inode) · 476 unmodified lines
477477 extern const struct file_operations hugetlbfs_file_operations;
478478 extern const struct vm_operations_struct hugetlb_vm_ops;
479479 struct file *hugetlb_file_setup(const char *name, size_t size, vm_flags_t acct,
480− struct ucounts **ucounts, int creat_flags,
481− int page_size_log);
480+ int creat_flags, int page_size_log);
482481
483482 static inline bool is_file_hugepages(struct file *file)
484483 {
@@ -497,8 +496,7 @@ static inline struct hstate *hstate_inode(struct inode *i) · 12 unmodified lines
497496 #define is_file_hugepages(file) false
498497 static inline struct file *
499498 hugetlb_file_setup(const char *name, size_t size, vm_flags_t acctflag,
500− struct ucounts **ucounts, int creat_flags,
501− int page_size_log)
499+ int creat_flags, int page_size_log)
502500 {
503501 return ERR_PTR(-ENOSYS);
504502 }
ipc/shm.c+1−7
@@ -287,9 +287,6 @@ static void shm_destroy(struct ipc_namespace *ns, struct shmid_kernel *shp) · 286 unmodified lines
287287 shm_unlock(shp);
288288 if (!is_file_hugepages(shm_file))
289289 shmem_lock(shm_file, 0, shp->mlock_ucounts);
290− else if (shp->mlock_ucounts)
291− user_shm_unlock(i_size_read(file_inode(shm_file)),
292− shp->mlock_ucounts);
293290 fput(shm_file);
294291 ipc_update_pid(&shp->shm_cprid, NULL);
295292 ipc_update_pid(&shp->shm_lprid, NULL);
@@ -650,8 +647,7 @@ static int newseg(struct ipc_namespace *ns, struct ipc_params *params) · 354 unmodified lines
650647 if (shmflg & SHM_NORESERVE)
651648 acctflag = VM_NORESERVE;
652649 file = hugetlb_file_setup(name, hugesize, acctflag,
653− &shp->mlock_ucounts, HUGETLB_SHMFS_INODE,
654− (shmflg >> SHM_HUGE_SHIFT) & SHM_HUGE_MASK);
650+ HUGETLB_SHMFS_INODE, (shmflg >> SHM_HUGE_SHIFT) & SHM_HUGE_MASK);
655651 } else {
656652 /*
657653 * Do not allow no accounting for OVERCOMMIT_NEVER, even
@@ -698,8 +694,6 @@ static int newseg(struct ipc_namespace *ns, struct ipc_params *params) · 40 unmodified lines
698694 no_id:
699695 ipc_update_pid(&shp->shm_cprid, NULL);
700696 ipc_update_pid(&shp->shm_lprid, NULL);
701− if (is_file_hugepages(file) && shp->mlock_ucounts)
702− user_shm_unlock(size, shp->mlock_ucounts);
703697 fput(file);
704698 ipc_rcu_putref(&shp->shm_perm, shm_rcu_free);
705699 return error;
mm/memfd.c+1−3
@@ -297,9 +297,7 @@ SYSCALL_DEFINE2(memfd_create, · 296 unmodified lines
297297 }
298298
299299 if (flags & MFD_HUGETLB) {
300− struct ucounts *ucounts = NULL;
301−
302− file = hugetlb_file_setup(name, 0, VM_NORESERVE, &ucounts,
300+ file = hugetlb_file_setup(name, 0, VM_NORESERVE,
303301 HUGETLB_ANONHUGE_INODE,
304302 (flags >> MFD_HUGE_SHIFT) &
305303 MFD_HUGE_MASK);
mm/mmap.c+1−2
@@ -1599,7 +1599,6 @@ unsigned long ksys_mmap_pgoff(unsigned long addr, unsigned long len, · 1598 unmodified lines
15991599 goto out_fput;
16001600 }
16011601 } else if (flags & MAP_HUGETLB) {
1602− struct ucounts *ucounts = NULL;
16031602 struct hstate *hs;
16041603
16051604 hs = hstate_sizelog((flags >> MAP_HUGE_SHIFT) & MAP_HUGE_MASK);
@@ -1615,7 +1614,7 @@ unsigned long ksys_mmap_pgoff(unsigned long addr, unsigned long len, · 9 unmodified lines
16151614 */
16161615 file = hugetlb_file_setup(HUGETLB_ANON_FILE, len,
16171616 VM_NORESERVE,
1618− &ucounts, HUGETLB_ANONHUGE_INODE,
1617+ HUGETLB_ANONHUGE_INODE,
16191618 (flags >> MAP_HUGE_SHIFT) & MAP_HUGE_MASK);
16201619 if (IS_ERR(file))
16211620 return PTR_ERR(file);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t