Skip to contentSkip to conversation

Weirdness in __alloc_bootmem_node_high

PATCH Michal Hocko 5 participants 21 messages Apr 17, 2012 – Apr 27, 2012

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Hi,
I just come across the following condition in __alloc_bootmem_node_high which I have hard times to understand. I guess it is a bug and we need something like the following. But, to be honest, I have no idea why we care about those 128MB above MAX_DMA32_PFN.

---
 mm/bootmem.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/bootmem.c +1 -1
index 0131170..5adb072 100644
@@ -737,7 +737,7 @@ void * __init __alloc_bootmem_node_high(pg_data_t *pgdat, unsigned long size,
 	/* update goal according ...MAX_DMA32_PFN */
 	end_pfn = pgdat->node_start_pfn + pgdat->node_spanned_pages;
 
-	if (end_pfn > MAX_DMA32_PFN + (128 >> (20 - PAGE_SHIFT)) &&
+	if (end_pfn > MAX_DMA32_PFN + (128 << (20 - PAGE_SHIFT)) &&
 	    (goal >> PAGE_SHIFT) < MAX_DMA32_PFN) {
 		void *ptr;
 		unsigned long new_goal;
Signature · 16 lines
1.7.9.5

-- 
Michal Hocko
SUSE Labs
SUSE LINUX s.r.o.
Lihovarska 1060/12
190 00 Praha 9    
Czech Republic

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#1 lore raw
Quoted 14 lines · Michal Hocko

Hi,
I just come across the following condition in __alloc_bootmem_node_high which I have hard times to understand. I guess it is a bug and we need something like the following. But, to be honest, I have no idea why we care about those 128MB above MAX_DMA32_PFN.
---
 mm/bootmem.c |    2 +-

 1 file changed, 1 insertion(+), 1 deletion(-)
mm/bootmem.c +0 -0
index 0131170..5adb072 100644

mm/bootmem.c void * __init __alloc_bootmem_node_high(pg_data_t *pgdat, unsigned long size,

Quoted 9 lines
mm/bootmem.c +1 -2
@@ -737,7 +737,7 @@ void * __init __alloc_bootmem_node_high(pg_data_t *pgdat, unsigned long size,
        /* update goal according ...MAX_DMA32_PFN */
        end_pfn = pgdat->node_start_pfn + pgdat->node_spanned_pages;
 
-       if (end_pfn > MAX_DMA32_PFN + (128 >> (20 - PAGE_SHIFT)) &&
+       if (end_pfn > MAX_DMA32_PFN + (128 << (20 - PAGE_SHIFT)) &&
            (goal >> PAGE_SHIFT) < MAX_DMA32_PFN) {
                void *ptr;
                unsigned long new_goal;
--

We are not using bootmem with x86 now, so could remove those workaround now.

Thanks

Yinghai

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#2 lore raw
Quoted 18 lines · Yinghai Lu
Quoted 17 lines · Michal Hocko

Hi,
I just come across the following condition in __alloc_bootmem_node_high which I have hard times to understand. I guess it is a bug and we need something like the following. But, to be honest, I have no idea why we care about those 128MB above MAX_DMA32_PFN.

---
 mm/bootmem.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/bootmem.c +0 -0
index 0131170..5adb072 100644
@@ -737,7 +737,7 @@ void * __init __alloc_bootmem_node_high(pg_data_t *pgdat, unsigned long size,
       /* update goal according ...MAX_DMA32_PFN */
       end_pfn = pgdat->node_start_pfn + pgdat->node_spanned_pages;
 
Quoted 8 lines

mm/bootmem.c void * __init __alloc_bootmem_node_high(pg_data_t *pgdat, unsigned long size,

Quoted 6 lines
mm/bootmem.c +1 -2
-       if (end_pfn > MAX_DMA32_PFN + (128 >> (20 - PAGE_SHIFT)) &&
+       if (end_pfn > MAX_DMA32_PFN + (128 << (20 - PAGE_SHIFT)) &&
           (goal >> PAGE_SHIFT) < MAX_DMA32_PFN) {
               void *ptr;
               unsigned long new_goal;
--

We are not using bootmem with x86 now, so could remove those workaround now.

Could you be more specific about what the workaround is used for?

Thanks

Quoted 11 lines

Thanks

Yinghai

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

Signature · 13 lines
Michal Hocko
SUSE Labs
SUSE LINUX s.r.o.
Lihovarska 1060/12
190 00 Praha 9    
Czech Republic

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#3 lore raw
Quoted 5 lines · Michal Hocko
Quoted 2 lines · Yinghai Lu

We are not using bootmem with x86 now, so could remove those workaround now.

Could you be more specific about what the workaround is used for?

Don't bootmem allocating too low to use up all low memory. like for system with lots of memory for sparse vmemmap.

when nobootmem.c is used, __alloc_bootmem_node_high is the same as __alloc_bootmem_node.

Thanks

Yinghai

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#4 lore raw
Quoted 5 lines · Yinghai Lu
Quoted 4 lines · Michal Hocko
Quoted 2 lines · Yinghai Lu

We are not using bootmem with x86 now, so could remove those workaround now.

Quoted 7 lines
Quoted 1 line

Could you be more specific about what the workaround is used for?

Don't bootmem allocating too low to use up all low memory. like for system with lots of memory for sparse vmemmap.

when nobootmem.c is used, __alloc_bootmem_node_high is the same as __alloc_bootmem_node.

It would be nice if someone familiar with the memblock/bootmem internals could cleans up the leftovers from the migration of x86 to memblock / nobootmem.

This would be less to be confused about when other migrate to use memblock.

Sam

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#5 lore raw

Hello, Sam.

Quoted 6 lines · Sam Ravnborg

It would be nice if someone familiar with the memblock/bootmem internals could cleans up the leftovers from the migration of x86 to memblock / nobootmem.

This would be less to be confused about when other migrate to use memblock.

I can't remember the details now (my memory sucks big time) but there were some obstacles and I decided to defer cleaning up. I'm kinda overwhelmed in other areas so if anyone is interested in cleaning up, I'll be happy to help. If not, I'll try to get to it.

Thanks.

Signature · 8 lines
tejun

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#6 lore raw
In reply to Yinghai Lu
Quoted 9 lines · Yinghai Lu
Quoted 5 lines · Michal Hocko
Quoted 2 lines · Yinghai Lu

We are not using bootmem with x86 now, so could remove those workaround now.

Could you be more specific about what the workaround is used for?

Don't bootmem allocating too low to use up all low memory. like for system with lots of memory for sparse vmemmap.

OK I see. Thanks for clarification.
I guess it doesn't make much sense to fix this particular thing now and rather let it to a bigger clean up. If people think otherwise I can send a patch though.

Quoted 14 lines

when nobootmem.c is used, __alloc_bootmem_node_high is the same as __alloc_bootmem_node.

Thanks

Yinghai

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

Signature · 13 lines
Michal Hocko
SUSE Labs
SUSE LINUX s.r.o.
Lihovarska 1060/12
190 00 Praha 9    
Czech Republic

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#7 lore raw
In reply to Michal Hocko
Quoted 14 lines · Michal Hocko

Hi,
I just come across the following condition in __alloc_bootmem_node_high which I have hard times to understand. I guess it is a bug and we need something like the following. But, to be honest, I have no idea why we care about those 128MB above MAX_DMA32_PFN.

---
 mm/bootmem.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/bootmem.c +0 -0
index 0131170..5adb072 100644

mm/bootmem.c void * __init __alloc_bootmem_node_high(pg_data_t *pgdat, unsigned long size, · line 743

Quoted 8 lines
mm/bootmem.c +1 -1
@@ -737,7 +737,7 @@ void * __init __alloc_bootmem_node_high(pg_data_t *pgdat, unsigned long size,
 	/* update goal according ...MAX_DMA32_PFN */
 	end_pfn = pgdat->node_start_pfn + pgdat->node_spanned_pages;
 
-	if (end_pfn > MAX_DMA32_PFN + (128 >> (20 - PAGE_SHIFT)) &&
+	if (end_pfn > MAX_DMA32_PFN + (128 << (20 - PAGE_SHIFT)) &&
 	    (goal >> PAGE_SHIFT) < MAX_DMA32_PFN) {
 		void *ptr;
 		unsigned long new_goal;

Regardless of x86 not using it, this is a bug fix and this code path seems to be used by mips at least. Michal, can you please post proper signed-off patch? The code is simply trying to use memory above DMA32 limit if there seems to be enough space (128M) to avoid unnecessarily using DMA32 memory.

Thanks.

Signature · 8 lines
tejun

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#8 lore raw
Quoted 18 lines · Tejun Heo
Quoted 17 lines · Michal Hocko

Hi,
I just come across the following condition in __alloc_bootmem_node_high which I have hard times to understand. I guess it is a bug and we need something like the following. But, to be honest, I have no idea why we care about those 128MB above MAX_DMA32_PFN.

---
 mm/bootmem.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/bootmem.c +0 -0
index 0131170..5adb072 100644
@@ -737,7 +737,7 @@ void * __init __alloc_bootmem_node_high(pg_data_t *pgdat, unsigned long size,
 	/* update goal according ...MAX_DMA32_PFN */
 	end_pfn = pgdat->node_start_pfn + pgdat->node_spanned_pages;
 
Quoted 8 lines

mm/bootmem.c void * __init __alloc_bootmem_node_high(pg_data_t *pgdat, unsigned long size, · line 743

Quoted 5 lines
mm/bootmem.c +1 -1
-	if (end_pfn > MAX_DMA32_PFN + (128 >> (20 - PAGE_SHIFT)) &&
+	if (end_pfn > MAX_DMA32_PFN + (128 << (20 - PAGE_SHIFT)) &&
 	    (goal >> PAGE_SHIFT) < MAX_DMA32_PFN) {
 		void *ptr;
 		unsigned long new_goal;

Regardless of x86 not using it, this is a bug fix and this code path seems to be used by mips at least.

I took a quick look at this. __alloc_bootmem_node_high() is used in mm/sparse.c - but only if SPARSEMEM_VMEMMAP is enabled.

mips has this:

config ARCH_SPARSEMEM_ENABLE
bool
select SPARSEMEM_STATIC

So SPARSEMEM_VMEMMAP is not enabled.

__alloc_bootmem_node_high() is used in mm/sparse-vmemmap.c which also depends on CONFIG_SPARSEMEM_VMEMMAP.

So I really do not see the logic in __alloc_bootmem_node_high() being used anymore and it can be replaced by __alloc_bootmem_node()

Sam

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#9 lore raw
Quoted 28 lines · Sam Ravnborg
Quoted 18 lines · Tejun Heo
Quoted 17 lines · Michal Hocko

Hi,
I just come across the following condition in __alloc_bootmem_node_high which I have hard times to understand. I guess it is a bug and we need something like the following. But, to be honest, I have no idea why we care about those 128MB above MAX_DMA32_PFN.

---
 mm/bootmem.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/bootmem.c +0 -0
index 0131170..5adb072 100644
@@ -737,7 +737,7 @@ void * __init __alloc_bootmem_node_high(pg_data_t *pgdat, unsigned long size,
 	/* update goal according ...MAX_DMA32_PFN */
 	end_pfn = pgdat->node_start_pfn + pgdat->node_spanned_pages;
 
Quoted 8 lines

mm/bootmem.c void * __init __alloc_bootmem_node_high(pg_data_t *pgdat, unsigned long size, · line 743

Quoted 5 lines
mm/bootmem.c +1 -1
-	if (end_pfn > MAX_DMA32_PFN + (128 >> (20 - PAGE_SHIFT)) &&
+	if (end_pfn > MAX_DMA32_PFN + (128 << (20 - PAGE_SHIFT)) &&
 	    (goal >> PAGE_SHIFT) < MAX_DMA32_PFN) {
 		void *ptr;
 		unsigned long new_goal;

Regardless of x86 not using it, this is a bug fix and this code path seems to be used by mips at least.

Quoted 3 lines

I took a quick look at this. __alloc_bootmem_node_high() is used in mm/sparse.c - but only if SPARSEMEM_VMEMMAP is enabled.

This is what I can see in the current (Linus) git:
./arch/sparc/Kconfig: select SPARSEMEM_VMEMMAP_ENABLE
./arch/powerpc/Kconfig: select SPARSEMEM_VMEMMAP_ENABLE

./arch/ia64/Kconfig:    select SPARSEMEM_VMEMMAP_ENABLE
./arch/s390/Kconfig:    select SPARSEMEM_VMEMMAP_ENABLE
./arch/s390/Kconfig:    select SPARSEMEM_VMEMMAP
./arch/x86/Kconfig:     select SPARSEMEM_VMEMMAP_ENABLE if X86_64

So there are more arches which enable SPARSEMEM_VMEMMAP so the function is used. Or am I missing something?

Signature · 13 lines
Michal Hocko
SUSE Labs
SUSE LINUX s.r.o.
Lihovarska 1060/12
190 00 Praha 9    
Czech Republic

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#12 lore raw
In reply to Sam Ravnborg
Quoted 11 lines · Sam Ravnborg

I took a quick look at this. __alloc_bootmem_node_high() is used in mm/sparse.c - but only if SPARSEMEM_VMEMMAP is enabled.

mips has this:

config ARCH_SPARSEMEM_ENABLE
       bool
       select SPARSEMEM_STATIC

Quoted 8 lines

So SPARSEMEM_VMEMMAP is not enabled.

__alloc_bootmem_node_high() is used in mm/sparse-vmemmap.c which also depends on CONFIG_SPARSEMEM_VMEMMAP.

So I really do not see the logic in __alloc_bootmem_node_high() being used anymore and it can be replaced by __alloc_bootmem_node()

Yes, you are right. __alloc_bootmem_node_high could be removed.

BTW, x86 is still the only one that use NO_BOOTMEM.

Are you working on making sparc to use NO_BOOTMEM?

Yinghai

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#10 lore raw
In reply to Michal Hocko
Quoted 10 lines · Michal Hocko

This is what I can see in the current (Linus) git:
./arch/sparc/Kconfig:   select SPARSEMEM_VMEMMAP_ENABLE ./arch/powerpc/Kconfig: select SPARSEMEM_VMEMMAP_ENABLE ./arch/ia64/Kconfig:    select SPARSEMEM_VMEMMAP_ENABLE ./arch/s390/Kconfig:    select SPARSEMEM_VMEMMAP_ENABLE ./arch/s390/Kconfig:    select SPARSEMEM_VMEMMAP ./arch/x86/Kconfig:     select SPARSEMEM_VMEMMAP_ENABLE if X86_64

So there are more arches which enable SPARSEMEM_VMEMMAP so the function is used. Or am I missing something?

MAX_DMA32_PFN is not defined for them.

I was think only x86 have that define. Actually mips have that defined too.

Yinghai

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#11 lore raw
Quoted 9 lines · Yinghai Lu
Quoted 8 lines · Michal Hocko

This is what I can see in the current (Linus) git:
./arch/sparc/Kconfig: select SPARSEMEM_VMEMMAP_ENABLE
./arch/powerpc/Kconfig: select SPARSEMEM_VMEMMAP_ENABLE

./arch/ia64/Kconfig:    select SPARSEMEM_VMEMMAP_ENABLE
./arch/s390/Kconfig:    select SPARSEMEM_VMEMMAP_ENABLE
./arch/s390/Kconfig:    select SPARSEMEM_VMEMMAP
./arch/x86/Kconfig:     select SPARSEMEM_VMEMMAP_ENABLE if X86_64
Quoted 4 lines
Quoted 2 lines

So there are more arches which enable SPARSEMEM_VMEMMAP so the function is used. Or am I missing something?

MAX_DMA32_PFN is not defined for them.

Ahh, you are right except that it is defined for x86 but that one uses nobootmem. I missed that point.

Thanks

Signature · 13 lines
Michal Hocko
SUSE Labs
SUSE LINUX s.r.o.
Lihovarska 1060/12
190 00 Praha 9    
Czech Republic

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#13 lore raw
In reply to Yinghai Lu
Quoted 18 lines · Yinghai Lu
Quoted 17 lines · Sam Ravnborg

I took a quick look at this. __alloc_bootmem_node_high() is used in mm/sparse.c - but only if SPARSEMEM_VMEMMAP is enabled.

mips has this:

config ARCH_SPARSEMEM_ENABLE
bool
select SPARSEMEM_STATIC

So SPARSEMEM_VMEMMAP is not enabled.

__alloc_bootmem_node_high() is used in mm/sparse-vmemmap.c which also depends on CONFIG_SPARSEMEM_VMEMMAP.

Quoted 8 lines
Quoted 2 lines

So I really do not see the logic in __alloc_bootmem_node_high() being used anymore and it can be replaced by __alloc_bootmem_node()

Yes, you are right. __alloc_bootmem_node_high could be removed.

BTW, x86 is still the only one that use NO_BOOTMEM.

Are you working on making sparc to use NO_BOOTMEM?

For now I am trying to convert sparc32 to
use memblock and NO_BOOTMEM in one step.

I have it almost finished - except that it does not work :-( We have limitations in what area we can allocate very early, and here I had to use the alloc_bootmem_low() variant. I had preferred a variant that allowed me to allocate bottom-up in this case.

For now I assume something is fishy in my code where I hand over memory to the buddyallocator.
But before posting anything I need time to go through my code and divide it up in smaller patches.

There is so far no changes to nobootmem / memblock code.

I will most likely convert sparc64 to NO_BOOTMEM next, if it looks reasonable simple that is.
But first step is to get sparc32 working.

Sam

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

maintainer
#14 lore raw

From: Sam Ravnborg <[email protected]>
Date: Fri, 20 Apr 2012 21:43:09 +0200

Quoted 5 lines

I have it almost finished - except that it does not work :-( We have limitations in what area we can allocate very early, and here I had to use the alloc_bootmem_low() variant. I had preferred a variant that allowed me to allocate bottom-up in this case.

I think you're going to have to bear down and map all of linear kernel mappings before you start using the bootmem code rather than afterwards.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#15 lore raw
Quoted 9 lines · David Miller

From: Sam Ravnborg <[email protected]>
Date: Fri, 20 Apr 2012 21:43:09 +0200

Quoted 5 lines

I have it almost finished - except that it does not work :-( We have limitations in what area we can allocate very early, and here I had to use the alloc_bootmem_low() variant. I had preferred a variant that allowed me to allocate bottom-up in this case.

Quoted 3 lines

I think you're going to have to bear down and map all of linear kernel mappings before you start using the bootmem code rather than afterwards.

Thanks - I will try to do so.
But I must admit I do not (yet) see any big difference in the approach before/after.

I digged up an old todo regarding final link of vmlinux. Will look at this and then re-visit memblock at sparc32.

Sam

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

maintainer
#16 lore raw

So here is a sparc64 conversion to NO_BOOTMEM.

Critically, I had to fix __alloc_bootmem_node to do what it promised to do. Which is retry the allocation without the goal if doing so with the goal fails.

Otherwise all bootmem allocations with goal set to __pa(MAX_DMA_ADDRESS) fail on sparc64, because we set that to ~0 so effectively all such allocations evaluate roughly to "goal=~0, limit=~0" which can never succeed.

arch/sparc/Kconfig +3 -0
index db4e821..3763302 100644
@@ -109,6 +109,9 @@ config NEED_PER_CPU_EMBED_FIRST_CHUNK
 config NEED_PER_CPU_PAGE_FIRST_CHUNK
 	def_bool y if SPARC64
 
+config NO_BOOTMEM
+	def_bool y if SPARC64
+
 config MMU
 	bool
 	default y
arch/sparc/mm/init_64.c +7 -84

138 lines not on this page · raw message

mm/nobootmem.c +8 -2
index 24f0fc1..e53bb8a 100644
@@ -298,13 +298,19 @@ void * __init __alloc_bootmem_node(pg_data_t *pgdat, unsigned long size,
 	if (WARN_ON_ONCE(slab_is_available()))
 		return kzalloc_node(size, GFP_NOWAIT, pgdat->node_id);
 
+again:
 	ptr = __alloc_memory_core_early(pgdat->node_id, size, align,
 					 goal, -1ULL);
 	if (ptr)
 		return ptr;
 
-	return __alloc_memory_core_early(MAX_NUMNODES, size, align,
-					 goal, -1ULL);
+	ptr = __alloc_memory_core_early(MAX_NUMNODES, size, align,
+					goal, -1ULL);
+	if (!ptr && goal) {
+		goal = 0;
+		goto again;
+	}
+	return ptr;
 }
 
 void * __init __alloc_bootmem_node_high(pg_data_t *pgdat, unsigned long size,

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#17 lore raw
Quoted 2 lines · David Miller

So here is a sparc64 conversion to NO_BOOTMEM.

Great!

I looked briefly through the patch - no comments.
I will take a more carefull look tonight.

Sam

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#18 lore raw
In reply to David Miller
Quoted 17 lines · David Miller

So here is a sparc64 conversion to NO_BOOTMEM.

Critically, I had to fix __alloc_bootmem_node to do what it promised to do. Which is retry the allocation without the goal if doing so with the goal fails.

Otherwise all bootmem allocations with goal set to __pa(MAX_DMA_ADDRESS) fail on sparc64, because we set that to ~0 so effectively all such allocations evaluate roughly to "goal=~0, limit=~0" which can never succeed.

arch/sparc/Kconfig +0 -0
index db4e821..3763302 100644

arch/sparc/Kconfig config NEED_PER_CPU_EMBED_FIRST_CHUNK · line 113

Quoted 5 lines
arch/sparc/Kconfig +2 -0
@@ -109,6 +109,9 @@ config NEED_PER_CPU_EMBED_FIRST_CHUNK
 config NEED_PER_CPU_PAGE_FIRST_CHUNK
 	def_bool y if SPARC64
 
+config NO_BOOTMEM
+	def_bool y if SPARC64

mm/Kconfig define NO_BOOTMEM so you can just add a "select NO_BOOTMEM" to SPARC64.

Sam

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

maintainer
#19 lore raw

From: Sam Ravnborg <[email protected]>
Date: Tue, 24 Apr 2012 08:32:36 +0200

Quoted 9 lines · David Miller
Quoted 8 lines
arch/sparc/Kconfig +0 -0
index db4e821..3763302 100644
@@ -109,6 +109,9 @@ config NEED_PER_CPU_EMBED_FIRST_CHUNK
 config NEED_PER_CPU_PAGE_FIRST_CHUNK
 	def_bool y if SPARC64
 
Quoted 5 lines

arch/sparc/Kconfig config NEED_PER_CPU_EMBED_FIRST_CHUNK · line 113

Quoted 2 lines
arch/sparc/Kconfig +2 -0
+config NO_BOOTMEM
+	def_bool y if SPARC64

mm/Kconfig define NO_BOOTMEM so you can just add a "select NO_BOOTMEM" to SPARC64.

I was merely following the lead on x86 :-) but yes it should probably be a select.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

maintainer
#20 lore raw

From: David Miller <[email protected]>
Date: Tue, 24 Apr 2012 03:00:50 -0400 (EDT)

Quoted 12 lines

From: Sam Ravnborg <[email protected]>
Date: Tue, 24 Apr 2012 08:32:36 +0200

Quoted 9 lines · David Miller
Quoted 8 lines
arch/sparc/Kconfig +0 -0
index db4e821..3763302 100644
@@ -109,6 +109,9 @@ config NEED_PER_CPU_EMBED_FIRST_CHUNK
 config NEED_PER_CPU_PAGE_FIRST_CHUNK
 	def_bool y if SPARC64
 
Quoted 8 lines
Quoted 5 lines

arch/sparc/Kconfig config NEED_PER_CPU_EMBED_FIRST_CHUNK · line 113

Quoted 2 lines
arch/sparc/Kconfig +2 -0
+config NO_BOOTMEM
+	def_bool y if SPARC64

mm/Kconfig define NO_BOOTMEM so you can just add a "select NO_BOOTMEM" to SPARC64.

I was merely following the lead on x86 :-) but yes it should probably be a select.

So I merged mainline into sparc-next to get the mm/nobootmem.c fix, and then added in the sparc64 NO_BOOTMEM conversion.

Just FYI.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>