<br><br><div class="gmail_quote">On Tue, May 24, 2011 at 11:09 PM, Joe Perches <span dir="ltr">&lt;<a href="mailto:joe@perches.com">joe@perches.com</a>&gt;</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>
&gt; On 5/23/11, Joe Perches &lt;<a href="mailto:joe@perches.com">joe@perches.com</a>&gt; wrote:<br>
&gt; &gt; On Mon, 2011-05-23 at 23:40 +0600, Rakib Mullick wrote:<br>
&gt; &gt;&gt; Following patch removes the uses of &#39;kmalloc+memset&#39; from various<br>
&gt; &gt;&gt; drivers subsystems, which is replaced by kzalloc. kzalloc take care of<br>
&gt; &gt;&gt; setting allocated memory with null, so it helps to get rid from using<br>
&gt; &gt;&gt; memset.<br>
&gt; &gt;&gt; diff --git a/drivers/gpu/drm/drm_scatter.c b/drivers/gpu/drm/drm_scatter.c<br>
&gt; &gt; []<br>
&gt; &gt;&gt; -  entry-&gt;pagelist = kmalloc(pages * sizeof(*entry-&gt;pagelist), GFP_KERNEL);<br>
&gt; &gt;&gt; +  entry-&gt;pagelist = kzalloc(pages * sizeof(*entry-&gt;pagelist), GFP_KERNEL);<br>
&gt; &gt; Perhaps it&#39;s better to use:<br>
&gt; &gt;     entry-&gt;pagelist =  kcalloc(pages, sizeof(*entry-&gt;pagelist), GFP_KERNEL);<br>
&gt; &gt;&gt; -  entry-&gt;busaddr = kmalloc(pages * sizeof(*entry-&gt;busaddr), GFP_KERNEL);<br>
&gt; &gt;&gt; +  entry-&gt;busaddr = kzalloc(pages * sizeof(*entry-&gt;busaddr), GFP_KERNEL);<br>
&gt; &gt; here too.<br>
&gt; 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 &amp;&amp; n &gt; ULONG_MAX / size)<br>
                return NULL;<br>
        return __kmalloc(n * size, flags | __GFP_ZERO);<br>
}<br>
<font color="#888888"><br></font></blockquote><div>It&#39;s been used for allocating memory for an array. Maybe, using kcalloc in entry-&gt;pagelist could be useful. But, not that much sure though. There&#39;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 &quot;unsubscribe linux-kernel&quot; 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>