Re: [PATCH v3 net-next 2/2] net: mscc: ocelot: use bulk reads for stats

From: Colin Foster
Date: Thu Jan 27 2022 - 11:30:11 EST


Hi Jakub,

On Wed, Jan 26, 2022 at 06:34:36PM -0800, Jakub Kicinski wrote:
> On Mon, 24 Jan 2022 23:15:31 -0800 Colin Foster wrote:
> > Create and utilize bulk regmap reads instead of single access for gathering
> > stats. The background reading of statistics happens frequently, and over
> > a few contiguous memory regions.
> >
> > High speed PCIe buses and MMIO access will probably see negligible
> > performance increase. Lower speed buses like SPI and I2C could see
> > significant performance increase, since the bus configuration and register
> > access times account for a large percentage of data transfer time.
> >
> > Signed-off-by: Colin Foster <colin.foster@xxxxxxxxxxxxxxxx>
>
> > +static int ocelot_prepare_stats_regions(struct ocelot *ocelot)
> > +{
> > + struct ocelot_stats_region *region = NULL;
> > + unsigned int last;
> > + int i;
> > +
> > + INIT_LIST_HEAD(&ocelot->stats_regions);
> > +
> > + for (i = 0; i < ocelot->num_stats; i++) {
> > + if (region && ocelot->stats_layout[i].offset == last + 1) {
> > + region->count++;
> > + } else {
> > + region = devm_kzalloc(ocelot->dev, sizeof(*region),
> > + GFP_KERNEL);
> > + if (!region)
> > + return -ENOMEM;
> > +
> > + region->offset = ocelot->stats_layout[i].offset;
> > + region->count = 1;
> > + list_add_tail(&region->node, &ocelot->stats_regions);
> > + }
> > +
> > + last = ocelot->stats_layout[i].offset;
> > + }
> > +
> > + list_for_each_entry(region, &ocelot->stats_regions, node) {
> > + region->buf = devm_kzalloc(ocelot->dev,
> > + region->count * sizeof(*region->buf),
> > + GFP_KERNEL);
>
> devm_kcalloc()

Good catch. I'll probably give it another day for review and resubmit
tomrrow.

>
> > +
>
> unnecessary new line
>
> > + if (!region->buf)
> > + return -ENOMEM;