<br><br><div class="gmail_quote">On Tue, May 24, 2011 at 11:09 PM, Joe Perches <span dir="ltr"><<a href="mailto:joe@perches.com">joe@perches.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div><div></div><div class="h5">On Tue, 2011-05-24 at 22:59 +0600, Rakib Mullick wrote:<br>
> On 5/23/11, Joe Perches <<a href="mailto:joe@perches.com">joe@perches.com</a>> wrote:<br>
> > On Mon, 2011-05-23 at 23:40 +0600, Rakib Mullick wrote:<br>
> >> Following patch removes the uses of 'kmalloc+memset' from various<br>
> >> drivers subsystems, which is replaced by kzalloc. kzalloc take care of<br>
> >> setting allocated memory with null, so it helps to get rid from using<br>
> >> memset.<br>
> >> diff --git a/drivers/gpu/drm/drm_scatter.c b/drivers/gpu/drm/drm_scatter.c<br>
> > []<br>
> >> - entry->pagelist = kmalloc(pages * sizeof(*entry->pagelist), GFP_KERNEL);<br>
> >> + entry->pagelist = kzalloc(pages * sizeof(*entry->pagelist), GFP_KERNEL);<br>
> > Perhaps it's better to use:<br>
> > entry->pagelist = kcalloc(pages, sizeof(*entry->pagelist), GFP_KERNEL);<br>
> >> - entry->busaddr = kmalloc(pages * sizeof(*entry->busaddr), GFP_KERNEL);<br>
> >> + entry->busaddr = kzalloc(pages * sizeof(*entry->busaddr), GFP_KERNEL);<br>
> > here too.<br>
> Is there any significant benefit of using kcalloc here?<br>
<br>
</div></div>Overflow and tradition.<br>
<br></blockquote><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
static inline void *kcalloc(size_t n, size_t size, gfp_t flags)<br>
{<br>
if (size != 0 && n > ULONG_MAX / size)<br>
return NULL;<br>
return __kmalloc(n * size, flags | __GFP_ZERO);<br>
}<br>
<font color="#888888"><br></font></blockquote><div>It's been used for allocating memory for an array. Maybe, using kcalloc in entry->pagelist could be useful. But, not that much sure though. There's no problem with current implementation.<br>
<br>This patch touches few drivers subsystems, they are added to the CC list.<br><br>Thanks,<br>Rakib<br></div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<font color="#888888">
<br>
--<br>
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in<br>
the body of a message to <a href="mailto:majordomo@vger.kernel.org">majordomo@vger.kernel.org</a><br>
More majordomo info at <a href="http://vger.kernel.org/majordomo-info.html" target="_blank">http://vger.kernel.org/majordomo-info.html</a><br>
Please read the FAQ at <a href="http://www.tux.org/lkml/" target="_blank">http://www.tux.org/lkml/</a><br>
</font></blockquote></div><br>