From: Vlastimil Babka <vbabka@suse.cz>
To: Lorenzo Stoakes <lstoakes@gmail.com>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
Andrew Morton <akpm@linux-foundation.org>,
Alexander Viro <viro@zeniv.linux.org.uk>,
Christian Brauner <brauner@kernel.org>
Cc: "=Liam R . Howlett" <Liam.Howlett@oracle.com>,
linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH v2 1/5] mm: move vma_policy() and anon_vma_name() decls to mm_types.h
Date: Tue, 10 Oct 2023 08:46:07 +0200 [thread overview]
Message-ID: <52d4760a-9d4b-e3c0-d236-5eaa0eb5f96a@suse.cz> (raw)
In-Reply-To: <4f1063f9c0e05ada89458083476e03434498e81e.1696884493.git.lstoakes@gmail.com>
On 10/9/23 22:53, Lorenzo Stoakes wrote:
> The vma_policy() define is a helper specifically for a VMA field so it
> makes sense to host it in the memory management types header.
>
> The anon_vma_name(), anon_vma_name_alloc() and anon_vma_name_free()
> functions are a little out of place in mm_inline.h as they define external
> functions, and so it makes sense to locate them in mm_types.h.
>
> The purpose of these relocations is to make it possible to abstract static
> inline wrappers which invoke both of these helpers.
>
> Signed-off-by: Lorenzo Stoakes <lstoakes@gmail.com>
Reviewed-by: Vlastimil Babka <vbabka@suse.cz>
> ---
> include/linux/mempolicy.h | 4 ----
> include/linux/mm_inline.h | 20 +-------------------
> include/linux/mm_types.h | 27 +++++++++++++++++++++++++++
> 3 files changed, 28 insertions(+), 23 deletions(-)
>
> diff --git a/include/linux/mempolicy.h b/include/linux/mempolicy.h
> index 3c208d4f0ee9..2801d5b0a4e9 100644
> --- a/include/linux/mempolicy.h
> +++ b/include/linux/mempolicy.h
> @@ -89,8 +89,6 @@ static inline struct mempolicy *mpol_dup(struct mempolicy *pol)
> return pol;
> }
>
> -#define vma_policy(vma) ((vma)->vm_policy)
> -
> static inline void mpol_get(struct mempolicy *pol)
> {
> if (pol)
> @@ -222,8 +220,6 @@ static inline struct mempolicy *get_vma_policy(struct vm_area_struct *vma,
> return NULL;
> }
>
> -#define vma_policy(vma) NULL
> -
> static inline int
> vma_dup_policy(struct vm_area_struct *src, struct vm_area_struct *dst)
> {
> diff --git a/include/linux/mm_inline.h b/include/linux/mm_inline.h
> index 8148b30a9df1..9ae7def16cb2 100644
> --- a/include/linux/mm_inline.h
> +++ b/include/linux/mm_inline.h
> @@ -4,6 +4,7 @@
>
> #include <linux/atomic.h>
> #include <linux/huge_mm.h>
> +#include <linux/mm_types.h>
> #include <linux/swap.h>
> #include <linux/string.h>
> #include <linux/userfaultfd_k.h>
> @@ -352,15 +353,6 @@ void lruvec_del_folio(struct lruvec *lruvec, struct folio *folio)
> }
>
> #ifdef CONFIG_ANON_VMA_NAME
> -/*
> - * mmap_lock should be read-locked when calling anon_vma_name(). Caller should
> - * either keep holding the lock while using the returned pointer or it should
> - * raise anon_vma_name refcount before releasing the lock.
> - */
> -extern struct anon_vma_name *anon_vma_name(struct vm_area_struct *vma);
> -extern struct anon_vma_name *anon_vma_name_alloc(const char *name);
> -extern void anon_vma_name_free(struct kref *kref);
> -
> /* mmap_lock should be read-locked */
> static inline void anon_vma_name_get(struct anon_vma_name *anon_name)
> {
> @@ -415,16 +407,6 @@ static inline bool anon_vma_name_eq(struct anon_vma_name *anon_name1,
> }
>
> #else /* CONFIG_ANON_VMA_NAME */
> -static inline struct anon_vma_name *anon_vma_name(struct vm_area_struct *vma)
> -{
> - return NULL;
> -}
> -
> -static inline struct anon_vma_name *anon_vma_name_alloc(const char *name)
> -{
> - return NULL;
> -}
> -
> static inline void anon_vma_name_get(struct anon_vma_name *anon_name) {}
> static inline void anon_vma_name_put(struct anon_vma_name *anon_name) {}
> static inline void dup_anon_vma_name(struct vm_area_struct *orig_vma,
> diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
> index 36c5b43999e6..21eb56145f57 100644
> --- a/include/linux/mm_types.h
> +++ b/include/linux/mm_types.h
> @@ -546,6 +546,27 @@ struct anon_vma_name {
> char name[];
> };
>
> +#ifdef CONFIG_ANON_VMA_NAME
> +/*
> + * mmap_lock should be read-locked when calling anon_vma_name(). Caller should
> + * either keep holding the lock while using the returned pointer or it should
> + * raise anon_vma_name refcount before releasing the lock.
> + */
> +struct anon_vma_name *anon_vma_name(struct vm_area_struct *vma);
> +struct anon_vma_name *anon_vma_name_alloc(const char *name);
> +void anon_vma_name_free(struct kref *kref);
> +#else /* CONFIG_ANON_VMA_NAME */
> +static inline struct anon_vma_name *anon_vma_name(struct vm_area_struct *vma)
> +{
> + return NULL;
> +}
> +
> +static inline struct anon_vma_name *anon_vma_name_alloc(const char *name)
> +{
> + return NULL;
> +}
> +#endif
> +
> struct vma_lock {
> struct rw_semaphore lock;
> };
> @@ -662,6 +683,12 @@ struct vm_area_struct {
> struct vm_userfaultfd_ctx vm_userfaultfd_ctx;
> } __randomize_layout;
>
> +#ifdef CONFIG_NUMA
> +#define vma_policy(vma) ((vma)->vm_policy)
> +#else
> +#define vma_policy(vma) NULL
> +#endif
> +
> #ifdef CONFIG_SCHED_MM_CID
> struct mm_cid {
> u64 time;
next prev parent reply other threads:[~2023-10-10 6:46 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-09 20:53 [PATCH v2 0/5] Abstract vma_merge() and split_vma() Lorenzo Stoakes
2023-10-09 20:53 ` [PATCH v2 1/5] mm: move vma_policy() and anon_vma_name() decls to mm_types.h Lorenzo Stoakes
2023-10-10 6:46 ` Vlastimil Babka [this message]
2023-10-09 20:53 ` [PATCH v2 2/5] mm: abstract the vma_merge()/split_vma() pattern for mprotect() et al Lorenzo Stoakes
2023-10-10 7:12 ` Vlastimil Babka
2023-10-10 18:11 ` Lorenzo Stoakes
2023-10-11 2:14 ` Liam R. Howlett
2023-10-11 6:34 ` Lorenzo Stoakes
2023-10-09 20:53 ` [PATCH v2 3/5] mm: make vma_merge() and split_vma() internal Lorenzo Stoakes
2023-10-09 20:53 ` [PATCH v2 4/5] mm: abstract merge for new VMAs into vma_merge_new_vma() Lorenzo Stoakes
2023-10-11 1:51 ` Liam R. Howlett
2023-10-11 6:48 ` Lorenzo Stoakes
2023-10-09 20:53 ` [PATCH v2 5/5] mm: abstract VMA merge and extend into vma_merge_extend() helper Lorenzo Stoakes
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=52d4760a-9d4b-e3c0-d236-5eaa0eb5f96a@suse.cz \
--to=vbabka@suse.cz \
--cc=Liam.Howlett@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=brauner@kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=lstoakes@gmail.com \
--cc=viro@zeniv.linux.org.uk \
/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;
as well as URLs for NNTP newsgroup(s).