mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-10 11:40:19 -04:00
mm, madvise: move madvise_set_anon_name() down the file
Preparatory change so that we can use madvise_lock()/unlock() in the function without forward declarations or more thorough shuffling. No functional change. Move as a separate commit helps git heuristics to detect it properly. Link: https://lkml.kernel.org/r/20250624-anon_name_cleanup-v2-3-600075462a11@suse.cz Signed-off-by: Vlastimil Babka <vbabka@suse.cz> Tested-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com> Acked-by: David Hildenbrand <david@redhat.com> Reviewed-by: Suren Baghdasaryan <surenb@google.com> Reviewed-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com> Cc: Colin Cross <ccross@google.com> Cc: Jann Horn <jannh@google.com> Cc: Liam Howlett <liam.howlett@oracle.com> Cc: Michal Hocko <mhocko@suse.com> Cc: Mike Rapoport <rppt@kernel.org> Cc: SeongJae Park <sj@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
committed by
Andrew Morton
parent
6b233784b1
commit
986738ce44
64
mm/madvise.c
64
mm/madvise.c
@@ -133,38 +133,6 @@ static int replace_anon_vma_name(struct vm_area_struct *vma,
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int madvise_set_anon_name(struct mm_struct *mm, unsigned long start,
|
||||
unsigned long len_in, struct anon_vma_name *anon_name)
|
||||
{
|
||||
unsigned long end;
|
||||
unsigned long len;
|
||||
struct madvise_behavior madv_behavior = {
|
||||
.mm = mm,
|
||||
.behavior = __MADV_SET_ANON_VMA_NAME,
|
||||
.lock_mode = MADVISE_MMAP_WRITE_LOCK,
|
||||
.anon_name = anon_name,
|
||||
};
|
||||
|
||||
if (start & ~PAGE_MASK)
|
||||
return -EINVAL;
|
||||
len = (len_in + ~PAGE_MASK) & PAGE_MASK;
|
||||
|
||||
/* Check to see whether len was rounded up from small -ve to zero */
|
||||
if (len_in && !len)
|
||||
return -EINVAL;
|
||||
|
||||
end = start + len;
|
||||
if (end < start)
|
||||
return -EINVAL;
|
||||
|
||||
if (end == start)
|
||||
return 0;
|
||||
|
||||
madv_behavior.range.start = start;
|
||||
madv_behavior.range.end = end;
|
||||
return madvise_walk_vmas(&madv_behavior);
|
||||
}
|
||||
#else /* CONFIG_ANON_VMA_NAME */
|
||||
static int replace_anon_vma_name(struct vm_area_struct *vma,
|
||||
struct anon_vma_name *anon_name)
|
||||
@@ -2109,6 +2077,38 @@ static inline bool is_valid_name_char(char ch)
|
||||
!strchr(ANON_VMA_NAME_INVALID_CHARS, ch);
|
||||
}
|
||||
|
||||
static int madvise_set_anon_name(struct mm_struct *mm, unsigned long start,
|
||||
unsigned long len_in, struct anon_vma_name *anon_name)
|
||||
{
|
||||
unsigned long end;
|
||||
unsigned long len;
|
||||
struct madvise_behavior madv_behavior = {
|
||||
.mm = mm,
|
||||
.behavior = __MADV_SET_ANON_VMA_NAME,
|
||||
.lock_mode = MADVISE_MMAP_WRITE_LOCK,
|
||||
.anon_name = anon_name,
|
||||
};
|
||||
|
||||
if (start & ~PAGE_MASK)
|
||||
return -EINVAL;
|
||||
len = (len_in + ~PAGE_MASK) & PAGE_MASK;
|
||||
|
||||
/* Check to see whether len was rounded up from small -ve to zero */
|
||||
if (len_in && !len)
|
||||
return -EINVAL;
|
||||
|
||||
end = start + len;
|
||||
if (end < start)
|
||||
return -EINVAL;
|
||||
|
||||
if (end == start)
|
||||
return 0;
|
||||
|
||||
madv_behavior.range.start = start;
|
||||
madv_behavior.range.end = end;
|
||||
return madvise_walk_vmas(&madv_behavior);
|
||||
}
|
||||
|
||||
int set_anon_vma_name(unsigned long addr, unsigned long size,
|
||||
const char __user *uname)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user