Skip to contentSkip to conversation

mm: add a nopanic option for low bootmem

PATCH In review Jon Mason 3 participants 5 messages Apr 24, 2006 – Apr 26, 2006 Memory management

lore
Share & tools
lore

Jon Mason

author
#0 lore raw

PATCH 1/1 mm: add a nopanic option for low bootmem

This patch adds a no panic option for low bootmem allocs. This will allow for a more graceful handling of "out of memory" for those callers who wish to handle it.

Thanks,
Jon

include/linux/bootmem.h +1 -0
diff -r 307c5ac10c26 include/linux/bootmem.h
@@ -46,6 +46,7 @@
 extern void __init free_bootmem (unsigned long addr, unsigned long size);
 extern void * __init __alloc_bootmem (unsigned long size, unsigned long align, unsigned long goal);
 extern void * __init __alloc_bootmem_nopanic (unsigned long size, unsigned long align, unsigned long goal);
+extern void * __init __alloc_bootmem_low_nopanic(unsigned long size, unsigned long align, unsigned long goal);
 extern void * __init __alloc_bootmem_low(unsigned long size,
 					 unsigned long align,
 					 unsigned long goal);
mm/bootmem.c +13 -0
diff -r 307c5ac10c26 mm/bootmem.c
@@ -463,3 +463,16 @@
 {
 	return __alloc_bootmem_core(pgdat->bdata, size, align, goal, LOW32LIMIT);
 }
+
+void * __init __alloc_bootmem_low_nopanic(unsigned long size, 
+					unsigned long align, unsigned long goal)
+{
+	bootmem_data_t *bdata;
+	void *ptr;
+
+	list_for_each_entry(bdata, &bdata_list, list)
+		if ((ptr = __alloc_bootmem_core(bdata, size, align, goal, 
+						LOW32LIMIT)))
+			return(ptr);
+	return NULL;
+}
#1 lore raw
Quoted 3 lines · Jon Mason

This patch adds a no panic option for low bootmem allocs. This will allow for a more graceful handling of "out of memory" for those callers who wish to handle it.

What's the user of it? Normally we don't merge such changes without an user.

-Andi

#2 lore raw
Quoted 7 lines · Andi Kleen
Quoted 3 lines · Jon Mason

This patch adds a no panic option for low bootmem allocs. This will allow for a more graceful handling of "out of memory" for those callers who wish to handle it.

What's the user of it? Normally we don't merge such changes without an user.

Calgary and swiotlb can use it to gracefully handle out of memory when they allocate their aperture (swiotlb) or translation tables (Calgary) on initialization. Either can fall back to no-iommu if initialization fails so there's really no need to panic.

Jon, you should probably resubmit this with your swiotlb patches making use of it.

Cheers,
Muli

Signature · 2 lines
Muli Ben-Yehuda
http://www.mulix.org | http://mulix.livejournal.com/
author
#3 lore raw
In reply to Andi Kleen
Quoted 7 lines · Andi Kleen
Quoted 3 lines · Jon Mason

This patch adds a no panic option for low bootmem allocs. This will allow for a more graceful handling of "out of memory" for those callers who wish to handle it.

What's the user of it? Normally we don't merge such changes without an user.

Sorry. Per your suggestion in the review of our Calgary IOMMU code, I tried to use the alloc_bootmem_nopanic that you recently added. Unfortunately, it needs low mem for our translation tables, so we needed a new function to do this.

Aside from Calgary, I have updated swiotlb to take advantage of this new function (amongst other clean-ups and refinements). I'll push those swiotlb patches out today.

Thanks,
Jon

Quoted 2 lines

-Andi

#4 lore raw
Quoted 9 lines · Jon Mason
Quoted 7 lines · Andi Kleen
Quoted 3 lines · Jon Mason

This patch adds a no panic option for low bootmem allocs. This will allow for a more graceful handling of "out of memory" for those callers who wish to handle it.

What's the user of it? Normally we don't merge such changes without an user.

Quoted 8 lines

Sorry. Per your suggestion in the review of our Calgary IOMMU code, I tried to use the alloc_bootmem_nopanic that you recently added. Unfortunately, it needs low mem for our translation tables, so we needed a new function to do this.

Aside from Calgary, I have updated swiotlb to take advantage of this new function (amongst other clean-ups and refinements). I'll push those swiotlb patches out today.

I will merge it together with the Calgary code then. -Andi