Subject: Re: [PATCH v2 1/8] powerpc/perf/hv-24x7: Fix inconsistent output values incase multiple hv-24x7 events run

From: Sukadev Bhattiprolu <[email-masked]>
Date: Sat, 22 Feb 2020 18:51:19 -0800

Kajol Jain [[email-masked]] wrote:
> Commit 2b206ee6b0df ("powerpc/perf/hv-24x7: Display change in counter
> values")' added to print _change_ in the counter value rather then raw
> value for 24x7 counters. Incase of transactions, the event count
> is set to 0 at the beginning of the transaction. It also sets
> the event's prev_count to the raw value at the time of initialization.
> Because of setting event count to 0, we are seeing some weird behaviour,
> whenever we run multiple 24x7 events at a time.

Interesting. Are we taking delta of a delta and ending up with large
negative values in the -I case?  However...

<snip>

> 
> Signed-off-by: Kajol Jain <[email-masked]>
> ---
>  arch/powerpc/perf/hv-24x7.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/powerpc/perf/hv-24x7.c b/arch/powerpc/perf/hv-24x7.c
> index 573e0b309c0c..6dbbf70232aa 100644
> --- a/arch/powerpc/perf/hv-24x7.c
> +++ b/arch/powerpc/perf/hv-24x7.c
> @@ -1409,7 +1409,7 @@ static void h_24x7_event_read(struct perf_event *event)
>  			 * that would require issuing a hcall, which would then
>  			 * defeat the purpose of using the txn interface.
>  			 */
> -			local64_set(&event->count, 0);
> +			local64_add(0, &event->count);

... not sure, how adding zero to the count helps. Should we just remove the
line (and the comment block above it)?  Or does it help to clear the event
count in ->start_txn() rather than on read()?

How does the change impact the counts when run without the -I?

Thanks for chasing this down.

Sukadev