mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-03-22 07:27:12 +08:00
mm: update all remaining mmap_prepare users to use vma_flags_t
We will be shortly removing the vm_flags_t field from vm_area_desc so we need to update all mmap_prepare users to only use the dessc->vma_flags field. This patch achieves that and makes all ancillary changes required to make this possible. This lays the groundwork for future work to eliminate the use of vm_flags_t in vm_area_desc altogether and more broadly throughout the kernel. While we're here, we take the opportunity to replace VM_REMAP_FLAGS with VMA_REMAP_FLAGS, the vma_flags_t equivalent. No functional changes intended. Link: https://lkml.kernel.org/r/fb1f55323799f09fe6a36865b31550c9ec67c225.1769097829.git.lorenzo.stoakes@oracle.com Signed-off-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com> Acked-by: Damien Le Moal <dlemoal@kernel.org> [zonefs] Acked-by: "Darrick J. Wong" <djwong@kernel.org> Acked-by: Pedro Falcato <pfalcato@suse.de> 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: Liam Howlett <liam.howlett@oracle.com> Cc: Suren Baghdasaryan <surenb@google.com> Cc: Vlastimil Babka <vbabka@suse.cz> Cc: Zi Yan <ziy@nvidia.com> Cc: Jarkko Sakkinen <jarkko@kernel.org> Cc: Yury Norov <ynorov@nvidia.com> Cc: Chris Mason <clm@fb.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
committed by
Andrew Morton
parent
590d356aa4
commit
5bd2c0650a
17
mm/memory.c
17
mm/memory.c
@@ -2957,7 +2957,7 @@ static inline int remap_p4d_range(struct mm_struct *mm, pgd_t *pgd,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_remap_pgoff(vm_flags_t vm_flags, unsigned long addr,
|
||||
static int get_remap_pgoff(bool is_cow, unsigned long addr,
|
||||
unsigned long end, unsigned long vm_start, unsigned long vm_end,
|
||||
unsigned long pfn, pgoff_t *vm_pgoff_p)
|
||||
{
|
||||
@@ -2967,7 +2967,7 @@ static int get_remap_pgoff(vm_flags_t vm_flags, unsigned long addr,
|
||||
* un-COW'ed pages by matching them up with "vma->vm_pgoff".
|
||||
* See vm_normal_page() for details.
|
||||
*/
|
||||
if (is_cow_mapping(vm_flags)) {
|
||||
if (is_cow) {
|
||||
if (addr != vm_start || end != vm_end)
|
||||
return -EINVAL;
|
||||
*vm_pgoff_p = pfn;
|
||||
@@ -2988,7 +2988,7 @@ static int remap_pfn_range_internal(struct vm_area_struct *vma, unsigned long ad
|
||||
if (WARN_ON_ONCE(!PAGE_ALIGNED(addr)))
|
||||
return -EINVAL;
|
||||
|
||||
VM_WARN_ON_ONCE((vma->vm_flags & VM_REMAP_FLAGS) != VM_REMAP_FLAGS);
|
||||
VM_WARN_ON_ONCE(!vma_test_all_flags_mask(vma, VMA_REMAP_FLAGS));
|
||||
|
||||
BUG_ON(addr >= end);
|
||||
pfn -= addr >> PAGE_SHIFT;
|
||||
@@ -3112,9 +3112,9 @@ void remap_pfn_range_prepare(struct vm_area_desc *desc, unsigned long pfn)
|
||||
* check it again on complete and will fail there if specified addr is
|
||||
* invalid.
|
||||
*/
|
||||
get_remap_pgoff(desc->vm_flags, desc->start, desc->end,
|
||||
get_remap_pgoff(vma_desc_is_cow_mapping(desc), desc->start, desc->end,
|
||||
desc->start, desc->end, pfn, &desc->pgoff);
|
||||
desc->vm_flags |= VM_REMAP_FLAGS;
|
||||
vma_desc_set_flags_mask(desc, VMA_REMAP_FLAGS);
|
||||
}
|
||||
|
||||
static int remap_pfn_range_prepare_vma(struct vm_area_struct *vma, unsigned long addr,
|
||||
@@ -3123,13 +3123,12 @@ static int remap_pfn_range_prepare_vma(struct vm_area_struct *vma, unsigned long
|
||||
unsigned long end = addr + PAGE_ALIGN(size);
|
||||
int err;
|
||||
|
||||
err = get_remap_pgoff(vma->vm_flags, addr, end,
|
||||
vma->vm_start, vma->vm_end,
|
||||
pfn, &vma->vm_pgoff);
|
||||
err = get_remap_pgoff(is_cow_mapping(vma->vm_flags), addr, end,
|
||||
vma->vm_start, vma->vm_end, pfn, &vma->vm_pgoff);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
vm_flags_set(vma, VM_REMAP_FLAGS);
|
||||
vma_set_flags_mask(vma, VMA_REMAP_FLAGS);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user