mirror of
https://github.com/torvalds/linux.git
synced 2026-03-08 01:24:47 +01:00
mm: update hugetlbfs to use VMA flags on mmap_prepare
In order to update all mmap_prepare users to utilising the new VMA flags type vma_flags_t and associated helper functions, we start by updating hugetlbfs which has a lot of additional logic that requires updating to make this change. This is laying the groundwork for eliminating the vm_flags_t from struct vm_area_desc and using vma_flags_t only, which further lays the ground for removing the deprecated vm_flags_t type altogether. No functional changes intended. Link: https://lkml.kernel.org/r/9226bec80c9aa3447cc2b83354f733841dba8a50.1769097829.git.lorenzo.stoakes@oracle.com Signed-off-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com> Reviewed-by: Liam R. Howlett <Liam.Howlett@oracle.com> Cc: Baolin Wang <baolin.wang@linux.alibaba.com> Cc: Barry Song <baohua@kernel.org> Cc: David Hildenbrand <david@kernel.org> Cc: Dev Jain <dev.jain@arm.com> Cc: Jason Gunthorpe <jgg@nvidia.com> Cc: Suren Baghdasaryan <surenb@google.com> Cc: Vlastimil Babka <vbabka@suse.cz> Cc: Zi Yan <ziy@nvidia.com> Cc: Damien Le Moal <dlemoal@kernel.org> Cc: "Darrick J. Wong" <djwong@kernel.org> Cc: Jarkko Sakkinen <jarkko@kernel.org> Cc: Yury Norov <ynorov@nvidia.com> Cc: Chris Mason <clm@fb.com> Cc: Pedro Falcato <pfalcato@suse.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
parent
bae0ba7c7c
commit
097e8db5e2
7 changed files with 41 additions and 29 deletions
12
ipc/shm.c
12
ipc/shm.c
|
|
@ -707,9 +707,9 @@ 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;
|
||||
struct file *file;
|
||||
char name[13];
|
||||
vm_flags_t acctflag = 0;
|
||||
|
||||
if (size < SHMMIN || size > ns->shm_ctlmax)
|
||||
return -EINVAL;
|
||||
|
|
@ -738,6 +738,7 @@ static int newseg(struct ipc_namespace *ns, struct ipc_params *params)
|
|||
|
||||
sprintf(name, "SYSV%08x", key);
|
||||
if (shmflg & SHM_HUGETLB) {
|
||||
vma_flags_t acctflag = EMPTY_VMA_FLAGS;
|
||||
struct hstate *hs;
|
||||
size_t hugesize;
|
||||
|
||||
|
|
@ -749,17 +750,18 @@ 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 {
|
||||
vm_flags_t acctflag = 0;
|
||||
|
||||
/*
|
||||
* Do not allow no accounting for OVERCOMMIT_NEVER, even
|
||||
* if it's asked for.
|
||||
*/
|
||||
if ((shmflg & SHM_NORESERVE) &&
|
||||
sysctl_overcommit_memory != OVERCOMMIT_NEVER)
|
||||
if (has_no_reserve && sysctl_overcommit_memory != OVERCOMMIT_NEVER)
|
||||
acctflag = VM_NORESERVE;
|
||||
file = shmem_kernel_file_setup(name, size, acctflag);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue