linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Adrian Hunter <adrian.hunter@intel.com>
To: Namhyung Kim <namhyung@kernel.org>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>,
	Jiri Olsa <jolsa@kernel.org>, Ian Rogers <irogers@google.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@kernel.org>,
	LKML <linux-kernel@vger.kernel.org>,
	linux-perf-users@vger.kernel.org
Subject: Re: [PATCH v2 3/4] perf tools: Convert to perf_record_header_attr_id()
Date: Wed, 30 Aug 2023 16:54:04 +0300	[thread overview]
Message-ID: <8cc59832-6dcd-0270-ede9-a06ee3e6a66c@intel.com> (raw)
In-Reply-To: <CAM9d7cg5vaD6zUThLWSpL-j3nXJgs3PK=_ensRw8P0Xye-VcfA@mail.gmail.com>

On 30/08/23 05:15, Namhyung Kim wrote:
> Hi Adrian,
> 
> On Mon, Aug 28, 2023 at 12:59 AM Adrian Hunter <adrian.hunter@intel.com> wrote:
>>
>> On 25/08/23 18:25, Namhyung Kim wrote:
>>> Instead of accessing the attr.id directly, use the
>>> perf_record_header_attr_id() helper to handle old versions.
>>>
>>> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
>>> ---
>>>  tools/perf/util/header.c           | 2 +-
>>>  tools/perf/util/session.c          | 4 ++--
>>>  tools/perf/util/synthetic-events.c | 2 +-
>>>  3 files changed, 4 insertions(+), 4 deletions(-)
>>>
>>> diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
>>> index f89321cbfdee..63967c34157d 100644
>>> --- a/tools/perf/util/header.c
>>> +++ b/tools/perf/util/header.c
>>> @@ -4408,7 +4408,7 @@ int perf_event__process_attr(struct perf_tool *tool __maybe_unused,
>>>       if (perf_evsel__alloc_id(&evsel->core, 1, n_ids))
>>>               return -ENOMEM;
>>>
>>> -     ids = (void *)&event->attr.attr + event->attr.attr.size;
>>> +     ids = perf_record_header_attr_id(event);
>>>       for (i = 0; i < n_ids; i++) {
>>>               perf_evlist__id_add(&evlist->core, &evsel->core, 0, i, ids[i]);
>>>       }
>>> diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
>>> index 00d18c74c090..1e9aa8ed15b6 100644
>>> --- a/tools/perf/util/session.c
>>> +++ b/tools/perf/util/session.c
>>> @@ -833,8 +833,8 @@ static void perf_event__hdr_attr_swap(union perf_event *event,
>>>       perf_event__attr_swap(&event->attr.attr);
>>>
>>>       size = event->header.size;
>>> -     size -= (void *)&event->attr.id - (void *)event;
>>> -     mem_bswap_64(event->attr.id, size);
>>> +     size -= perf_record_header_attr_id(event) - (void *)event;
>>> +     mem_bswap_64(perf_record_header_attr_id(event), size);
>>
>> Should this and below also be a fix for stable?
> 
> Then it'd need the perf_record_header_attr_id() change as well.
> Also I'm not sure if it's really needed for stable as it's a pipe output
> (saved to a file though) so very unlikely to have a different endian.
> 
> Thanks,
> Namhyung

Ok

For the patch set:

Acked-by: Adrian Hunter <adrian.hunter@intel.com>

> 
>>
>>>  }
>>>
>>>  static void perf_event__event_update_swap(union perf_event *event,
>>> diff --git a/tools/perf/util/synthetic-events.c b/tools/perf/util/synthetic-events.c
>>> index 45714a2785fd..a0579c7d7b9e 100644
>>> --- a/tools/perf/util/synthetic-events.c
>>> +++ b/tools/perf/util/synthetic-events.c
>>> @@ -2145,7 +2145,7 @@ int perf_event__synthesize_attr(struct perf_tool *tool, struct perf_event_attr *
>>>               return -ENOMEM;
>>>
>>>       ev->attr.attr = *attr;
>>> -     memcpy(ev->attr.id, id, ids * sizeof(u64));
>>> +     memcpy(perf_record_header_attr_id(ev), id, ids * sizeof(u64));
>>>
>>>       ev->attr.header.type = PERF_RECORD_HEADER_ATTR;
>>>       ev->attr.header.size = (u16)size;
>>


  reply	other threads:[~2023-08-30 18:34 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-25 15:25 [PATCH v2 1/4] perf tools: Handle old data in PERF_RECORD_ATTR Namhyung Kim
2023-08-25 15:25 ` [PATCH v2 2/4] tools/lib/perf: Add perf_record_header_attr_id() Namhyung Kim
2023-08-25 15:25 ` [PATCH v2 3/4] perf tools: Convert to perf_record_header_attr_id() Namhyung Kim
2023-08-28  7:59   ` Adrian Hunter
2023-08-30  2:15     ` Namhyung Kim
2023-08-30 13:54       ` Adrian Hunter [this message]
2023-08-25 15:25 ` [PATCH v2 4/4] tools/lib/perf: Get rid of attr.id field Namhyung Kim

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=8cc59832-6dcd-0270-ede9-a06ee3e6a66c@intel.com \
    --to=adrian.hunter@intel.com \
    --cc=acme@kernel.org \
    --cc=irogers@google.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung@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).