From: Ingo Molnar <mingo@kernel.org>
To: Christoph Hellwig <hch@lst.de>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Dave Hansen <dave.hansen@linux.intel.com>,
Andy Lutomirski <luto@kernel.org>,
Peter Zijlstra <peterz@infradead.org>, Fei Li <fei1.li@intel.com>,
x86@kernel.org, linux-mm@kvack.org
Subject: Re: [PATCH 3/3] mm: move follow_phys to arch/x86/mm/pat/memtype.c
Date: Mon, 25 Mar 2024 11:28:17 +0100 [thread overview]
Message-ID: <ZgFRwVRPyLzLAr9r@gmail.com> (raw)
In-Reply-To: <20240324234542.2038726-4-hch@lst.de>
* Christoph Hellwig <hch@lst.de> wrote:
> follow_phys is only used by two allers in arch/x86/mm/pat/memtype.c.
> Move it there and hardcode the two arguments that get the same values
> passed by both caller.
s/aller
/caller
s/both caller.
/both callers.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
> arch/x86/mm/pat/memtype.c | 22 ++++++++++++++++++++--
> include/linux/mm.h | 2 --
> mm/memory.c | 28 ----------------------------
> 3 files changed, 20 insertions(+), 32 deletions(-)
>
> diff --git a/arch/x86/mm/pat/memtype.c b/arch/x86/mm/pat/memtype.c
> index 0d72183b5dd028..bad99eb5c95b0d 100644
> --- a/arch/x86/mm/pat/memtype.c
> +++ b/arch/x86/mm/pat/memtype.c
> @@ -947,6 +947,24 @@ static void free_pfn_range(u64 paddr, unsigned long size)
> memtype_free(paddr, paddr + size);
> }
>
> +static int follow_phys(struct vm_area_struct *vma, unsigned long *prot,
> + resource_size_t *phys)
> +{
> + pte_t *ptep, pte;
> + spinlock_t *ptl;
> +
> + if (!(vma->vm_flags & (VM_IO | VM_PFNMAP)))
> + return -EINVAL;
> +
> + if (follow_pte(vma->vm_mm, vma->vm_start, &ptep, &ptl))
> + return -EINVAL;
> + pte = ptep_get(ptep);
> + *prot = pgprot_val(pte_pgprot(pte));
> + *phys = (resource_size_t)pte_pfn(pte) << PAGE_SHIFT;
> + pte_unmap_unlock(ptep, ptl);
> + return 0;
> +}
Please keep the readability newlines as the original had, ie.:
+ if (follow_pte(vma->vm_mm, vma->vm_start, &ptep, &ptl))
+ return -EINVAL;
+
+ pte = ptep_get(ptep);
+ *prot = pgprot_val(pte_pgprot(pte));
+ *phys = (resource_size_t)pte_pfn(pte) << PAGE_SHIFT;
+ pte_unmap_unlock(ptep, ptl);
+
+ return 0;
Thanks,
Ingo
next prev parent reply other threads:[~2024-03-25 10:28 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-24 23:45 remove follow_pfn Christoph Hellwig
2024-03-24 23:45 ` [PATCH 1/3] virt: acrn: stop using follow_pfn Christoph Hellwig
2024-03-25 10:33 ` David Hildenbrand
2024-03-26 6:04 ` Christoph Hellwig
2024-03-26 17:06 ` David Hildenbrand
2024-03-24 23:45 ` [PATCH 2/3] mm: remove follow_pfn Christoph Hellwig
2024-03-25 10:33 ` David Hildenbrand
2024-03-24 23:45 ` [PATCH 3/3] mm: move follow_phys to arch/x86/mm/pat/memtype.c Christoph Hellwig
2024-03-25 10:28 ` Ingo Molnar [this message]
2024-03-25 10:36 ` David Hildenbrand
-- strict thread matches above, loose matches on Subject: below --
2024-03-28 8:46 remove follow_pfn v2 Christoph Hellwig
2024-03-28 8:46 ` [PATCH 3/3] mm: move follow_phys to arch/x86/mm/pat/memtype.c Christoph Hellwig
2024-03-28 9:34 ` David Hildenbrand
2024-03-28 15:25 ` Nathan Chancellor
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=ZgFRwVRPyLzLAr9r@gmail.com \
--to=mingo@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=dave.hansen@linux.intel.com \
--cc=fei1.li@intel.com \
--cc=hch@lst.de \
--cc=linux-mm@kvack.org \
--cc=luto@kernel.org \
--cc=peterz@infradead.org \
--cc=x86@kernel.org \
/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).