All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nicholas Piggin <npiggin@gmail.com>
To: Andrew Morton <akpm@linux-foundation.org>,
	Christoph Hellwig <hch@lst.de>
Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org,
	Peter Zijlstra <peterz@infradead.org>
Subject: Re: [PATCH 1/2] mm: move ioremap_page_range to vmalloc.c
Date: Thu, 26 Aug 2021 12:36:46 +1000	[thread overview]
Message-ID: <1629945172.9i2oy8ddvl.astroid@bobo.none> (raw)
In-Reply-To: <20210824091259.1324527-2-hch@lst.de>

Excerpts from Christoph Hellwig's message of August 24, 2021 7:12 pm:
> This keeps it together with the implementation, and to remove the
> vmap_range wrapper.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  include/linux/vmalloc.h |  3 ---
>  mm/Makefile             |  3 ++-
>  mm/ioremap.c            | 25 -------------------------
>  mm/vmalloc.c            | 22 +++++++++++++++++-----
>  4 files changed, 19 insertions(+), 34 deletions(-)
> 
> diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h
> index 2644425b6dce..671d402c3778 100644
> --- a/include/linux/vmalloc.h
> +++ b/include/linux/vmalloc.h
> @@ -225,9 +225,6 @@ static inline bool is_vm_area_hugepages(const void *addr)
>  }
>  
>  #ifdef CONFIG_MMU
> -int vmap_range(unsigned long addr, unsigned long end,
> -			phys_addr_t phys_addr, pgprot_t prot,
> -			unsigned int max_page_shift);
>  void vunmap_range(unsigned long addr, unsigned long end);
>  static inline void set_vm_flush_reset_perms(void *addr)
>  {
> diff --git a/mm/Makefile b/mm/Makefile
> index e3436741d539..0e0a5a6fe127 100644
> --- a/mm/Makefile
> +++ b/mm/Makefile
> @@ -38,7 +38,7 @@ mmu-y			:= nommu.o
>  mmu-$(CONFIG_MMU)	:= highmem.o memory.o mincore.o \
>  			   mlock.o mmap.o mmu_gather.o mprotect.o mremap.o \
>  			   msync.o page_vma_mapped.o pagewalk.o \
> -			   pgtable-generic.o rmap.o vmalloc.o ioremap.o
> +			   pgtable-generic.o rmap.o vmalloc.o
>  
>  
>  ifdef CONFIG_CROSS_MEMORY_ATTACH
> @@ -128,3 +128,4 @@ obj-$(CONFIG_PTDUMP_CORE) += ptdump.o
>  obj-$(CONFIG_PAGE_REPORTING) += page_reporting.o
>  obj-$(CONFIG_IO_MAPPING) += io-mapping.o
>  obj-$(CONFIG_HAVE_BOOTMEM_INFO_NODE) += bootmem_info.o
> +obj-$(CONFIG_GENERIC_IOREMAP) += ioremap.o

Nice cleanup.

> diff --git a/mm/ioremap.c b/mm/ioremap.c
> index 8ee0136f8cb0..5fe598ecd9b7 100644
> --- a/mm/ioremap.c
> +++ b/mm/ioremap.c
> @@ -8,33 +8,9 @@
>   */
>  #include <linux/vmalloc.h>
>  #include <linux/mm.h>
> -#include <linux/sched.h>
>  #include <linux/io.h>
>  #include <linux/export.h>
> -#include <asm/cacheflush.h>
>  
> -#include "pgalloc-track.h"
> -
> -#ifdef CONFIG_HAVE_ARCH_HUGE_VMAP
> -static unsigned int __ro_after_init iomap_max_page_shift = BITS_PER_LONG - 1;
> -
> -static int __init set_nohugeiomap(char *str)
> -{
> -	iomap_max_page_shift = PAGE_SHIFT;
> -	return 0;
> -}
> -early_param("nohugeiomap", set_nohugeiomap);
> -#else /* CONFIG_HAVE_ARCH_HUGE_VMAP */
> -static const unsigned int iomap_max_page_shift = PAGE_SHIFT;
> -#endif	/* CONFIG_HAVE_ARCH_HUGE_VMAP */
> -
> -int ioremap_page_range(unsigned long addr,
> -		       unsigned long end, phys_addr_t phys_addr, pgprot_t prot)
> -{
> -	return vmap_range(addr, end, phys_addr, prot, iomap_max_page_shift);
> -}
> -
> -#ifdef CONFIG_GENERIC_IOREMAP
>  void __iomem *ioremap_prot(phys_addr_t addr, size_t size, unsigned long prot)
>  {
>  	unsigned long offset, vaddr;
> @@ -71,4 +47,3 @@ void iounmap(volatile void __iomem *addr)
>  	vunmap((void *)((unsigned long)addr & PAGE_MASK));
>  }
>  EXPORT_SYMBOL(iounmap);
> -#endif /* CONFIG_GENERIC_IOREMAP */
> diff --git a/mm/vmalloc.c b/mm/vmalloc.c
> index d5cd52805149..e44983fb2d15 100644
> --- a/mm/vmalloc.c
> +++ b/mm/vmalloc.c
> @@ -44,6 +44,19 @@
>  #include "internal.h"
>  #include "pgalloc-track.h"
>  
> +#ifdef CONFIG_HAVE_ARCH_HUGE_VMAP
> +static unsigned int __ro_after_init ioremap_max_page_shift = BITS_PER_LONG - 1;
> +
> +static int __init set_nohugeiomap(char *str)
> +{
> +	ioremap_max_page_shift = PAGE_SHIFT;
> +	return 0;
> +}
> +early_param("nohugeiomap", set_nohugeiomap);
> +#else /* CONFIG_HAVE_ARCH_HUGE_VMAP */
> +static const unsigned int ioremap_max_page_shift = PAGE_SHIFT;
> +#endif	/* CONFIG_HAVE_ARCH_HUGE_VMAP */
> +
>  #ifdef CONFIG_HAVE_ARCH_HUGE_VMALLOC
>  static bool __ro_after_init vmap_allow_huge = true;
>  
> @@ -298,15 +311,14 @@ static int vmap_range_noflush(unsigned long addr, unsigned long end,
>  	return err;
>  }
>  
> -int vmap_range(unsigned long addr, unsigned long end,
> -			phys_addr_t phys_addr, pgprot_t prot,
> -			unsigned int max_page_shift)
> +int ioremap_page_range(unsigned long addr, unsigned long end,
> +		phys_addr_t phys_addr, pgprot_t prot)
>  {
>  	int err;
>  
> -	err = vmap_range_noflush(addr, end, phys_addr, prot, max_page_shift);
> +	err = vmap_range_noflush(addr, end, phys_addr, prot,
> +				 ioremap_max_page_shift);
>  	flush_cache_vmap(addr, end);
> -
>  	return err;
>  }

I guess this is fine. I wanted to have an API that can be used to remap 
memory without struct page and that is not MMIO but since you removed 
the caller it could come back if other things make use of it.

Reviewed-by: Nicholas Piggin <npiggin@gmail.com>

Thanks,
Nick

  parent reply	other threads:[~2021-08-26  2:36 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-24  9:12 small ioremap cleanups Christoph Hellwig
2021-08-24  9:12 ` [PATCH 1/2] mm: move ioremap_page_range to vmalloc.c Christoph Hellwig
2021-08-24 19:51   ` kernel test robot
2021-08-24 19:51     ` kernel test robot
2021-08-26  2:36   ` Nicholas Piggin [this message]
2021-08-24  9:12 ` [PATCH 2/2] mm: don't allow executable ioremap mappings Christoph Hellwig
2021-08-26  2:46   ` Nicholas Piggin
2021-08-26  5:37     ` Christoph Hellwig

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=1629945172.9i2oy8ddvl.astroid@bobo.none \
    --to=npiggin@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=hch@lst.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=peterz@infradead.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.