All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sergey Matyukevich <geomatsi@gmail.com>
To: opensbi@lists.infradead.org
Subject: [PATCH] lib: pmu: allow to use the highest available counter
Date: Fri, 24 Jun 2022 10:03:03 +0300	[thread overview]
Message-ID: <YrVhp3jFrUTR/yhF@curiosity> (raw)
In-Reply-To: <20220624065028.2895176-1-atishp@rivosinc.com>

Hi,

> Both OpenSBI and OS explicitly assume that there is no hardware counter
> with index 1: hardware uses that bit for TM control. So OpenSBI filters
> out that index in sanity checks.
> However, OpenSBI doesn't consider TM bit while returning the number of
> counters. As a result, the supervisor software is aware of less number
> of firmware counter.
> 
> The simple test is to make sure that there is no counter multiplexing
> in the following command:
> 
> $ perf stat -e \
>         r8000000000000000,r8000000000000001,r8000000000000002,r8000000000000003, \
>         r8000000000000004,r8000000000000005,r8000000000000006,r8000000000000007, \
>         r8000000000000008,r8000000000000009,r800000000000000a,r800000000000000b, \
>         r800000000000000c,r800000000000000d,r800000000000000e,r800000000000000f  \
>         ls
> (16 firmware events with 16 counters won't require multiplexing)
> 
> Return accurate number of counters and update the firmware counter

This is not correct.

> starting index.
> 
> Signed-off-by: Sergey Matyukevich <geomatsi@gmail.com>
> Signed-off-by: Atish Patra <atishp@rivosinc.com>

snip

> -		num_hw_ctrs = sbi_hart_mhpm_count(scratch) + 2;
> +		num_hw_ctrs = sbi_hart_mhpm_count(scratch) + 3;
>  		total_ctrs = num_hw_ctrs + SBI_PMU_FW_CTR_MAX;
>  	}

I would suggest _not_ to merge this change in its current form. Current
approach reports incorrect number of hardware counters just to make
kernel driver provide accurate counter mask in all the subsequent
SBI requests. That is going to impact all the other SBI implementations
as well: all of them will have to pass incorrect hw counter number in
order to get correct counters mask from the kernel.

Regards,
Sergey


  reply	other threads:[~2022-06-24  7:03 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-24  6:50 [PATCH] lib: pmu: allow to use the highest available counter Atish Patra
2022-06-24  7:03 ` Sergey Matyukevich [this message]
2022-06-24  8:48   ` Anup Patel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YrVhp3jFrUTR/yhF@curiosity \
    --to=geomatsi@gmail.com \
    --cc=opensbi@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.