linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Namhyung Kim <namhyung@kernel.org>
To: Arnaldo Carvalho de Melo <arnaldo.melo@gmail.com>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>,
	Ian Rogers <irogers@google.com>,
	 Kan Liang <kan.liang@linux.intel.com>,
	Jiri Olsa <jolsa@kernel.org>,
	 Adrian Hunter <adrian.hunter@intel.com>,
	Peter Zijlstra <peterz@infradead.org>,
	 Ingo Molnar <mingo@kernel.org>,
	LKML <linux-kernel@vger.kernel.org>,
	 linux-perf-users <linux-perf-users@vger.kernel.org>,
	 Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Subject: Re: [PATCH 1/2] perf annotate-data: Show offset and size in hex
Date: Mon, 19 Aug 2024 19:21:34 -0700	[thread overview]
Message-ID: <CAM9d7cjLvS5BUO_AEkfR3LsT8SNB8MCt-DTHCiRDrZyQxhySoQ@mail.gmail.com> (raw)
In-Reply-To: <CA+JHD93fa33YL_AHL9RfxUOoBm+hw8zHbk13BU4qD8B3p4KHug@mail.gmail.com>

On Mon, Aug 19, 2024 at 5:12 PM Arnaldo Carvalho de Melo
<arnaldo.melo@gmail.com> wrote:
>
>
>
> On Mon, Aug 19, 2024, 8:36 PM Namhyung Kim <namhyung@kernel.org> wrote:
>>
>> It'd be better to have them in hex to check cacheline alignment.
>>
>>
> Why is it better? To compare with the usual output of some other tool?
>
> Spelling out reasons helps reviewers/users.

Cache line sizes are power of 2 so it'd be natural to use hex and
check whether an offset is in the same boundary.  Also perf annotate
shows instruction offsets in hex.

>
> Maybe this should be selectable?

I can add an option and/or a config if you want.

Thanks,
Namhyung

>>
>>
>
>>  Percent     offset       size  field
>>   100.00          0      0x1c0  struct cfs_rq    {
>>     0.00          0       0x10      struct load_weight  load {
>>     0.00          0        0x8          long unsigned int       weight;
>>     0.00        0x8        0x4          u32     inv_weight;
>>                                     };
>>     0.00       0x10        0x4      unsigned int        nr_running;
>>    14.56       0x14        0x4      unsigned int        h_nr_running;
>>     0.00       0x18        0x4      unsigned int        idle_nr_running;
>>     0.00       0x1c        0x4      unsigned int        idle_h_nr_running;
>>   ...
>>
>> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
>> ---
>>  tools/perf/ui/browsers/annotate-data.c | 4 ++--
>>  tools/perf/util/annotate-data.c        | 2 +-
>>  tools/perf/util/sort.c                 | 2 +-
>>  3 files changed, 4 insertions(+), 4 deletions(-)
>>
>> diff --git a/tools/perf/ui/browsers/annotate-data.c b/tools/perf/ui/browsers/annotate-data.c
>> index f563a3bb072c..cd562a8822b7 100644
>> --- a/tools/perf/ui/browsers/annotate-data.c
>> +++ b/tools/perf/ui/browsers/annotate-data.c
>> @@ -427,12 +427,12 @@ static void browser__write(struct ui_browser *uib, void *entry, int row)
>>
>>         /* print type info */
>>         if (be->indent == 0 && !member->var_name) {
>> -               ui_browser__printf(uib, " %10d %10d  %s%s",
>> +               ui_browser__printf(uib, " %#10x %#10x  %s%s",
>>                                    member->offset, member->size,
>>                                    member->type_name,
>>                                    list_empty(&member->children) || be->folded? ";" : " {");
>>         } else {
>> -               ui_browser__printf(uib, " %10d %10d  %*s%s\t%s%s",
>> +               ui_browser__printf(uib, " %#10x %#10x  %*s%s\t%s%s",
>>                                    member->offset, member->size,
>>                                    be->indent * 4, "", member->type_name,
>>                                    member->var_name ?: "",
>> diff --git a/tools/perf/util/annotate-data.c b/tools/perf/util/annotate-data.c
>> index aa330c7d8edd..25105b3b9a13 100644
>> --- a/tools/perf/util/annotate-data.c
>> +++ b/tools/perf/util/annotate-data.c
>> @@ -1660,7 +1660,7 @@ static void print_annotated_data_type(struct annotated_data_type *mem_type,
>>                 nr_events++;
>>         }
>>
>> -       printf(" %10d %10d  %*s%s\t%s",
>> +       printf(" %#10x %#10x  %*s%s\t%s",
>>                member->offset, member->size, indent, "", member->type_name,
>>                member->var_name ?: "");
>>
>> diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
>> index c4046d5d1749..d315308f9170 100644
>> --- a/tools/perf/util/sort.c
>> +++ b/tools/perf/util/sort.c
>> @@ -2312,7 +2312,7 @@ static int hist_entry__typeoff_snprintf(struct hist_entry *he, char *bf,
>>                                  he->mem_type_off, true);
>>         buf[4095] = '\0';
>>
>> -       return repsep_snprintf(bf, size, "%s %+d (%s)", he_type->self.type_name,
>> +       return repsep_snprintf(bf, size, "%s +%#x (%s)", he_type->self.type_name,
>>                                he->mem_type_off, buf);
>>  }
>>
>> --
>> 2.46.0.184.g6999bdac58-goog
>>
>>

  parent reply	other threads:[~2024-08-20  2:21 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-19 23:36 [PATCH 1/2] perf annotate-data: Show offset and size in hex Namhyung Kim
2024-08-19 23:36 ` [PATCH 2/2] perf annotate-data: Add 'typecln' sort key Namhyung Kim
     [not found] ` <CA+JHD93fa33YL_AHL9RfxUOoBm+hw8zHbk13BU4qD8B3p4KHug@mail.gmail.com>
2024-08-20  2:21   ` Namhyung Kim [this message]
2024-08-21 14:45     ` [PATCH 1/2] perf annotate-data: Show offset and size in hex Arnaldo Carvalho de Melo

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=CAM9d7cjLvS5BUO_AEkfR3LsT8SNB8MCt-DTHCiRDrZyQxhySoQ@mail.gmail.com \
    --to=namhyung@kernel.org \
    --cc=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=arnaldo.melo@gmail.com \
    --cc=atrajeev@linux.vnet.ibm.com \
    --cc=irogers@google.com \
    --cc=jolsa@kernel.org \
    --cc=kan.liang@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=peterz@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).