Re: [PATCH] vmallocinfo: Add NUMA informations

From: Andrew Morton
Date: Mon Jun 09 2008 - 17:05:35 EST


On Mon, 9 Jun 2008 07:16:48 -0700 (PDT)
Christoph Lameter <clameter@xxxxxxx> wrote:

> On Tue, 3 Jun 2008, Andrew Morton wrote:
>
> > > + if (NUMA_BUILD) {
> > > + unsigned int *counters, nr;
> > > +
> > > + counters = kzalloc(nr_node_ids * sizeof(unsigned int),
> >
> > This is kcalloc(). If you like that sorts of thing - I think kcalloc()
> > is pretty pointless personally.
>
> Same here. I think its generally ignored. I tried to remove it at some
> point in the past. If we want kcalloc then we also need kczalloc.

kcalloc() zeroes the returned memory - it's like calloc().

> It would
> be best to keep the interface simple.

yup. Oh well, it's not a big deal.

Except the inlined

if (n != 0 && size > ULONG_MAX / n)
return NULL;

is a bit bloaty/inefficient. I expect that it's often the case that
one of `n' and `size' is not a compile-time constant.

otoh, there's one good thing about kcalloc: it actually checks for
multiplicative overflows, whereas the open-coded version often forgets
to do that.

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