diff mbox series

arm: use SPARSMEM_STATIC when SPARSEMEM is enabled (Was: [PATCH 1/2] ARM: Remove redundant ARCH_SPARSEMEM_DEFAULT setting)

Message ID 20200507200859.GF683243@linux.ibm.com (mailing list archive)
State Mainlined
Commit 0697e5e06ea0d96e2d1508104ff3b13e4dddc4bb
Headers show
Series arm: use SPARSMEM_STATIC when SPARSEMEM is enabled (Was: [PATCH 1/2] ARM: Remove redundant ARCH_SPARSEMEM_DEFAULT setting) | expand

Commit Message

Mike Rapoport May 7, 2020, 8:08 p.m. UTC
On Thu, May 07, 2020 at 11:30:39AM +0100, Russell King - ARM Linux admin wrote:
> On Wed, May 06, 2020 at 04:50:08PM -0700, Florian Fainelli wrote:
> > From: Kevin Cernekee <cernekee@gmail.com>
> > 
> > If ARCH_SPARSEMEM_ENABLE=y and ARCH_{FLATMEM,DISCONTIGMEM}_ENABLE=n,
> > then the logic in mm/Kconfig already makes CONFIG_SPARSEMEM the only
> > choice.  This is true for all of the existing ARM users of
> > ARCH_SPARSEMEM_ENABLE.
> > 
> > Forcing ARCH_SPARSEMEM_DEFAULT=y if ARCH_SPARSEMEM_ENABLE=y prevents
> > us from ever defaulting to FLATMEM, so we should remove this setting.
> 
> No explanation why that is desirable.
> 
> > -config ARCH_SPARSEMEM_DEFAULT
> > -	def_bool ARCH_SPARSEMEM_ENABLE
> > -
> 
> What this basically says is ARCH_SPARSEMEM_ENABLE=ARCH_SPARSEMEM_DEFAULT,
> which is exactly what we want for the non-multiplatform boards that
> select ARCH_SPARSEMEM_ENABLE - we _want_ them to default to sparsemem
> because that is what the platform requires.
>
> For example, with RiscPC, which selects ARCH_SPARSEMEM_ENABLE, we have
> four banks of memory at 0x10000000, 0x14000000, 0x18000000 and
> 0x1c000000.  These correspond with the two memory slots - the first two
> for the first slot, and the second two for the second slot.  Each slot
> has two banks.  The size of each memory bank depends on the size of the
> module.

Out of curiosity I've run 

	make ARCH=arm rpc_defconfig
	grep SPARSEMEM .config

and I was surprised to find out that it has

	CONFIG_SPARSEMEM_EXTREME=y

Which would waste several kilibytes of memory for nothing.
Here is the fix:

From 7097c114226b5b1b2fc6bb605bf0d7eae601cc7f Mon Sep 17 00:00:00 2001
From: Mike Rapoport <rppt@linux.ibm.com>
Date: Thu, 7 May 2020 22:39:12 +0300
Subject: [PATCH] arm: use SPARSMEM_STATIC when SPARSEMEM is enabled

The commit 3e347261a80b5 ("[PATCH] sparsemem extreme implementation")
made SPARSMEM_EXTREME the default option for configurations that enable
SPARSEMEM.

For ARM systems with handful of memory banks SPARSEMEM_EXTREME is an
overkill.

Ensure that SPARSMEM_STATIC is enabled in the configurations that use
SPARSEMEM.

Fixes: 3e347261a80b5 ("[PATCH] sparsemem extreme implementation")
Signed-off-by: Mike Rapoport <rppt@linux.ibm.com>
---
 arch/arm/Kconfig | 1 +
 1 file changed, 1 insertion(+)

Comments

Florian Fainelli May 8, 2020, 8:20 p.m. UTC | #1
On 5/7/2020 1:08 PM, Mike Rapoport wrote:
> On Thu, May 07, 2020 at 11:30:39AM +0100, Russell King - ARM Linux admin wrote:
>> On Wed, May 06, 2020 at 04:50:08PM -0700, Florian Fainelli wrote:
>>> From: Kevin Cernekee <cernekee@gmail.com>
>>>
>>> If ARCH_SPARSEMEM_ENABLE=y and ARCH_{FLATMEM,DISCONTIGMEM}_ENABLE=n,
>>> then the logic in mm/Kconfig already makes CONFIG_SPARSEMEM the only
>>> choice.  This is true for all of the existing ARM users of
>>> ARCH_SPARSEMEM_ENABLE.
>>>
>>> Forcing ARCH_SPARSEMEM_DEFAULT=y if ARCH_SPARSEMEM_ENABLE=y prevents
>>> us from ever defaulting to FLATMEM, so we should remove this setting.
>>
>> No explanation why that is desirable.
>>
>>> -config ARCH_SPARSEMEM_DEFAULT
>>> -	def_bool ARCH_SPARSEMEM_ENABLE
>>> -
>>
>> What this basically says is ARCH_SPARSEMEM_ENABLE=ARCH_SPARSEMEM_DEFAULT,
>> which is exactly what we want for the non-multiplatform boards that
>> select ARCH_SPARSEMEM_ENABLE - we _want_ them to default to sparsemem
>> because that is what the platform requires.
>>
>> For example, with RiscPC, which selects ARCH_SPARSEMEM_ENABLE, we have
>> four banks of memory at 0x10000000, 0x14000000, 0x18000000 and
>> 0x1c000000.  These correspond with the two memory slots - the first two
>> for the first slot, and the second two for the second slot.  Each slot
>> has two banks.  The size of each memory bank depends on the size of the
>> module.
> 
> Out of curiosity I've run 
> 
> 	make ARCH=arm rpc_defconfig
> 	grep SPARSEMEM .config
> 
> and I was surprised to find out that it has
> 
> 	CONFIG_SPARSEMEM_EXTREME=y
> 
> Which would waste several kilibytes of memory for nothing.
> Here is the fix:
> 
> From 7097c114226b5b1b2fc6bb605bf0d7eae601cc7f Mon Sep 17 00:00:00 2001
> From: Mike Rapoport <rppt@linux.ibm.com>
> Date: Thu, 7 May 2020 22:39:12 +0300
> Subject: [PATCH] arm: use SPARSMEM_STATIC when SPARSEMEM is enabled
> 
> The commit 3e347261a80b5 ("[PATCH] sparsemem extreme implementation")
> made SPARSMEM_EXTREME the default option for configurations that enable
> SPARSEMEM.
> 
> For ARM systems with handful of memory banks SPARSEMEM_EXTREME is an
> overkill.
> 
> Ensure that SPARSMEM_STATIC is enabled in the configurations that use
> SPARSEMEM.
> 
> Fixes: 3e347261a80b5 ("[PATCH] sparsemem extreme implementation")
> Signed-off-by: Mike Rapoport <rppt@linux.ibm.com>

Acked-by: Florian Fainelli <f.fainelli@gmail.com>
diff mbox series

Patch

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 66a04f6f4775..c88a48d622fc 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -1517,6 +1517,7 @@  config ARCH_HAS_HOLES_MEMORYMODEL
 
 config ARCH_SPARSEMEM_ENABLE
 	bool
+	select SPARSEMEM_STATIC
 
 config ARCH_SPARSEMEM_DEFAULT
 	def_bool ARCH_SPARSEMEM_ENABLE