All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86, olpc: Eliminate BUG_ON and memset after alloc_bootmem
@ 2014-07-19 11:36 Himangi Saraogi
  2014-07-21 22:56 ` David Rientjes
  0 siblings, 1 reply; 2+ messages in thread
From: Himangi Saraogi @ 2014-07-19 11:36 UTC (permalink / raw)
  To: Thomas Gleixner, Ingo Molnar, H. Peter Anvin, x86, linux-kernel
  Cc: Julia Lawall

alloc_bootmem and related functions never return NULL and always return
a zeroed region of memory.  Thus a BUG_ON the NULL test or memset after
calls to these functions is unnecessary.

The following Coccinelle semantic patch was used for making the change:

@@
expression E;
statement S;
@@

E = \(alloc_bootmem\|alloc_bootmem_low\|alloc_bootmem_pages\|alloc_bootmem_low_pages\)(...)
... when != E
- BUG_ON (E == NULL);

@@
expression E,E1;
@@

E = \(alloc_bootmem\|alloc_bootmem_low\|alloc_bootmem_pages\|alloc_bootmem_low_pages\)(...)
... when != E
- memset(E,0,E1);

Signed-off-by: Himangi Saraogi <himangi774@gmail.com>
Acked-by: Julia Lawall <julia.lawall@lip6.fr>
---
 arch/x86/platform/olpc/olpc_dt.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/arch/x86/platform/olpc/olpc_dt.c b/arch/x86/platform/olpc/olpc_dt.c
index d6ee929..280645d 100644
--- a/arch/x86/platform/olpc/olpc_dt.c
+++ b/arch/x86/platform/olpc/olpc_dt.c
@@ -142,9 +142,7 @@ void * __init prom_early_alloc(unsigned long size)
 		 * wasted bootmem) and hand off chunks of it to callers.
 		 */
 		res = alloc_bootmem(chunk_size);
-		BUG_ON(!res);
 		prom_early_allocated += chunk_size;
-		memset(res, 0, chunk_size);
 		free_mem = chunk_size;
 		mem = res;
 	}
-- 
1.9.1


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

* Re: [PATCH] x86, olpc: Eliminate BUG_ON and memset after alloc_bootmem
  2014-07-19 11:36 [PATCH] x86, olpc: Eliminate BUG_ON and memset after alloc_bootmem Himangi Saraogi
@ 2014-07-21 22:56 ` David Rientjes
  0 siblings, 0 replies; 2+ messages in thread
From: David Rientjes @ 2014-07-21 22:56 UTC (permalink / raw)
  To: Himangi Saraogi
  Cc: Thomas Gleixner, Ingo Molnar, H. Peter Anvin, x86, linux-kernel,
	Julia Lawall

On Sat, 19 Jul 2014, Himangi Saraogi wrote:

> alloc_bootmem and related functions never return NULL and always return
> a zeroed region of memory.  Thus a BUG_ON the NULL test or memset after
> calls to these functions is unnecessary.
> 
> The following Coccinelle semantic patch was used for making the change:
> 
> @@
> expression E;
> statement S;
> @@
> 
> E = \(alloc_bootmem\|alloc_bootmem_low\|alloc_bootmem_pages\|alloc_bootmem_low_pages\)(...)
> ... when != E
> - BUG_ON (E == NULL);
> 
> @@
> expression E,E1;
> @@
> 
> E = \(alloc_bootmem\|alloc_bootmem_low\|alloc_bootmem_pages\|alloc_bootmem_low_pages\)(...)
> ... when != E
> - memset(E,0,E1);
> 
> Signed-off-by: Himangi Saraogi <himangi774@gmail.com>
> Acked-by: Julia Lawall <julia.lawall@lip6.fr>

Acked-by: David Rientjes <rientjes@google.com>

Many callers of alloc_bootmem() do not check for the return value because 
of this, there's no fallback available at this part in bootstrap so 
there's nothing else that can be done.

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

end of thread, other threads:[~2014-07-21 22:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-19 11:36 [PATCH] x86, olpc: Eliminate BUG_ON and memset after alloc_bootmem Himangi Saraogi
2014-07-21 22:56 ` David Rientjes

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.