Re: [PATCH v4 2/3] perf lock: Fix the wrong name percpu-rwsem
From: Chun-Tse Shao
Date: Tue Dec 10 2024 - 15:10:53 EST
Thank you Namhyung! Please check my v5 patchset:
https://lore.kernel.org/all/20241210200847.1023139-1-ctshao@xxxxxxxxxx/T/#t
On Mon, Dec 9, 2024 at 2:44 PM Namhyung Kim <namhyung@xxxxxxxxxx> wrote:
>
> On Mon, Dec 09, 2024 at 12:01:01PM -0800, Chun-Tse Shao wrote:
> > In `perf lock --help`, the name of `percpu-rwsem` should be
> > `pcpu-rwsem`. This patch fixes the naming in `lock_type_table`, and also
> > replaces the mismatched name `percpu-rwsem` before parsing it for
> > backward compatibility.
> >
> > Tested `./perf lock con -ab -Y pcpu-sem` and `./perf lock con -ab -Y
> > percpu-rwsem`
> >
> > Fixes: 4f701063bfa2 ("perf lock contention: Show lock type with address")
> > Signed-off-by: Chun-Tse Shao <ctshao@xxxxxxxxxx>
> > ---
> > tools/perf/builtin-lock.c | 8 ++++++--
> > 1 file changed, 6 insertions(+), 2 deletions(-)
> >
> > diff --git a/tools/perf/builtin-lock.c b/tools/perf/builtin-lock.c
> > index 7e36bbe3cb80..264acfa648e4 100644
> > --- a/tools/perf/builtin-lock.c
> > +++ b/tools/perf/builtin-lock.c
> > @@ -1587,8 +1587,8 @@ static const struct {
> > { LCB_F_RT, "rt-mutex", "rt-mutex" },
> > { LCB_F_RT | LCB_F_READ, "rwlock-rt:R", "rwlock-rt" },
> > { LCB_F_RT | LCB_F_WRITE, "rwlock-rt:W", "rwlock-rt" },
> > - { LCB_F_PERCPU | LCB_F_READ, "pcpu-sem:R", "percpu-rwsem" },
> > - { LCB_F_PERCPU | LCB_F_WRITE, "pcpu-sem:W", "percpu-rwsem" },
> > + { LCB_F_PERCPU | LCB_F_READ, "pcpu-sem:R", "pcpu-sem" },
> > + { LCB_F_PERCPU | LCB_F_WRITE, "pcpu-sem:W", "pcpu-sem" },
>
> It'll change the output of perf lock con -l.
>
>
> > { LCB_F_MUTEX, "mutex", "mutex" },
> > { LCB_F_MUTEX | LCB_F_SPIN, "mutex", "mutex" },
> > };
> > @@ -2365,7 +2365,11 @@ static int parse_lock_type(const struct option *opt __maybe_unused, const char *
> > /*
> > * Otherwise `tok` is `name` in `lock_type_table`.
> > * Single lock name could contain multiple flags.
> > + * By documentation, `percpu-rwmem` should be `pcpu-sem`.
> > + * For backward compatibility, we replace `percpu-rwmem` with `pcpu-sem`.
> > */
> > + if (!strcmp(tok, "percpu-rwsem"))
> > + tok = (char *)"pcpu-sem";
>
> I think you can do this in the other way around.
>
> Thanks,
> Namhyung
>
>
> > for (unsigned int i = 0; i < ARRAY_SIZE(lock_type_table); i++) {
> > if (!strcmp(lock_type_table[i].name, tok)) {
> > if (add_lock_type(lock_type_table[i].flags)) {
> > --
> > 2.47.0.338.g60cca15819-goog
> >