linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: rainkin <rainkin1993@gmail.com>
To: Namhyung Kim <namhyung@gmail.com>
Cc: linux-perf-users <linux-perf-users@vger.kernel.org>
Subject: Re: [Question] How to sample PERF_TYPE_HARDWARE
Date: Thu, 18 Feb 2021 10:04:45 +0800	[thread overview]
Message-ID: <CAHb-xau-HhbuLL0aKyzmHjCixETcMNV7xGxGj_bBYoSVQd_R2w@mail.gmail.com> (raw)
In-Reply-To: <CAM9d7cg2qfQcNkH__XL8HUPSfsFqSwnYUXWCJZQLr06dip9RCw@mail.gmail.com>

Hi Namhyung,
Thanks for your reply.
Let me make my goal more clear: record the number of occurring branch
instructions (PERF_COUNT_HW_BRANCH_INSTRUCTIONS) every N cycles
(PERF_COUNT_HW_CPU_CYCLES).

For the command you mentioned : perf record -e branches -c N

I use strace to capture the syscall invoked by the above command:

perf_event_open({type=PERF_TYPE_HARDWARE, size=PERF_ATTR_SIZE_VER6,
config=PERF_COUNT_HW_BRANCH_INSTRUCTIONS, sample_period=100000,
sample_type=PERF_SAMPLE_IP|PERF_SAMPLE_TID|PERF_SAMPLE_TIME|PERF_SAMPLE_ID|PERF_SAMPLE_CPU,
read_format=PERF_FORMAT_ID, disabled=1, inherit=1, pinned=0,
exclusive=0, exclusive_user=0, exclude_kernel=0, exclude_hv=0,
exclude_idle=0, mmap=0, comm=0, freq=0, inherit_stat=0,
enable_on_exec=0, task=0, watermark=0, precise_ip=0 /* arbitrary skid
*/, mmap_data=0, sample_id_all=1, exclude_host=0, exclude_guest=1,
exclude_callchain_kernel=0, exclude_callchain_user=0, mmap2=0,
comm_exec=0, use_clockid=0, context_switch=0, write_backward=0,
namespaces=0, wakeup_events=0, config1=0, config2=0,
sample_regs_user=0, sample_regs_intr=0, aux_watermark=0,
sample_max_stack=0, aux_sample_size=0}, -1, 10, -1,
PERF_FLAG_FD_CLOEXEC)

In my understanding ,WHAT this command actually does is recording
IP,TID, and so on
(sample_type=PERF_SAMPLE_IP|PERF_SAMPLE_TID|PERF_SAMPLE_TIME|PERF_SAMPLE_ID|PERF_SAMPLE_CPU)
every N (here N = 100000) branches
(config=PERF_COUNT_HW_BRANCH_INSTRUCTIONS). Thus this cannot meet my
goal.

Thanks,
Rainkin

  parent reply	other threads:[~2021-02-18  2:06 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-08  3:47 [Question] How to sample PERF_TYPE_HARDWARE rainkin
2021-02-16  7:50 ` Namhyung Kim
2021-02-18  1:22   ` rainkin
2021-02-18  2:04   ` rainkin [this message]
2021-02-19  7:09     ` 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=CAHb-xau-HhbuLL0aKyzmHjCixETcMNV7xGxGj_bBYoSVQd_R2w@mail.gmail.com \
    --to=rainkin1993@gmail.com \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=namhyung@gmail.com \
    /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).