Re: [PATCH] rtc: pl030: Use devm_kzalloc() instead of kmalloc()

From: Tejun Heo
Date: Thu Oct 10 2013 - 19:19:00 EST


Hello,

On Thu, Oct 10, 2013 at 04:06:03PM -0700, Andrew Morton wrote:
> On Tue, 08 Oct 2013 21:59:27 -0700 Joe Perches <joe@xxxxxxxxxxx> wrote:
>
> > I was a bit surprised to find there isn't a devm_kmalloc.
>
> Yes, the unconditional memset is silly. Especially when the
> function has a handy gfp_t and could be passed __GFP_ZERO.
>
> The comment says "managed kzalloc/kfree for device drivers, no kmalloc,
> always use kzalloc". There's no explanation for this - it looks like
> some ideological thing.

Skipping resetting just is highly unlikely to make any meaningful
difference in the paths devres is supposed to be used. These don't
and shouldn't get called from hot paths. Wouldn't it be more
idelogical to have something just because it feels weird not to have
it even if it is not necessary? I don't necessarily object to having
non-zeroing interface but it seems rather pointless. Do we have an
actual cases where this makes meaningful differences?

> - memset(dr, 0, tot_size);
> + if (gfp & __GFP_ZERO)
> + memset(dr, 0, tot_size);

I'd much prefer to have at least the devres_node part cleared
regardless of __GFP_ZERO and Joe already has better patches doing
this.

Thanks.

--
tejun
--
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/