Re: [PATCH v8 06/22] perf arm-spe: Refactor printing string to buffer

From: Leo Yan
Date: Thu Nov 12 2020 - 00:34:50 EST


On Wed, Nov 11, 2020 at 03:01:27PM -0300, Arnaldo Carvalho de Melo wrote:
> Em Wed, Nov 11, 2020 at 05:58:27PM +0000, Dave Martin escreveu:
> >
> > On Wed, Nov 11, 2020 at 05:39:22PM +0000, Arnaldo Carvalho de Melo wrote:
> > > Em Wed, Nov 11, 2020 at 03:45:23PM +0000, Andr� Przywara escreveu:
> > > > On 11/11/2020 15:35, Arnaldo Carvalho de Melo wrote:
> > > > > Isn't this 'ret +=' ? Otherwise if any of these arm_spe_pkt_snprintf()
> > > > > calls are made the previous 'ret' value is simply discarded. Can you
> > > > > clarify this?
>
> > > > ret is the same as err. If err is negative (from previous calls), we
> > > > return that straight away, so it does nothing but propagating the error.
>
> > > Usually the return of a snprintf is used to account for buffer space, ok
> > > I'll have to read it, which I shouldn't as snprintf has a well defined
> > > meaning...
>
> > > Ok, now that I look at it, I realize it is not a snprintf() routine, but
> > > something with different semantics, that will look at a pointer to an
> > > integer and then do nothing if it comes with some error, etc, confusing
> > > :-/
>
> > Would you be happier if the function were renamed?
>
> > Originally we were aiming for snprintf() semantics, but this still
> > spawns a lot of boilerplate code and encourages mistakes in the local
> > caller here -- hence the current sticky error approach.
>
> > So maybe the name should now be less "snprintf"-like.
>
> Please, its important to stick to semantics for such well known type of
> routines, helps reviewing, etc.

My bad, will change the function name to arm_spe_pkt_out_string().

> I'll keep the series up to that point and will run my build tests, then
> push it publicly to acme/perf/core and you can go from there, ok?

Will follow up and rebase patches for next version.

> I've changed the BIT() to BIT_ULL() as Andre suggested and I'm testing
> it again.

I worry that consumed your (Arnaldo/Andre/Dave) much time, but very
appreciate you guy's helping.

Thanks,
Leo