linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drivers/arch_numa: remove rebudant setup_per_cpu_areas()
@ 2021-03-09 10:21 Pingfan Liu
  2021-03-09 14:01 ` Will Deacon
  0 siblings, 1 reply; 3+ messages in thread
From: Pingfan Liu @ 2021-03-09 10:21 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: Pingfan Liu, Catalin Marinas, Will Deacon, Greg Kroah-Hartman,
	Rafael J. Wysocki, Atish Patra, linux-kernel

There are two identical implementations of setup_per_cpu_areas() in
mm/percpu.c and drivers/base/arch_numa.c.

Hence removing the one in arch_numa.c. And let arm64 drop
HAVE_SETUP_PER_CPU_AREA.

Signed-off-by: Pingfan Liu <kernelfans@gmail.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will@kernel.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: Atish Patra <atish.patra@wdc.com>
Cc: linux-kernel@vger.kernel.org
To: linux-arm-kernel@lists.infradead.org
---
 arch/arm64/Kconfig       |  4 ----
 drivers/base/arch_numa.c | 22 ----------------------
 2 files changed, 26 deletions(-)

diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index 1f212b47a48a..d4bf8be0c3d5 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -1022,10 +1022,6 @@ config USE_PERCPU_NUMA_NODE_ID
 	def_bool y
 	depends on NUMA
 
-config HAVE_SETUP_PER_CPU_AREA
-	def_bool y
-	depends on NUMA
-
 config NEED_PER_CPU_EMBED_FIRST_CHUNK
 	def_bool y
 	depends on NUMA
diff --git a/drivers/base/arch_numa.c b/drivers/base/arch_numa.c
index 4cc4e117727d..23e1e419a83d 100644
--- a/drivers/base/arch_numa.c
+++ b/drivers/base/arch_numa.c
@@ -167,28 +167,6 @@ static void __init pcpu_fc_free(void *ptr, size_t size)
 {
 	memblock_free_early(__pa(ptr), size);
 }
-
-void __init setup_per_cpu_areas(void)
-{
-	unsigned long delta;
-	unsigned int cpu;
-	int rc;
-
-	/*
-	 * Always reserve area for module percpu variables.  That's
-	 * what the legacy allocator did.
-	 */
-	rc = pcpu_embed_first_chunk(PERCPU_MODULE_RESERVE,
-				    PERCPU_DYNAMIC_RESERVE, PAGE_SIZE,
-				    pcpu_cpu_distance,
-				    pcpu_fc_alloc, pcpu_fc_free);
-	if (rc < 0)
-		panic("Failed to initialize percpu areas.");
-
-	delta = (unsigned long)pcpu_base_addr - (unsigned long)__per_cpu_start;
-	for_each_possible_cpu(cpu)
-		__per_cpu_offset[cpu] = delta + pcpu_unit_offsets[cpu];
-}
 #endif
 
 /**
-- 
2.29.2


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] drivers/arch_numa: remove rebudant setup_per_cpu_areas()
  2021-03-09 10:21 [PATCH] drivers/arch_numa: remove rebudant setup_per_cpu_areas() Pingfan Liu
@ 2021-03-09 14:01 ` Will Deacon
  2021-03-10  4:05   ` Pingfan Liu
  0 siblings, 1 reply; 3+ messages in thread
From: Will Deacon @ 2021-03-09 14:01 UTC (permalink / raw)
  To: Pingfan Liu
  Cc: linux-arm-kernel, Catalin Marinas, Greg Kroah-Hartman,
	Rafael J. Wysocki, Atish Patra, linux-kernel

[typo in subject "rebudant"]

On Tue, Mar 09, 2021 at 06:21:38PM +0800, Pingfan Liu wrote:
> There are two identical implementations of setup_per_cpu_areas() in
> mm/percpu.c and drivers/base/arch_numa.c.
> 
> Hence removing the one in arch_numa.c. And let arm64 drop
> HAVE_SETUP_PER_CPU_AREA.
> 
> Signed-off-by: Pingfan Liu <kernelfans@gmail.com>
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Cc: Will Deacon <will@kernel.org>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: "Rafael J. Wysocki" <rafael@kernel.org>
> Cc: Atish Patra <atish.patra@wdc.com>
> Cc: linux-kernel@vger.kernel.org
> To: linux-arm-kernel@lists.infradead.org
> ---
>  arch/arm64/Kconfig       |  4 ----
>  drivers/base/arch_numa.c | 22 ----------------------
>  2 files changed, 26 deletions(-)
> 
> diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
> index 1f212b47a48a..d4bf8be0c3d5 100644
> --- a/arch/arm64/Kconfig
> +++ b/arch/arm64/Kconfig
> @@ -1022,10 +1022,6 @@ config USE_PERCPU_NUMA_NODE_ID
>  	def_bool y
>  	depends on NUMA
>  
> -config HAVE_SETUP_PER_CPU_AREA
> -	def_bool y
> -	depends on NUMA
> -
>  config NEED_PER_CPU_EMBED_FIRST_CHUNK
>  	def_bool y
>  	depends on NUMA
> diff --git a/drivers/base/arch_numa.c b/drivers/base/arch_numa.c
> index 4cc4e117727d..23e1e419a83d 100644
> --- a/drivers/base/arch_numa.c
> +++ b/drivers/base/arch_numa.c
> @@ -167,28 +167,6 @@ static void __init pcpu_fc_free(void *ptr, size_t size)
>  {
>  	memblock_free_early(__pa(ptr), size);
>  }
> -
> -void __init setup_per_cpu_areas(void)
> -{
> -	unsigned long delta;
> -	unsigned int cpu;
> -	int rc;
> -
> -	/*
> -	 * Always reserve area for module percpu variables.  That's
> -	 * what the legacy allocator did.
> -	 */
> -	rc = pcpu_embed_first_chunk(PERCPU_MODULE_RESERVE,
> -				    PERCPU_DYNAMIC_RESERVE, PAGE_SIZE,
> -				    pcpu_cpu_distance,
> -				    pcpu_fc_alloc, pcpu_fc_free);

This doesn't look identical to the version in mm/percpu.c -- that one passes
NULL instead of 'pcpu_cpu_distance' and tries to allocate the pcpu memory on
the relevant NUMA nodes. In fact, if you could remove this function, you
could probably remove the whole HAVE_SETUP_PER_CPU_AREA block here as the
other functions are just used as helpers. So I'm not sure this is valid.

Will

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] drivers/arch_numa: remove rebudant setup_per_cpu_areas()
  2021-03-09 14:01 ` Will Deacon
@ 2021-03-10  4:05   ` Pingfan Liu
  0 siblings, 0 replies; 3+ messages in thread
From: Pingfan Liu @ 2021-03-10  4:05 UTC (permalink / raw)
  To: Will Deacon
  Cc: linux-arm-kernel, Catalin Marinas, Greg Kroah-Hartman,
	Rafael J. Wysocki, Atish Patra, LKML

On Tue, Mar 9, 2021 at 10:02 PM Will Deacon <will@kernel.org> wrote:
>
> [typo in subject "rebudant"]
>
> On Tue, Mar 09, 2021 at 06:21:38PM +0800, Pingfan Liu wrote:
> > There are two identical implementations of setup_per_cpu_areas() in
> > mm/percpu.c and drivers/base/arch_numa.c.
> >
> > Hence removing the one in arch_numa.c. And let arm64 drop
> > HAVE_SETUP_PER_CPU_AREA.
> >
> > Signed-off-by: Pingfan Liu <kernelfans@gmail.com>
> > Cc: Catalin Marinas <catalin.marinas@arm.com>
> > Cc: Will Deacon <will@kernel.org>
> > Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> > Cc: "Rafael J. Wysocki" <rafael@kernel.org>
> > Cc: Atish Patra <atish.patra@wdc.com>
> > Cc: linux-kernel@vger.kernel.org
> > To: linux-arm-kernel@lists.infradead.org
> > ---
> >  arch/arm64/Kconfig       |  4 ----
> >  drivers/base/arch_numa.c | 22 ----------------------
> >  2 files changed, 26 deletions(-)
> >
> > diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
> > index 1f212b47a48a..d4bf8be0c3d5 100644
> > --- a/arch/arm64/Kconfig
> > +++ b/arch/arm64/Kconfig
> > @@ -1022,10 +1022,6 @@ config USE_PERCPU_NUMA_NODE_ID
> >       def_bool y
> >       depends on NUMA
> >
> > -config HAVE_SETUP_PER_CPU_AREA
> > -     def_bool y
> > -     depends on NUMA
> > -
> >  config NEED_PER_CPU_EMBED_FIRST_CHUNK
> >       def_bool y
> >       depends on NUMA
> > diff --git a/drivers/base/arch_numa.c b/drivers/base/arch_numa.c
> > index 4cc4e117727d..23e1e419a83d 100644
> > --- a/drivers/base/arch_numa.c
> > +++ b/drivers/base/arch_numa.c
> > @@ -167,28 +167,6 @@ static void __init pcpu_fc_free(void *ptr, size_t size)
> >  {
> >       memblock_free_early(__pa(ptr), size);
> >  }
> > -
> > -void __init setup_per_cpu_areas(void)
> > -{
> > -     unsigned long delta;
> > -     unsigned int cpu;
> > -     int rc;
> > -
> > -     /*
> > -      * Always reserve area for module percpu variables.  That's
> > -      * what the legacy allocator did.
> > -      */
> > -     rc = pcpu_embed_first_chunk(PERCPU_MODULE_RESERVE,
> > -                                 PERCPU_DYNAMIC_RESERVE, PAGE_SIZE,
> > -                                 pcpu_cpu_distance,
> > -                                 pcpu_fc_alloc, pcpu_fc_free);
>
> This doesn't look identical to the version in mm/percpu.c -- that one passes
> NULL instead of 'pcpu_cpu_distance' and tries to allocate the pcpu memory on
> the relevant NUMA nodes. In fact, if you could remove this function, you
> could probably remove the whole HAVE_SETUP_PER_CPU_AREA block here as the
> other functions are just used as helpers. So I'm not sure this is valid.
>
You are right. I need to rethink about it to see whether these two
functions can be unified into one.

Thanks,
Pingfan

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-03-10  4:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-09 10:21 [PATCH] drivers/arch_numa: remove rebudant setup_per_cpu_areas() Pingfan Liu
2021-03-09 14:01 ` Will Deacon
2021-03-10  4:05   ` Pingfan Liu

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).