linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: chenqiwu <qiwuchen55@gmail.com>
To: John Hubbard <jhubbard@nvidia.com>
Cc: akpm@linux-foundation.org, linux-mm@kvack.org,
	chenqiwu <chenqiwu@xiaomi.com>
Subject: Re: [RESEND PATCH] mm/sparsemem: use wrapped macros instead of open-coding
Date: Wed, 11 Mar 2020 16:01:42 +0800	[thread overview]
Message-ID: <20200311080142.GA30917@cqw-OptiPlex-7050> (raw)
In-Reply-To: <a731692c-0a04-2926-a573-d49e4f9c2efe@nvidia.com>

On Tue, Mar 10, 2020 at 07:10:10PM -0700, John Hubbard wrote:
> On 3/6/20 2:19 AM, qiwuchen55@gmail.com wrote:
> > From: chenqiwu <chenqiwu@xiaomi.com>
> > 
> > Use wrapped macros instead of open-coding for better code
> > readability.
> > 
> > Signed-off-by: chenqiwu <chenqiwu@xiaomi.com>
> 
> 
> This breaks my x86 (64-bit) build:
> 
> mm/sparse.c: In function ‘check_usemap_section_nr’:
> mm/sparse.c:389:33: error: implicit declaration of function ‘virt_to_pfn’; did you mean ‘virt_to_phys’? [-Werror=implicit-function-declaration]
>   389 |  usemap_snr = pfn_to_section_nr(virt_to_pfn(usage));
>       |                                 ^~~~~~~~~~~
>       |                                 virt_to_phys
> 
> 
> ...and I think the reason is that the arch/x86/include/asm/page.h does not
> have virt_to_pfn(). For that reason, I'm concerned that the following fix, 
> which fixes up x86, may not completely correct for the patch.
> 
> Here's a compile-tested (only, and only on x86 64-bit) fix:
> 
> diff --git a/arch/x86/include/asm/page.h b/arch/x86/include/asm/page.h
> index 7555b48803a8..982bc76bf13c 100644
> --- a/arch/x86/include/asm/page.h
> +++ b/arch/x86/include/asm/page.h
> @@ -62,6 +62,9 @@ static inline void copy_user_page(void *to, void *from, unsigned long vaddr,
>  #define __boot_va(x)		__va(x)
>  #define __boot_pa(x)		__pa(x)
>  
> +#define virt_to_pfn(kaddr)	(__pa(kaddr) >> PAGE_SHIFT)
> +#define pfn_to_virt(pfn)	__va((pfn) << PAGE_SHIFT)
> +
>  /*
>   * virt_to_page(kaddr) returns a valid pointer if and only if
>   * virt_addr_valid(kaddr) returns true.
> 
> 
> thanks,
> -- 
> John Hubbard
> NVIDIA

Hi John,
I tested this patch only on arm64 build, not sure if any other build
breakings. But I think any architecture is worth to support virt_to_pfn()
API. Could you please send your compile-tested patch to x86 upstream?

Thanks
Qiwu


  reply	other threads:[~2020-03-11  8:01 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-06 10:19 qiwuchen55
2020-03-11  2:10 ` John Hubbard
2020-03-11  8:01   ` chenqiwu [this message]
2020-03-12  1:09     ` John Hubbard

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=20200311080142.GA30917@cqw-OptiPlex-7050 \
    --to=qiwuchen55@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=chenqiwu@xiaomi.com \
    --cc=jhubbard@nvidia.com \
    --cc=linux-mm@kvack.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