mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Divya Indi <divya.indi@oracle.com>
To: Steven Rostedt <rostedt@goodmis.org>, linux-kernel@vger.kernel.org
Cc: Divya Indi <divya.indi@oracle.com>, Joe Jin <joe.jin@oracle.com>,
	Srinivas Eeda <srinivas.eeda@oracle.com>,
	Aruna Ramakrishna <aruna.ramakrishna@oracle.com>,
	Manjunath Patil <manjunath.b.patil@oracle.com>
Subject: [RFC]Sample module for Kernel access to Ftrace instances.
Date: Fri, 20 Sep 2019 16:59:25 -0700	[thread overview]
Message-ID: <1569023966-23004-1-git-send-email-divya.indi@oracle.com> (raw)

[PATCH] tracing: Sample module to demonstrate kernel access to Ftrace

Hi,

This patch is for a sample module to demonstrate the use of APIs that 
were introduced/exported in order to access Ftrace instances from within the kernel.

Please Note: This module is dependent on -
- commit: f45d122 tracing: Kernel access to Ftrace instances
- Patches pending review: https://lore.kernel.org/lkml/1565805327-579-1-git-send-email-divya.indi@oracle.com/

The sample module creates/lookup a trace array called sample-instance on module load time. 
We then start a kernel thread(simple-thread) to -
1) Enable tracing for event "sample_event" to buffer associated with the trace array - "sample-instance".
2) Start a timer that will disable tracing to this buffer after 5 sec. (Tracing disabled after 5 sec ie at count=4)
3) Write to the buffer using trace_array_printk()
4) Stop the kernel thread and destroy the buffer during module unload.

A sample output for the same -

# tracer: nop
#
# entries-in-buffer/entries-written: 16/16   #P:4
#
#                              _-----=> irqs-off
#                             / _----=> need-resched
#                            | / _---=> hardirq/softirq
#                            || / _--=> preempt-depth
#                            ||| /     delay
#           TASK-PID   CPU#  ||||    TIMESTAMP  FUNCTION
#              | |       |   ||||       |         |
 sample-instance-26797 [003] .... 955180.489833: simple_thread: trace_array_printk: count=0
 sample-instance-26797 [003] .... 955180.489836: sample_event: count value=0 at jiffies=5249940864
 sample-instance-26797 [003] .... 955181.513722: simple_thread: trace_array_printk: count=1
 sample-instance-26797 [003] .... 955181.513724: sample_event: count value=1 at jiffies=5249941888
 sample-instance-26797 [003] .... 955182.537629: simple_thread: trace_array_printk: count=2
 sample-instance-26797 [003] .... 955182.537631: sample_event: count value=2 at jiffies=5249942912
 sample-instance-26797 [003] .... 955183.561516: simple_thread: trace_array_printk: count=3
 sample-instance-26797 [003] .... 955183.561518: sample_event: count value=3 at jiffies=5249943936
 sample-instance-26797 [003] .... 955184.585423: simple_thread: trace_array_printk: count=4
 sample-instance-26797 [003] .... 955184.585427: sample_event: count value=4 at jiffies=5249944960
 sample-instance-26797 [003] .... 955185.609344: simple_thread: trace_array_printk: count=5
 sample-instance-26797 [003] .... 955186.633241: simple_thread: trace_array_printk: count=6
 sample-instance-26797 [003] .... 955187.657157: simple_thread: trace_array_printk: count=7
 sample-instance-26797 [003] .... 955188.681039: simple_thread: trace_array_printk: count=8
 sample-instance-26797 [003] .... 955189.704937: simple_thread: trace_array_printk: count=9
 sample-instance-26797 [003] .... 955190.728840: simple_thread: trace_array_printk: count=10

Let me know if you have any questions.

Thanks,
Divya

             reply	other threads:[~2019-09-21  0:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-20 23:59 Divya Indi [this message]
2019-09-20 23:59 ` [PATCH] tracing: Sample module to demonstrate kernel " Divya Indi
2019-10-15 17:05   ` Steven Rostedt
2019-10-15 19:53     ` Divya Indi

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=1569023966-23004-1-git-send-email-divya.indi@oracle.com \
    --to=divya.indi@oracle.com \
    --cc=aruna.ramakrishna@oracle.com \
    --cc=joe.jin@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=manjunath.b.patil@oracle.com \
    --cc=rostedt@goodmis.org \
    --cc=srinivas.eeda@oracle.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

all inboxes | Powered by JetHome®