From: Hugh Dickins <hughd@google.com>
To: Shivank Garg <shivankg@amd.com>
Cc: akpm@linux-foundation.org, linux-kernel@vger.kernel.org,
linux-mm@kvack.org
Subject: Re: [PATCH] mm: use vma_policy() to get vm_policy
Date: Fri, 1 Nov 2024 00:37:45 -0700 (PDT) [thread overview]
Message-ID: <8169912f-82dc-e210-862c-f6eb092db78d@google.com> (raw)
In-Reply-To: <20241101071350.402878-1-shivankg@amd.com>
On Fri, 1 Nov 2024, Shivank Garg wrote:
> Instead of accessing vma->vm_policy directly, use vma_policy() like
> other places for consistency.
>
> Signed-off-by: Shivank Garg <shivankg@amd.com>
NAK. The vma_policy(vma) wrapper exists to avoid #ifdef CONFIG_NUMAs
all over the place; there is no point to it inside CONFIG_NUMA source.
Hugh
> ---
> ipc/shm.c | 2 +-
> mm/mempolicy.c | 16 ++++++++--------
> 2 files changed, 9 insertions(+), 9 deletions(-)
>
> diff --git a/ipc/shm.c b/ipc/shm.c
> index 99564c870084..ebd45e48b0d4 100644
> --- a/ipc/shm.c
> +++ b/ipc/shm.c
> @@ -577,7 +577,7 @@ static struct mempolicy *shm_get_policy(struct vm_area_struct *vma,
> unsigned long addr, pgoff_t *ilx)
> {
> struct shm_file_data *sfd = shm_file_data(vma->vm_file);
> - struct mempolicy *mpol = vma->vm_policy;
> + struct mempolicy *mpol = vma_policy(vma);
>
> if (sfd->vm_ops->get_policy)
> mpol = sfd->vm_ops->get_policy(vma, addr, ilx);
> diff --git a/mm/mempolicy.c b/mm/mempolicy.c
> index b646fab3e45e..7ccbeb9966f0 100644
> --- a/mm/mempolicy.c
> +++ b/mm/mempolicy.c
> @@ -420,7 +420,7 @@ void mpol_rebind_mm(struct mm_struct *mm, nodemask_t *new)
> mmap_write_lock(mm);
> for_each_vma(vmi, vma) {
> vma_start_write(vma);
> - mpol_rebind_policy(vma->vm_policy, new);
> + mpol_rebind_policy(vma_policy(vma), new);
> }
> mmap_write_unlock(mm);
> }
> @@ -805,8 +805,8 @@ static int vma_replace_policy(struct vm_area_struct *vma,
> goto err_out;
> }
>
> - old = vma->vm_policy;
> - vma->vm_policy = new; /* protected by mmap_lock */
> + old = vma_policy(vma);
> + vma_policy(vma) = new; /* protected by mmap_lock */
> mpol_put(old);
>
> return 0;
> @@ -830,7 +830,7 @@ static int mbind_range(struct vma_iterator *vmi, struct vm_area_struct *vma,
> vmstart = vma->vm_start;
> }
>
> - if (mpol_equal(vma->vm_policy, new_pol)) {
> + if (mpol_equal(vma_policy(vma), new_pol)) {
> *prev = vma;
> return 0;
> }
> @@ -1797,7 +1797,7 @@ struct mempolicy *__get_vma_policy(struct vm_area_struct *vma,
> {
> *ilx = 0;
> return (vma->vm_ops && vma->vm_ops->get_policy) ?
> - vma->vm_ops->get_policy(vma, addr, ilx) : vma->vm_policy;
> + vma->vm_ops->get_policy(vma, addr, ilx) : vma_policy(vma);
> }
>
> /*
> @@ -1847,7 +1847,7 @@ bool vma_policy_mof(struct vm_area_struct *vma)
> return ret;
> }
>
> - pol = vma->vm_policy;
> + pol = vma_policy(vma);
> if (!pol)
> pol = get_task_policy(current);
>
> @@ -2559,11 +2559,11 @@ unsigned long alloc_pages_bulk_array_mempolicy_noprof(gfp_t gfp,
>
> int vma_dup_policy(struct vm_area_struct *src, struct vm_area_struct *dst)
> {
> - struct mempolicy *pol = mpol_dup(src->vm_policy);
> + struct mempolicy *pol = mpol_dup(vma_policy(src));
>
> if (IS_ERR(pol))
> return PTR_ERR(pol);
> - dst->vm_policy = pol;
> + vma_policy(dst) = pol;
> return 0;
> }
>
> --
> 2.34.1
next prev parent reply other threads:[~2024-11-01 7:37 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-01 7:13 Shivank Garg
2024-11-01 7:37 ` Hugh Dickins [this message]
2024-11-01 13:30 ` Gregory Price
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=8169912f-82dc-e210-862c-f6eb092db78d@google.com \
--to=hughd@google.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=shivankg@amd.com \
/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