[PATCH] SGI UltraViolet: Prefer kzalloc over kmalloc and memset andremove a pointless cast

From: Jesper Juhl
Date: Sat Oct 30 2010 - 15:03:14 EST



Hi,

Using kzalloc() instead of kmalloc()+memset() carries no downsides that I
can see, but it results in smaller (and presumably slightly faster) code.
There are two places in arch/x86/platform/uv/ that I've found where we can
make this improvement - patch below.
I also removed the cast of the kzalloc() return value since it returns a
void* so the cast is pointless.

It compiles, but I have no way to test it further than that.


Signed-off-by: Jesper Juhl <jj@xxxxxxxxxxxxx>
---
tlb_uv.c | 4 +---
uv_time.c | 3 +--
2 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/arch/x86/platform/uv/tlb_uv.c b/arch/x86/platform/uv/tlb_uv.c
index 20ea20a..f5b0258 100644
--- a/arch/x86/platform/uv/tlb_uv.c
+++ b/arch/x86/platform/uv/tlb_uv.c
@@ -1520,9 +1520,7 @@ static void __init uv_init_per_cpu(int nuvhubs)

timeout_us = calculate_destination_timeout();

- uvhub_descs = (struct uvhub_desc *)
- kmalloc(nuvhubs * sizeof(struct uvhub_desc), GFP_KERNEL);
- memset(uvhub_descs, 0, nuvhubs * sizeof(struct uvhub_desc));
+ uvhub_descs = kzalloc(nuvhubs * sizeof(struct uvhub_desc), GFP_KERNEL);
uvhub_mask = kzalloc((nuvhubs+7)/8, GFP_KERNEL);
for_each_present_cpu(cpu) {
bcp = &per_cpu(bau_control, cpu);
diff --git a/arch/x86/platform/uv/uv_time.c b/arch/x86/platform/uv/uv_time.c
index 56e421b..523975c 100644
--- a/arch/x86/platform/uv/uv_time.c
+++ b/arch/x86/platform/uv/uv_time.c
@@ -149,10 +149,9 @@ static __init int uv_rtc_allocate_timers(void)
{
int cpu;

- blade_info = kmalloc(uv_possible_blades * sizeof(void *), GFP_KERNEL);
+ blade_info = kzalloc(uv_possible_blades * sizeof(void *), GFP_KERNEL);
if (!blade_info)
return -ENOMEM;
- memset(blade_info, 0, uv_possible_blades * sizeof(void *));

for_each_present_cpu(cpu) {
int nid = cpu_to_node(cpu);


--
Jesper Juhl <jj@xxxxxxxxxxxxx> http://www.chaosbits.net/
Plain text mails only, please http://www.expita.com/nomime.html
Don't top-post http://www.catb.org/~esr/jargon/html/T/top-post.html

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/