summaryrefslogtreecommitdiffstats
path: root/runtime/probes/tasklet/stp_tasklet.c
blob: c6e7b132602216f9de60b741fa9b942b0a96828f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/* Framework for putting a jprobe in a tasklet. */
/* Useful for testing probes in interrupt context. */
/* Doesn't do anything useful as is.  Put test code in the inst func */

#define STP_NETLINK_ONLY
#define STP_NUM_STRINGS 1

static unsigned n_subbufs = 4;
static unsigned subbuf_size = 65536;

#include "runtime.h"

#ifdef STP_NETLINK_ONLY
static int transport_mode = STP_TRANSPORT_NETLINK;
#else
static int transport_mode = STP_TRANSPORT_RELAYFS;
#endif

#include "probes.c"

MODULE_DESCRIPTION("test jprobes of tasklets");
MODULE_AUTHOR("Martin Hunt <hunt@redhat.com>");

void inst__rcu_process_callbacks(struct rcu_ctrlblk *rcp,
				 struct rcu_state *rsp, struct rcu_data *rdp)
{  
  _stp_printf ("count=%d irqs_disabled=%d in_interrupt=%d in_irq=%d", 
	       preempt_count(), irqs_disabled(), in_interrupt(), in_irq());
  _stp_print_flush();
  jprobe_return();
}

static struct jprobe stp_probes[] = {
  {
    .kp.addr =  (kprobe_opcode_t *)"__rcu_process_callbacks",
    .entry = (kprobe_opcode_t *) inst__rcu_process_callbacks
  },
};
#define MAX_STP_PROBES (sizeof(stp_probes)/sizeof(struct jprobe))

static int pid;
module_param(pid, int, 0);
MODULE_PARM_DESC(pid, "daemon pid");

int init_module(void)
{
  int ret;
  
  if (!pid) 
    {
      printk("init_dtr: Can't start without daemon pid\n");		
      return -1;
    }
  
  if (_stp_transport_open(transport_mode, n_subbufs, subbuf_size, pid) < 0) {
    printk("init_dtr: Couldn't open transport\n");		
    return -1;
  }
  
  ret = _stp_register_jprobes (stp_probes, MAX_STP_PROBES);
  return ret;
}

static void probe_exit (void)
{
  _stp_unregister_jprobes (stp_probes, MAX_STP_PROBES);
}

void cleanup_module(void)
{
  _stp_transport_close();
}

MODULE_LICENSE("GPL");