* [PATCH 3/14] arch/ia64: Eliminate NULL test and memset after alloc_bootmem
@ 2008-06-24 8:22 Julia Lawall
2008-06-24 17:42 ` Luck, Tony
0 siblings, 1 reply; 6+ messages in thread
From: Julia Lawall @ 2008-06-24 8:22 UTC (permalink / raw)
To: akinobu.mita, tony.luck, linux-ia64, linux-kernel, kernel-janitors
From: Julia Lawall <julia@diku.dk>
As noted by Akinobu Mita in patch b1fceac2b9e04d278316b2faddf276015fc06e3b,
alloc_bootmem and related functions never return NULL and always return a
zeroed region of memory. Thus a NULL test or memset after calls to these
functions is unnecessary.
arch/ia64/kernel/iosapic.c | 2 --
1 file changed, 2 deletions(-)
This was fixed using the following semantic patch.
(http://www.emn.fr/x-info/coccinelle/)
// <smpl>
@@
expression E;
statement S;
@@
E = \(alloc_bootmem\|alloc_bootmem_low\|alloc_bootmem_pages\|alloc_bootmem_low_pages\)(...)
... when != E
(
- BUG_ON (E == NULL);
|
- if (E == NULL) S
)
@@
expression E,E1;
@@
E = \(alloc_bootmem\|alloc_bootmem_low\|alloc_bootmem_pages\|alloc_bootmem_low_pages\)(...)
... when != E
- memset(E,0,E1);
// </smpl>
Signed-off-by: Julia Lawall <julia@diku.dk>
---
diff -u -p a/arch/ia64/kernel/iosapic.c b/arch/ia64/kernel/iosapic.c
--- a/arch/ia64/kernel/iosapic.c
+++ b/arch/ia64/kernel/iosapic.c
@@ -558,8 +558,6 @@ static struct iosapic_rte_info * __init_
if (!iosapic_kmalloc_ok && list_empty(&free_rte_list)) {
rte = alloc_bootmem(sizeof(struct iosapic_rte_info) *
NR_PREALLOCATE_RTE_ENTRIES);
- if (!rte)
- return NULL;
for (i = 0; i < NR_PREALLOCATE_RTE_ENTRIES; i++, rte++)
list_add(&rte->rte_list, &free_rte_list);
}
^ permalink raw reply [flat|nested] 6+ messages in thread
* RE: [PATCH 3/14] arch/ia64: Eliminate NULL test and memset after alloc_bootmem
2008-06-24 8:22 [PATCH 3/14] arch/ia64: Eliminate NULL test and memset after alloc_bootmem Julia Lawall
@ 2008-06-24 17:42 ` Luck, Tony
2008-06-24 17:55 ` Julia Lawall
2008-06-24 17:56 ` Luck, Tony
0 siblings, 2 replies; 6+ messages in thread
From: Luck, Tony @ 2008-06-24 17:42 UTC (permalink / raw)
To: Julia Lawall, akinobu.mita, linux-ia64, linux-kernel, kernel-janitors
> As noted by Akinobu Mita in patch b1fceac2b9e04d278316b2faddf276015fc06e3b,
> alloc_bootmem and related functions never return NULL and always return a
> zeroed region of memory. Thus a NULL test or memset after calls to these
> functions is unnecessary.
There is no commit b1fceac2b9e04d278316b2faddf276015fc06e3b in Linus' tree.
In addition the current alloc_bootmem() is a macro that uses __alloc_bootmem
which most defintely can return NULL.
Is this against -mm or linux-next?
-Tony
^ permalink raw reply [flat|nested] 6+ messages in thread
* RE: [PATCH 3/14] arch/ia64: Eliminate NULL test and memset after alloc_bootmem
2008-06-24 17:42 ` Luck, Tony
@ 2008-06-24 17:55 ` Julia Lawall
2008-06-24 17:59 ` Luck, Tony
2008-06-24 17:56 ` Luck, Tony
1 sibling, 1 reply; 6+ messages in thread
From: Julia Lawall @ 2008-06-24 17:55 UTC (permalink / raw)
To: Luck, Tony; +Cc: akinobu.mita, linux-ia64, linux-kernel, kernel-janitors
On Tue, 24 Jun 2008, Luck, Tony wrote:
> > As noted by Akinobu Mita in patch b1fceac2b9e04d278316b2faddf276015fc06e3b,
> > alloc_bootmem and related functions never return NULL and always return a
> > zeroed region of memory. Thus a NULL test or memset after calls to these
> > functions is unnecessary.
>
> There is no commit b1fceac2b9e04d278316b2faddf276015fc06e3b in Linus' tree.
I am not sure to know how to tell precisely where you are looking, but you
can find it here:
http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=b1fceac2b9e04d278316b2faddf276015fc06e3b
> In addition the current alloc_bootmem() is a macro that uses __alloc_bootmem
> which most defintely can return NULL.
The "return NULL;" at the bottom of __alloc_bootmem is preceded by
panic("Out of memory");, which I assume cannot return?
> Is this against -mm or linux-next?
I pull files from the following git repository:
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git
julia
^ permalink raw reply [flat|nested] 6+ messages in thread
* RE: [PATCH 3/14] arch/ia64: Eliminate NULL test and memset after alloc_bootmem
2008-06-24 17:42 ` Luck, Tony
2008-06-24 17:55 ` Julia Lawall
@ 2008-06-24 17:56 ` Luck, Tony
2008-06-24 18:00 ` Julia Lawall
1 sibling, 1 reply; 6+ messages in thread
From: Luck, Tony @ 2008-06-24 17:56 UTC (permalink / raw)
To: Luck, Tony, Julia Lawall, akinobu.mita, linux-ia64, linux-kernel,
kernel-janitors
> In addition the current alloc_bootmem() is a macro that uses __alloc_bootmem
> which most defintely can return NULL.
...
panic("Out of memory");
return NULL;
}
Oops ... that "panic" call before the "return NULL" makes the
above statement totally wrong.
-Tony
^ permalink raw reply [flat|nested] 6+ messages in thread
* RE: [PATCH 3/14] arch/ia64: Eliminate NULL test and memset after alloc_bootmem
2008-06-24 17:55 ` Julia Lawall
@ 2008-06-24 17:59 ` Luck, Tony
0 siblings, 0 replies; 6+ messages in thread
From: Luck, Tony @ 2008-06-24 17:59 UTC (permalink / raw)
To: Julia Lawall; +Cc: akinobu.mita, linux-ia64, linux-kernel, kernel-janitors
>> There is no commit b1fceac2b9e04d278316b2faddf276015fc06e3b in Linus' tree.
>
> I am not sure to know how to tell precisely where you are looking, but you
> can find it here:
You are right ... I'm not at all sure where I was looking either. I cut
& pasted the commit to a "git show ....", and it came up with nothing. But
now it works! Some strange user error on my part. Sorry.
-Tony
^ permalink raw reply [flat|nested] 6+ messages in thread
* RE: [PATCH 3/14] arch/ia64: Eliminate NULL test and memset after alloc_bootmem
2008-06-24 17:56 ` Luck, Tony
@ 2008-06-24 18:00 ` Julia Lawall
0 siblings, 0 replies; 6+ messages in thread
From: Julia Lawall @ 2008-06-24 18:00 UTC (permalink / raw)
To: Luck, Tony; +Cc: akinobu.mita, linux-ia64, linux-kernel, kernel-janitors
On Tue, 24 Jun 2008, Luck, Tony wrote:
> > In addition the current alloc_bootmem() is a macro that uses __alloc_bootmem
> > which most defintely can return NULL.
>
> ...
> panic("Out of memory");
> return NULL;
> }
>
> Oops ... that "panic" call before the "return NULL" makes the
> above statement totally wrong.
Thanks. I was worried there might be somewhere a non-aborting version of
panic. But that would be really confusing...
julia
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2008-06-24 18:00 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-06-24 8:22 [PATCH 3/14] arch/ia64: Eliminate NULL test and memset after alloc_bootmem Julia Lawall
2008-06-24 17:42 ` Luck, Tony
2008-06-24 17:55 ` Julia Lawall
2008-06-24 17:59 ` Luck, Tony
2008-06-24 17:56 ` Luck, Tony
2008-06-24 18:00 ` Julia Lawall
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®