Re: [PATCH 3/3] mm: move follow_phys to arch/x86/mm/pat/memtype.c

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Christoph,

On Thu, Mar 28, 2024 at 09:46:29AM +0100, Christoph Hellwig wrote:
> follow_phys is only used by two callers in arch/x86/mm/pat/memtype.c.
> Move it there and hardcode the two arguments that get the same values
> passed by both callers.
> 
> Signed-off-by: Christoph Hellwig <hch@xxxxxx>
> ---
>  arch/x86/mm/pat/memtype.c | 23 +++++++++++++++++++++--
>  include/linux/mm.h        |  2 --
>  mm/memory.c               | 28 ----------------------------
>  3 files changed, 21 insertions(+), 32 deletions(-)
> 
> diff --git a/arch/x86/mm/pat/memtype.c b/arch/x86/mm/pat/memtype.c
> index 0d72183b5dd028..c64f07b0fc2099 100644
> --- a/arch/x86/mm/pat/memtype.c
> +++ b/arch/x86/mm/pat/memtype.c
> @@ -947,6 +947,25 @@ 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);

memtype.c needs to include highmem.h for highmem-internal.h, otherwise I
get a build failure (ARCH=i386 allmodconfig):

  In file included from include/linux/mm.h:30,
                   from include/linux/memblock.h:12,
                   from arch/x86/mm/pat/memtype.c:35:
  arch/x86/mm/pat/memtype.c: In function 'follow_phys':
  include/linux/pgtable.h:105:9: error: implicit declaration of function 'kunmap_local' [-Werror=implicit-function-declaration]
    105 |         kunmap_local((pte));    \
        |         ^~~~~~~~~~~~
  include/linux/mm.h:3014:9: note: in expansion of macro 'pte_unmap'
   3014 |         pte_unmap(pte);                                 \
        |         ^~~~~~~~~
  arch/x86/mm/pat/memtype.c:965:9: note: in expansion of macro 'pte_unmap_unlock'
    965 |         pte_unmap_unlock(ptep, ptl);
        |         ^~~~~~~~~~~~~~~~
  cc1: all warnings being treated as errors

Cheers,
Nathan

diff --git a/arch/x86/mm/pat/memtype.c b/arch/x86/mm/pat/memtype.c
index c64f07b0fc20..143d1e3d3fd2 100644
--- a/arch/x86/mm/pat/memtype.c
+++ b/arch/x86/mm/pat/memtype.c
@@ -39,6 +39,7 @@
 #include <linux/pfn_t.h>
 #include <linux/slab.h>
 #include <linux/mm.h>
+#include <linux/highmem.h>
 #include <linux/fs.h>
 #include <linux/rbtree.h>
 




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux