awslabs / damo

DAMON user-space tool
https://damonitor.github.io/
GNU General Public License v2.0
155 stars 26 forks source link

damo_record: Add --perf_path option and check its sanity #39

Closed honggyukim closed 1 year ago

honggyukim commented 1 year ago

This PR adds --perf_path option for damo record to provide a way to change the file path of perf.

In addition, the current way of testing perf is to check whether perf exists or not.

However, if the perf record doesn't work properly, then there is no need to proceed to the actual damo record.

This PR also makes damo record to check whether the given perf binary actually works.

Here are the example executions.

  $ ls /xxx/perf
  ls: cannot access '/xxx/perf': No such file or directory

  $ sudo ./damo record --perf_path=/xxx/perf $$
  perf not found at "/xxx/perf"

  $ file /usr/bin/perf
  /usr/bin/perf: Bourne-Again shell script, ASCII text executable

  $ sudo ./damo record --perf_path=/usr/bin/perf $$
  perf record not working with "/usr/bin/perf"

  $ file /home/honggyu/usr/bin/perf
  /home/honggyu/usr/bin/perf: ELF 64-bit LSB pie executable, x86-64, ...

  $ sudo ./damo record --perf_path=/home/honggyu/usr/bin/perf $$
  Press Ctrl+C to stop
  ^C
  signal 2 received
  [ perf record: Woken up 1 times to write data ]
  [ perf record: Captured and wrote 1.483 MB damon.data (153 samples) ]

Fixed: #38

sj-aws commented 1 year ago

Looks great to me, so just merged. Thank you for reporting the issue and even fixing it with this great PR, Honggyu!

honggyukim commented 1 year ago

Thanks very much for your help!