* the memset operation on a automatic array variable can be removed by data Initialization
@ 2007-06-18 7:47 Denis Cheng
0 siblings, 0 replies; 3+ messages in thread
From: Denis Cheng @ 2007-06-18 7:47 UTC (permalink / raw)
To: trivial; +Cc: linux-kernel
Signed-Off-By: Denis Cheng <crquan@gmail.com>
--- arch/x86_64/mm/init.c.orig 2007-06-07 10:08:04.000000000 +0800
+++ arch/x86_64/mm/init.c 2007-06-18 14:43:15.000000000 +0800
@@ -406,8 +406,7 @@ void __cpuinit zap_low_mappings(int cpu)
#ifndef CONFIG_NUMA
void __init paging_init(void)
{
- unsigned long max_zone_pfns[MAX_NR_ZONES];
- memset(max_zone_pfns, 0, sizeof(max_zone_pfns));
+ unsigned long max_zone_pfns[MAX_NR_ZONES] = { 0, };
max_zone_pfns[ZONE_DMA] = MAX_DMA_PFN;
max_zone_pfns[ZONE_DMA32] = MAX_DMA32_PFN;
max_zone_pfns[ZONE_NORMAL] = end_pfn;
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: the memset operation on a automatic array variable can be removed by data Initialization
2007-06-18 7:43 Denis Cheng
@ 2007-06-18 11:42 ` Jan Engelhardt
0 siblings, 0 replies; 3+ messages in thread
From: Jan Engelhardt @ 2007-06-18 11:42 UTC (permalink / raw)
To: Denis Cheng; +Cc: linux-kernel
On Jun 18 2007 00:43, Denis Cheng wrote:
>Subject: the memset operation on a automatic array variable can be removed by
> data Initialization
>
>--- arch/x86_64/mm/init.c 2007-06-07 10:08:04.000000000 +0800
>+++ /tmp/init.c 2007-06-18 14:43:15.000000000 +0800
>@@ -406,8 +406,7 @@ void __cpuinit zap_low_mappings(int cpu)
> #ifndef CONFIG_NUMA
> void __init paging_init(void)
> {
>- unsigned long max_zone_pfns[MAX_NR_ZONES];
>- memset(max_zone_pfns, 0, sizeof(max_zone_pfns));
>+ unsigned long max_zone_pfns[MAX_NR_ZONES] = { 0, };
The cost is the same. "= {0}" is transformed into a bunch of movs,
or a rep mov, (At least for x86), so is equivalent to memset (which
will get transformed to __builtin_memset anyway). So I wonder
what this really buys.
And, you do not even need the zero. Just write
...[MAX_NR_ZONES] = {};
> max_zone_pfns[ZONE_DMA] = MAX_DMA_PFN;
> max_zone_pfns[ZONE_DMA32] = MAX_DMA32_PFN;
> max_zone_pfns[ZONE_NORMAL] = end_pfn;
Jan
--
^ permalink raw reply [flat|nested] 3+ messages in thread
* the memset operation on a automatic array variable can be removed by data Initialization
@ 2007-06-18 7:43 Denis Cheng
2007-06-18 11:42 ` Jan Engelhardt
0 siblings, 1 reply; 3+ messages in thread
From: Denis Cheng @ 2007-06-18 7:43 UTC (permalink / raw)
To: linux-kernel
Signed-Off-By: Denis Cheng <crquan@gmail.com>
--- arch/x86_64/mm/init.c 2007-06-07 10:08:04.000000000 +0800
+++ /tmp/init.c 2007-06-18 14:43:15.000000000 +0800
@@ -406,8 +406,7 @@ void __cpuinit zap_low_mappings(int cpu)
#ifndef CONFIG_NUMA
void __init paging_init(void)
{
- unsigned long max_zone_pfns[MAX_NR_ZONES];
- memset(max_zone_pfns, 0, sizeof(max_zone_pfns));
+ unsigned long max_zone_pfns[MAX_NR_ZONES] = { 0, };
max_zone_pfns[ZONE_DMA] = MAX_DMA_PFN;
max_zone_pfns[ZONE_DMA32] = MAX_DMA32_PFN;
max_zone_pfns[ZONE_NORMAL] = end_pfn;
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-06-18 11:42 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-06-18 7:47 the memset operation on a automatic array variable can be removed by data Initialization Denis Cheng
-- strict thread matches above, loose matches on Subject: below --
2007-06-18 7:43 Denis Cheng
2007-06-18 11:42 ` Jan Engelhardt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).