All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paulo Miguel Almeida <paulo.miguel.almeida.rodenas@gmail.com>
To: linux-trace-devel@vger.kernel.org
Cc: paulo.miguel.almeida.rodenas@gmail.com
Subject: Re: [PATCH v2] trace-cmd: open code execvp routine to avoid multiple execve syscalls
Date: Sat, 14 Jan 2023 17:58:54 +1300	[thread overview]
Message-ID: <Y8I2jseKDuV0PzUJ@mail.google.com> (raw)
In-Reply-To: <Y8HjyE3qnmsAtrM9@mail.google.com>

On Sat, Jan 14, 2023 at 12:05:44PM +1300, Paulo Miguel Almeida wrote:
> On Sat, Jan 14, 2023 at 11:58:41AM +1300, Paulo Miguel Almeida wrote:
> > In tracecmd/trace-record.c:<run_cmd>, trace-cmd record -F <executable>
> > is launched via the libc's execvp() routine. The way that execvp() routine
> > works is by invoking execve syscall for every entry on the $PATH if
> > command specified is neither absolute nor relative which can come across
> > as a bit cryptic to untrained eyes.
> > 
> > - absolute path example:
> > 
> >         # trace-cmd record -p function_graph \
> >                 -g __x64_sys_execve -O nofuncgraph-irqs \
> >                 -n __cond_resched --max-graph-depth 1  \
> >                 -F /usr/bin/echo "ftrace" > /dev/null
> > 
> >         # trace-cmd report
> >         echo-172994 [000] 185539.798539: funcgraph_entry:      ! 803.376 us |  __x64_sys_execve();
> > 
> > - PATH-dependent path example:
> > 
> >         # trace-cmd record -p function_graph \
> >                 -g __x64_sys_execve -O nofuncgraph-irqs \
> >                 -n __cond_resched --max-graph-depth 1  \
> >                 -F echo "ftrace" > /dev/null
> > 
> >         # trace-cmd report
> >         echo-172656 [002] 185009.671586: funcgraph_entry:      ! 288.732 us |  __x64_sys_execve();
> >         echo-172656 [002] 185009.671879: funcgraph_entry:      ! 158.337 us |  __x64_sys_execve();
> >         echo-172656 [002] 185009.672042: funcgraph_entry:      ! 161.843 us |  __x64_sys_execve();
> >         echo-172656 [002] 185009.672207: funcgraph_entry:      ! 157.656 us |  __x64_sys_execve();
> >         echo-172656 [002] 185009.672369: funcgraph_entry:      ! 156.343 us |  __x64_sys_execve();
> >         echo-172656 [002] 185009.672529: funcgraph_entry:      ! 863.629 us |  __x64_sys_execve();
> > 
> > Open code the libc's execvp routine into trace-cmd so ftrace will only
> > start recording once the command is found when it needs to be found in
> > PATH.
> > 
> > Signed-off-by: Paulo Miguel Almeida <paulo.miguel.almeida.rodenas@gmail.com>
> > ---
> > Changelog:
> > 
> > - v2: open code execvp routine into trace-cmd. (Req. Steve Rostedt)
> > - v1: https://lore.kernel.org/linux-trace-devel/Y7dUo6woh9Y31cdl@mail.google.com/
> > ---
> 
> Ignore this patch. I just realised that I didn't tweak the CUnit tests.
> I will submit another patch shortly.
> 
> - Paulo A.

False alarm Steve. You can review this patch as it is :-)

The error I was getting before:

---
Suite: trace-cmd
  Test: Simple record and report ...passed
  Test: Test convert from v7 to v6 ...passed
  Test: Use libraries to read file ...FAILED
    1. tracecmd-utest.c:441  - data.counter > 0
  Test: Test max length ...passed

Run Summary:    Type  Total    Ran Passed Failed Inactive
              suites      1      1    n/a      0        0
               tests      4      4      3      1        0
             asserts     24     24     23      1      n/a

Elapsed time =    0.193 seconds
---

After git bisect'ing the error I realised that my commit has nothing
to do with the CUnit test failure given that this particular test case
has been failing for me since its introduction to the code base on
commit <d83b6628927326d158>.

Regardless of what fix it requires, I'm assuming that would be done
in a different patch anyway. So as soon as this one is reviewed and
merged, I'm happy to further investigate the other :-)

thanks!

- Paulo A.

  reply	other threads:[~2023-01-14  4:59 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-05 22:52 [PATCH] trace-cmd: document expected behaviour of execvp for record command Paulo Miguel Almeida
2023-01-05 23:13 ` Steven Rostedt
2023-01-06  2:09   ` Paulo Miguel Almeida
2023-01-06  3:07     ` Steven Rostedt
2023-01-13 22:58       ` [PATCH v2] trace-cmd: open code execvp routine to avoid multiple execve syscalls Paulo Miguel Almeida
2023-01-13 23:05         ` Paulo Miguel Almeida
2023-01-14  4:58           ` Paulo Miguel Almeida [this message]
2023-01-14  5:51         ` Steven Rostedt
2023-01-14 14:43           ` Steven Rostedt

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=Y8I2jseKDuV0PzUJ@mail.google.com \
    --to=paulo.miguel.almeida.rodenas@gmail.com \
    --cc=linux-trace-devel@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.