From: richard clark <richard.xnu.clark@gmail.com>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: bristot@kernel.org, linux-trace-devel@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: Question about 'for_each_kernel_tracepoint(...)' function
Date: Fri, 21 Oct 2022 09:43:14 +0800 [thread overview]
Message-ID: <CAJNi4rMVUzfZJPge=ncaULD87wLQ4TwWS=oKDuC1hZMoWi0OjA@mail.gmail.com> (raw)
In-Reply-To: <20221020111439.76e72230@gandalf.local.home>
On Thu, Oct 20, 2022 at 11:14 PM Steven Rostedt <rostedt@goodmis.org> wrote:
>
> On Thu, 20 Oct 2022 17:32:57 +0800
> richard clark <richard.xnu.clark@gmail.com> wrote:
>
> > Hi,
> > Can this function only find the trace points defined in the kernel
>
> It should find all tracepoints.
I defined an event trace point in module B(in the header file):
...
#define TRACE_SYSTEM cus_tp
...
TRACE_EVENT(function_event_a,
/* all the data struct parameter is in form of pointer instead
of object */
TP_PROTO(enum event ev),
TP_ARGS(ev),
...
);
After the module B inserted, the output is:
root@robotics:/sys/kernel/debug/tracing# cat available_events | grep func
cus_tp:function_event_a
Then I inserted module A with below code snippet:
void fc(struct tracepoint *ktp, void *priv)
{
pr_info("events: %s\n", ktp->name);
}
static int module_A_init(void)
{
for_each_kernel_tracepoint(fc, NULL);
return 0;
}
Then I insert the module A into the system with module B is inserted,
the dmesg shows:
root@ robotics:/home/robotics/evt-tp# dmesg | grep func
[149421.718576] events: call_function_entry
[149421.718578] events: call_function_exit
[149421.718579] events: call_function_single_entry
[149421.718581] events: call_function_single_exit
So Steve you can see that the 'for_each_kernel_tracepoint' doesn't
find the event tp defined in module B, but that tp indeed shows in
/sys/kernel/debug/tracing/available_events.
Any comments about that?
>
> > image? I want to define a trace event in my kernel module A, then B
> > module to register a probe callback function for that event TP in A. I
> > want to kick off a timer in A and call the traced function
> > periodically, thus I can monitor the events happening in A from B.
>
> You could also export the tracepoint from A and reference it directly in B.
>
> >
> > Can I do that, is it possible?
> >
>
> Try it and find out. Why ask?
Ah, as you can see that I did it, but the result is not what I
expected :-). Help?
Richard
>
> -- Steve
next prev parent reply other threads:[~2022-10-21 1:43 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-20 9:32 Question about 'for_each_kernel_tracepoint(...)' function richard clark
2022-10-20 15:14 ` Steven Rostedt
2022-10-21 1:43 ` richard clark [this message]
2022-10-21 2:12 ` Steven Rostedt
2022-10-21 3:51 ` richard clark
2022-10-21 12:32 ` Steven Rostedt
2022-10-22 2:55 ` richard clark
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='CAJNi4rMVUzfZJPge=ncaULD87wLQ4TwWS=oKDuC1hZMoWi0OjA@mail.gmail.com' \
--to=richard.xnu.clark@gmail.com \
--cc=bristot@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-devel@vger.kernel.org \
--cc=rostedt@goodmis.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).