All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: akpm@linux-foundation.org, hughd@google.com, linux-mm@kvack.org,
	liuzixian4@huawei.com, mhocko@suse.com, mike.kravetz@oracle.com,
	mm-commits@vger.kernel.org, torvalds@linux-foundation.org,
	wuxu.wu@huawei.com, zhangyiru3@huawei.com
Subject: [patch 02/87] mm,hugetlb: remove mlock ulimit for SHM_HUGETLB
Date: Mon, 08 Nov 2021 18:31:27 -0800	[thread overview]
Message-ID: <20211109023127.M0F66RgO7%akpm@linux-foundation.org> (raw)
In-Reply-To: <20211108183057.809e428e841088b657a975ec@linux-foundation.org>

From: zhangyiru <zhangyiru3@huawei.com>
Subject: mm,hugetlb: remove mlock ulimit for SHM_HUGETLB

commit 21a3c273f88c9cbbaf7e ("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.

Link: https://lkml.kernel.org/r/20211103105857.25041-1-zhangyiru3@huawei.com
Signed-off-by: zhangyiru <zhangyiru3@huawei.com>
Reviewed-by: Mike Kravetz <mike.kravetz@oracle.com>
Cc: Hugh Dickins <hughd@google.com>
Cc: Liu Zixian <liuzixian4@huawei.com>
Cc: Michal Hocko <mhocko@suse.com>
Cc: wuxu.wu <wuxu.wu@huawei.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 fs/hugetlbfs/inode.c    |   23 ++++++++---------------
 include/linux/hugetlb.h |    6 ++----
 ipc/shm.c               |    8 +-------
 mm/memfd.c              |    4 +---
 mm/mmap.c               |    3 +--
 5 files changed, 13 insertions(+), 31 deletions(-)

--- a/fs/hugetlbfs/inode.c~mmhugetlb-remove-mlock-ulimit-for-shm_hugetlb
+++ a/fs/hugetlbfs/inode.c
@@ -1446,8 +1446,8 @@ static int get_hstate_idx(int page_size_
  * otherwise hugetlb_reserve_pages reserves one less hugepages than intended.
  */
 struct file *hugetlb_file_setup(const char *name, size_t size,
-				vm_flags_t acctflag, struct ucounts **ucounts,
-				int creat_flags, int page_size_log)
+				vm_flags_t acctflag, int creat_flags,
+				int page_size_log)
 {
 	struct inode *inode;
 	struct vfsmount *mnt;
@@ -1458,22 +1458,19 @@ struct file *hugetlb_file_setup(const ch
 	if (hstate_idx < 0)
 		return ERR_PTR(-ENODEV);
 
-	*ucounts = NULL;
 	mnt = hugetlbfs_vfsmount[hstate_idx];
 	if (!mnt)
 		return ERR_PTR(-ENOENT);
 
 	if (creat_flags == HUGETLB_SHMFS_INODE && !can_do_hugetlb_shm()) {
-		*ucounts = current_ucounts();
-		if (user_shm_lock(size, *ucounts)) {
-			task_lock(current);
-			pr_warn_once("%s (%d): Using mlock ulimits for SHM_HUGETLB is deprecated\n",
+		struct ucounts *ucounts = current_ucounts();
+
+		if (user_shm_lock(size, ucounts)) {
+			pr_warn_once("%s (%d): Using mlock ulimits for SHM_HUGETLB is obsolete\n",
 				current->comm, current->pid);
-			task_unlock(current);
-		} else {
-			*ucounts = NULL;
-			return ERR_PTR(-EPERM);
+			user_shm_unlock(size, ucounts);
 		}
+		return ERR_PTR(-EPERM);
 	}
 
 	file = ERR_PTR(-ENOSPC);
@@ -1498,10 +1495,6 @@ struct file *hugetlb_file_setup(const ch
 
 	iput(inode);
 out:
-	if (*ucounts) {
-		user_shm_unlock(size, *ucounts);
-		*ucounts = NULL;
-	}
 	return file;
 }
 
--- a/include/linux/hugetlb.h~mmhugetlb-remove-mlock-ulimit-for-shm_hugetlb
+++ a/include/linux/hugetlb.h
@@ -477,8 +477,7 @@ static inline struct hugetlbfs_inode_inf
 extern const struct file_operations hugetlbfs_file_operations;
 extern const struct vm_operations_struct hugetlb_vm_ops;
 struct file *hugetlb_file_setup(const char *name, size_t size, vm_flags_t acct,
-				struct ucounts **ucounts, int creat_flags,
-				int page_size_log);
+				int creat_flags, int page_size_log);
 
 static inline bool is_file_hugepages(struct file *file)
 {
@@ -497,8 +496,7 @@ static inline struct hstate *hstate_inod
 #define is_file_hugepages(file)			false
 static inline struct file *
 hugetlb_file_setup(const char *name, size_t size, vm_flags_t acctflag,
-		struct ucounts **ucounts, int creat_flags,
-		int page_size_log)
+		int creat_flags, int page_size_log)
 {
 	return ERR_PTR(-ENOSYS);
 }
--- a/ipc/shm.c~mmhugetlb-remove-mlock-ulimit-for-shm_hugetlb
+++ a/ipc/shm.c
@@ -287,9 +287,6 @@ static void shm_destroy(struct ipc_names
 	shm_unlock(shp);
 	if (!is_file_hugepages(shm_file))
 		shmem_lock(shm_file, 0, shp->mlock_ucounts);
-	else if (shp->mlock_ucounts)
-		user_shm_unlock(i_size_read(file_inode(shm_file)),
-				shp->mlock_ucounts);
 	fput(shm_file);
 	ipc_update_pid(&shp->shm_cprid, NULL);
 	ipc_update_pid(&shp->shm_lprid, NULL);
@@ -650,8 +647,7 @@ static int newseg(struct ipc_namespace *
 		if (shmflg & SHM_NORESERVE)
 			acctflag = VM_NORESERVE;
 		file = hugetlb_file_setup(name, hugesize, acctflag,
-				  &shp->mlock_ucounts, HUGETLB_SHMFS_INODE,
-				(shmflg >> SHM_HUGE_SHIFT) & SHM_HUGE_MASK);
+				HUGETLB_SHMFS_INODE, (shmflg >> SHM_HUGE_SHIFT) & SHM_HUGE_MASK);
 	} else {
 		/*
 		 * Do not allow no accounting for OVERCOMMIT_NEVER, even
@@ -698,8 +694,6 @@ static int newseg(struct ipc_namespace *
 no_id:
 	ipc_update_pid(&shp->shm_cprid, NULL);
 	ipc_update_pid(&shp->shm_lprid, NULL);
-	if (is_file_hugepages(file) && shp->mlock_ucounts)
-		user_shm_unlock(size, shp->mlock_ucounts);
 	fput(file);
 	ipc_rcu_putref(&shp->shm_perm, shm_rcu_free);
 	return error;
--- a/mm/memfd.c~mmhugetlb-remove-mlock-ulimit-for-shm_hugetlb
+++ a/mm/memfd.c
@@ -297,9 +297,7 @@ SYSCALL_DEFINE2(memfd_create,
 	}
 
 	if (flags & MFD_HUGETLB) {
-		struct ucounts *ucounts = NULL;
-
-		file = hugetlb_file_setup(name, 0, VM_NORESERVE, &ucounts,
+		file = hugetlb_file_setup(name, 0, VM_NORESERVE,
 					HUGETLB_ANONHUGE_INODE,
 					(flags >> MFD_HUGE_SHIFT) &
 					MFD_HUGE_MASK);
--- a/mm/mmap.c~mmhugetlb-remove-mlock-ulimit-for-shm_hugetlb
+++ a/mm/mmap.c
@@ -1599,7 +1599,6 @@ unsigned long ksys_mmap_pgoff(unsigned l
 			goto out_fput;
 		}
 	} else if (flags & MAP_HUGETLB) {
-		struct ucounts *ucounts = NULL;
 		struct hstate *hs;
 
 		hs = hstate_sizelog((flags >> MAP_HUGE_SHIFT) & MAP_HUGE_MASK);
@@ -1615,7 +1614,7 @@ unsigned long ksys_mmap_pgoff(unsigned l
 		 */
 		file = hugetlb_file_setup(HUGETLB_ANON_FILE, len,
 				VM_NORESERVE,
-				&ucounts, HUGETLB_ANONHUGE_INODE,
+				HUGETLB_ANONHUGE_INODE,
 				(flags >> MAP_HUGE_SHIFT) & MAP_HUGE_MASK);
 		if (IS_ERR(file))
 			return PTR_ERR(file);
_

  parent reply	other threads:[~2021-11-09  2:31 UTC|newest]

Thread overview: 98+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-09  2:30 incoming Andrew Morton
2021-11-09  2:31 ` [patch 01/87] vfs: keep inodes with page cache off the inode shrinker LRU Andrew Morton
2021-11-09  2:31 ` Andrew Morton [this message]
2021-11-09  2:31 ` [patch 03/87] procfs: do not list TID 0 in /proc/<pid>/task Andrew Morton
2021-11-09  2:31 ` [patch 04/87] x86/xen: update xen_oldmem_pfn_is_ram() documentation Andrew Morton
2021-11-09  2:31 ` [patch 05/87] x86/xen: simplify xen_oldmem_pfn_is_ram() Andrew Morton
2021-11-09  2:31 ` [patch 06/87] x86/xen: print a warning when HVMOP_get_mem_type fails Andrew Morton
2021-11-09  2:31 ` [patch 07/87] proc/vmcore: let pfn_is_ram() return a bool Andrew Morton
2021-11-09  2:31 ` [patch 08/87] proc/vmcore: convert oldmem_pfn_is_ram callback to more generic vmcore callbacks Andrew Morton
2021-11-09  3:59   ` Dave Young
2021-11-09  6:40     ` David Hildenbrand
2021-11-09 10:30       ` Dave Young
2021-11-10  7:22   ` Baoquan He
2021-11-10  8:10     ` David Hildenbrand
2021-11-10 11:11       ` Dave Young
2021-11-10 11:21         ` David Hildenbrand
2021-11-10 11:28           ` Dave Young
2021-11-10 12:05             ` David Hildenbrand
2021-11-10 13:11               ` Dave Young
2021-11-09  2:31 ` [patch 09/87] virtio-mem: factor out hotplug specifics from virtio_mem_init() into virtio_mem_init_hotplug() Andrew Morton
2021-11-09  2:31 ` [patch 10/87] virtio-mem: factor out hotplug specifics from virtio_mem_probe() " Andrew Morton
2021-11-09  2:31 ` [patch 11/87] virtio-mem: factor out hotplug specifics from virtio_mem_remove() into virtio_mem_deinit_hotplug() Andrew Morton
2021-11-09  2:32 ` [patch 12/87] virtio-mem: kdump mode to sanitize /proc/vmcore access Andrew Morton
2021-11-09  2:32 ` [patch 13/87] proc: allow pid_revalidate() during LOOKUP_RCU Andrew Morton
2021-11-09  2:32 ` [patch 14/87] kernel.h: drop unneeded <linux/kernel.h> inclusion from other headers Andrew Morton
2021-11-09  2:32 ` [patch 15/87] kernel.h: split out container_of() and typeof_member() macros Andrew Morton
2021-11-09  2:32 ` [patch 16/87] include/kunit/test.h: replace kernel.h with the necessary inclusions Andrew Morton
2021-11-09  2:32 ` [patch 17/87] include/linux/list.h: " Andrew Morton
2021-11-09  2:32 ` [patch 18/87] include/linux/llist.h: " Andrew Morton
2021-11-09  2:32 ` [patch 19/87] include/linux/plist.h: " Andrew Morton
2021-11-09  2:32 ` [patch 20/87] include/media/media-entity.h: " Andrew Morton
2021-11-09  2:32 ` [patch 21/87] include/linux/delay.h: " Andrew Morton
2021-11-09  2:32 ` [patch 22/87] include/linux/sbitmap.h: " Andrew Morton
2021-11-09  2:32 ` [patch 23/87] include/linux/radix-tree.h: " Andrew Morton
2021-11-09  2:32 ` [patch 24/87] include/linux/generic-radix-tree.h: " Andrew Morton
2021-11-09  2:32 ` [patch 25/87] kernel.h: split out instruction pointer accessors Andrew Morton
2021-11-09  2:32 ` [patch 26/87] linux/container_of.h: switch to static_assert Andrew Morton
2021-11-09  2:32 ` [patch 27/87] mailmap: update email address for Colin King Andrew Morton
2021-11-09  2:32 ` [patch 28/87] MAINTAINERS: add "exec & binfmt" section with myself and Eric Andrew Morton
2021-11-09  2:32 ` [patch 29/87] MAINTAINERS: rectify entry for ARM/TOSHIBA VISCONTI ARCHITECTURE Andrew Morton
2021-11-09  2:32 ` [patch 30/87] MAINTAINERS: rectify entry for HIKEY960 ONBOARD USB GPIO HUB DRIVER Andrew Morton
2021-11-09  2:33 ` [patch 31/87] MAINTAINERS: rectify entry for INTEL KEEM BAY DRM DRIVER Andrew Morton
2021-11-09  2:33 ` [patch 32/87] MAINTAINERS: rectify entry for ALLWINNER HARDWARE SPINLOCK SUPPORT Andrew Morton
2021-11-09  2:33 ` [patch 33/87] lib, stackdepot: check stackdepot handle before accessing slabs Andrew Morton
2021-11-09  2:33 ` [patch 34/87] lib, stackdepot: add helper to print stack entries Andrew Morton
2021-11-09  2:33 ` [patch 35/87] lib, stackdepot: add helper to print stack entries into buffer Andrew Morton
2021-11-09  2:33 ` [patch 36/87] include/linux/string_helpers.h: add linux/string.h for strlen() Andrew Morton
2021-11-09  2:33 ` [patch 37/87] lib: uninline simple_strntoull() as well Andrew Morton
2021-11-09  2:33 ` [patch 38/87] mm/scatterlist: replace the !preemptible warning in sg_miter_stop() Andrew Morton
2021-11-09  2:33 ` [patch 39/87] const_structs.checkpatch: add a few sound ops structs Andrew Morton
2021-11-09  2:33 ` [patch 40/87] checkpatch: improve EXPORT_SYMBOL test for EXPORT_SYMBOL_NS uses Andrew Morton
2021-11-09  2:33 ` [patch 41/87] checkpatch: get default codespell dictionary path from package location Andrew Morton
2021-11-09  2:33 ` [patch 42/87] binfmt_elf: reintroduce using MAP_FIXED_NOREPLACE Andrew Morton
2021-11-09  2:33 ` [patch 43/87] ELF: simplify STACK_ALLOC macro Andrew Morton
2021-11-09  2:33 ` [patch 44/87] kallsyms: remove arch specific text and data check Andrew Morton
2021-11-09  2:33 ` [patch 45/87] kallsyms: fix address-checks for kernel related range Andrew Morton
2021-11-09  2:33 ` [patch 46/87] sections: move and rename core_kernel_data() to is_kernel_core_data() Andrew Morton
2021-11-09  2:33 ` [patch 47/87] sections: move is_kernel_inittext() into sections.h Andrew Morton
2021-11-09  2:33 ` [patch 48/87] x86: mm: rename __is_kernel_text() to is_x86_32_kernel_text() Andrew Morton
2021-11-09  2:34 ` [patch 49/87] sections: provide internal __is_kernel() and __is_kernel_text() helper Andrew Morton
2021-11-09  2:34 ` [patch 50/87] mm: kasan: use is_kernel() helper Andrew Morton
2021-11-09  2:34 ` [patch 51/87] extable: use is_kernel_text() helper Andrew Morton
2021-11-09  2:34 ` [patch 52/87] powerpc/mm: use core_kernel_text() helper Andrew Morton
2021-11-09  2:34 ` [patch 53/87] microblaze: use is_kernel_text() helper Andrew Morton
2021-11-09  2:34 ` [patch 54/87] alpha: " Andrew Morton
2021-11-09  2:34 ` [patch 55/87] ramfs: fix mount source show for ramfs Andrew Morton
2021-11-09  2:34 ` [patch 56/87] init: make unknown command line param message clearer Andrew Morton
2021-11-09  2:34 ` [patch 57/87] coda: avoid NULL pointer dereference from a bad inode Andrew Morton
2021-11-09  2:34 ` [patch 58/87] coda: check for async upcall request using local state Andrew Morton
2021-11-09  2:34 ` [patch 59/87] coda: remove err which no one care Andrew Morton
2021-11-09  2:34 ` [patch 60/87] coda: avoid flagging NULL inodes Andrew Morton
2021-11-09  2:34 ` [patch 61/87] coda: avoid hidden code duplication in rename Andrew Morton
2021-11-09  2:34 ` [patch 62/87] coda: avoid doing bad things on inode type changes during revalidation Andrew Morton
2021-11-09  2:34 ` [patch 63/87] coda: convert from atomic_t to refcount_t on coda_vm_ops->refcnt Andrew Morton
2021-11-09  2:34 ` [patch 64/87] coda: use vmemdup_user to replace the open code Andrew Morton
2021-11-09  2:34 ` [patch 65/87] coda: bump module version to 7.2 Andrew Morton
2021-11-09  2:34 ` [patch 66/87] nilfs2: replace snprintf in show functions with sysfs_emit Andrew Morton
2021-11-09  2:35 ` [patch 67/87] nilfs2: remove filenames from file comments Andrew Morton
2021-11-09  2:35 ` [patch 68/87] hfs/hfsplus: use WARN_ON for sanity check Andrew Morton
2021-11-09  2:35 ` [patch 69/87] crash_dump: fix boolreturn.cocci warning Andrew Morton
2021-11-09  2:35 ` [patch 70/87] crash_dump: remove duplicate include in crash_dump.h Andrew Morton
2021-11-09  2:35 ` [patch 71/87] signal: remove duplicate include in signal.h Andrew Morton
2021-11-09  2:35 ` [patch 72/87] seq_file: move seq_escape() to a header Andrew Morton
2021-11-09  2:35 ` [patch 73/87] seq_file: fix passing wrong private data Andrew Morton
2021-11-09  2:35 ` [patch 74/87] kernel/fork.c: unshare(): use swap() to make code cleaner Andrew Morton
2021-11-09  2:35 ` [patch 75/87] sysv: use BUILD_BUG_ON instead of runtime check Andrew Morton
2021-11-09  2:35 ` [patch 76/87] Documentation/kcov: include types.h in the example Andrew Morton
2021-11-09  2:35 ` [patch 77/87] Documentation/kcov: define `ip' " Andrew Morton
2021-11-09  2:35 ` [patch 78/87] kcov: allocate per-CPU memory on the relevant node Andrew Morton
2021-11-09  2:35 ` [patch 79/87] kcov: avoid enable+disable interrupts if !in_task() Andrew Morton
2021-11-09  2:35 ` [patch 80/87] kcov: replace local_irq_save() with a local_lock_t Andrew Morton
2021-11-09  2:35 ` [patch 81/87] scripts/gdb: handle split debug for vmlinux Andrew Morton
2021-11-09  2:35 ` [patch 82/87] kernel/resource: clean up and optimize iomem_is_exclusive() Andrew Morton
2021-11-09  2:35 ` [patch 83/87] kernel/resource: disallow access to exclusive system RAM regions Andrew Morton
2021-11-09  2:35 ` [patch 84/87] virtio-mem: disallow mapping virtio-mem memory via /dev/mem Andrew Morton
2021-11-09  2:35 ` [patch 85/87] selftests/kselftest/runner/run_one(): allow running non-executable files Andrew Morton
2021-11-09  2:35 ` [patch 86/87] ipc: check checkpoint_restore_ns_capable() to modify C/R proc files Andrew Morton
2021-11-09  2:36 ` [patch 87/87] ipc/ipc_sysctl.c: remove fallback for !CONFIG_PROC_SYSCTL Andrew Morton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211109023127.M0F66RgO7%akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=hughd@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=liuzixian4@huawei.com \
    --cc=mhocko@suse.com \
    --cc=mike.kravetz@oracle.com \
    --cc=mm-commits@vger.kernel.org \
    --cc=torvalds@linux-foundation.org \
    --cc=wuxu.wu@huawei.com \
    --cc=zhangyiru3@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.