All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nathan Chancellor <nathan@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: Thu, 28 Mar 2024 08:25:58 -0700	[thread overview]
Message-ID: <20240328152558.GA2652500@dev-arch.thelio-3990X> (raw)
In-Reply-To: <20240328084629.2955393-4-hch@lst.de>

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@lst.de>
> ---
>  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>
 


  parent reply	other threads:[~2024-03-28 15:26 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-28  8:46 remove follow_pfn v2 Christoph Hellwig
2024-03-28  8:46 ` [PATCH 1/3] virt: acrn: stop using follow_pfn Christoph Hellwig
2024-03-28  8:46 ` [PATCH 2/3] mm: remove follow_pfn 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 [this message]
  -- strict thread matches above, loose matches on Subject: below --
2024-03-24 23:45 remove follow_pfn Christoph Hellwig
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
2024-03-25 10:36   ` David Hildenbrand

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=20240328152558.GA2652500@dev-arch.thelio-3990X \
    --to=nathan@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.