summaryrefslogtreecommitdiff
path: root/ipc
diff options
context:
space:
mode:
Diffstat (limited to 'ipc')
-rw-r--r--ipc/shm.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/ipc/shm.c b/ipc/shm.c
index 3db36773dd10..e8c7d1924c50 100644
--- a/ipc/shm.c
+++ b/ipc/shm.c
@@ -707,9 +707,10 @@ static int newseg(struct ipc_namespace *ns, struct ipc_params *params)
int error;
struct shmid_kernel *shp;
size_t numpages = (size + PAGE_SIZE - 1) >> PAGE_SHIFT;
+ const bool has_no_reserve = shmflg & SHM_NORESERVE;
+ vma_flags_t acctflag = EMPTY_VMA_FLAGS;
struct file *file;
char name[13];
- vm_flags_t acctflag = 0;
if (size < SHMMIN || size > ns->shm_ctlmax)
return -EINVAL;
@@ -749,8 +750,8 @@ static int newseg(struct ipc_namespace *ns, struct ipc_params *params)
hugesize = ALIGN(size, huge_page_size(hs));
/* hugetlb_file_setup applies strict accounting */
- if (shmflg & SHM_NORESERVE)
- acctflag = VM_NORESERVE;
+ if (has_no_reserve)
+ vma_flags_set(&acctflag, VMA_NORESERVE_BIT);
file = hugetlb_file_setup(name, hugesize, acctflag,
HUGETLB_SHMFS_INODE, (shmflg >> SHM_HUGE_SHIFT) & SHM_HUGE_MASK);
} else {
@@ -758,9 +759,8 @@ static int newseg(struct ipc_namespace *ns, struct ipc_params *params)
* Do not allow no accounting for OVERCOMMIT_NEVER, even
* if it's asked for.
*/
- if ((shmflg & SHM_NORESERVE) &&
- sysctl_overcommit_memory != OVERCOMMIT_NEVER)
- acctflag = VM_NORESERVE;
+ if (has_no_reserve && sysctl_overcommit_memory != OVERCOMMIT_NEVER)
+ vma_flags_set(&acctflag, VMA_NORESERVE_BIT);
file = shmem_kernel_file_setup(name, size, acctflag);
}
error = PTR_ERR(file);