From: David Hildenbrand <david@redhat.com>
To: Vlastimil Babka <vbabka@suse.cz>,
Andrew Morton <akpm@linux-foundation.org>,
"Liam R. Howlett" <Liam.Howlett@oracle.com>,
Lorenzo Stoakes <lorenzo.stoakes@oracle.com>,
Jann Horn <jannh@google.com>, Mike Rapoport <rppt@kernel.org>,
Suren Baghdasaryan <surenb@google.com>,
Michal Hocko <mhocko@suse.com>, Colin Cross <ccross@google.com>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 3/4] mm, madvise: move madvise_set_anon_name() down the file
Date: Tue, 24 Jun 2025 16:05:26 +0200 [thread overview]
Message-ID: <c6240a90-e02a-4ae2-b144-4fbf82aca6ce@redhat.com> (raw)
In-Reply-To: <20250624-anon_name_cleanup-v2-3-600075462a11@suse.cz>
On 24.06.25 15:03, Vlastimil Babka wrote:
> Preparatory change so that we can use madvise_lock()/unlock() in the
> function without forward declarations or more thorough shuffling.
>
> Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
> ---
> mm/madvise.c | 64 ++++++++++++++++++++++++++++++------------------------------
> 1 file changed, 32 insertions(+), 32 deletions(-)
>
> diff --git a/mm/madvise.c b/mm/madvise.c
> index 7e8819b5e9a0f183213ffe19d7e52bd5fda5f49d..cae064479cdf908707c45b941bd03d43d095eab6 100644
> --- a/mm/madvise.c
> +++ b/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)
> {
>
Personally, I would squash that into #4, given that #4 is pretty small ;)
Acked-by: David Hildenbrand <david@redhat.com>
--
Cheers,
David / dhildenb
next prev parent reply other threads:[~2025-06-24 14:05 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-24 13:03 [PATCH v2 0/4] madvise anon_name cleanups Vlastimil Babka
2025-06-24 13:03 ` [PATCH v2 1/4] mm, madvise: simplify anon_name handling Vlastimil Babka
2025-06-24 13:58 ` David Hildenbrand
2025-06-24 14:28 ` Suren Baghdasaryan
2025-06-24 16:41 ` Vlastimil Babka
2025-06-24 16:38 ` Vlastimil Babka
2025-06-24 15:26 ` Lorenzo Stoakes
2025-06-24 16:42 ` Vlastimil Babka
2025-06-24 17:01 ` Vlastimil Babka
2025-06-24 13:03 ` [PATCH v2 2/4] mm, madvise: extract mm code from prctl_set_vma() to mm/madvise.c Vlastimil Babka
2025-06-24 14:04 ` David Hildenbrand
2025-06-24 14:31 ` Suren Baghdasaryan
2025-06-24 15:28 ` Lorenzo Stoakes
2025-06-24 13:03 ` [PATCH v2 3/4] mm, madvise: move madvise_set_anon_name() down the file Vlastimil Babka
2025-06-24 14:05 ` David Hildenbrand [this message]
2025-06-24 14:33 ` Suren Baghdasaryan
2025-06-24 16:46 ` Vlastimil Babka
2025-06-24 15:36 ` Lorenzo Stoakes
2025-06-24 17:02 ` Vlastimil Babka
2025-06-24 13:03 ` [PATCH v2 4/4] mm, madvise: use standard madvise locking in madvise_set_anon_name() Vlastimil Babka
2025-06-24 14:06 ` David Hildenbrand
2025-06-24 14:35 ` Suren Baghdasaryan
2025-06-24 15:45 ` Lorenzo Stoakes
2025-06-24 16:48 ` Vlastimil Babka
2025-06-24 17:03 ` Vlastimil Babka
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=c6240a90-e02a-4ae2-b144-4fbf82aca6ce@redhat.com \
--to=david@redhat.com \
--cc=Liam.Howlett@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=ccross@google.com \
--cc=jannh@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=lorenzo.stoakes@oracle.com \
--cc=mhocko@suse.com \
--cc=rppt@kernel.org \
--cc=surenb@google.com \
--cc=vbabka@suse.cz \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox