aboutsummaryrefslogtreecommitdiffstats
path: root/litmus/sched_task_trace.c
diff options
context:
space:
mode:
Diffstat (limited to 'litmus/sched_task_trace.c')
-rw-r--r--litmus/sched_task_trace.c35
1 files changed, 28 insertions, 7 deletions
diff --git a/litmus/sched_task_trace.c b/litmus/sched_task_trace.c
index 7ef7b2889b42..a15b25d21a89 100644
--- a/litmus/sched_task_trace.c
+++ b/litmus/sched_task_trace.c
@@ -38,12 +38,17 @@ static int st_dev_can_open(struct ftdev *dev, unsigned int cpu)
38static int __init init_sched_task_trace(void) 38static int __init init_sched_task_trace(void)
39{ 39{
40 struct local_buffer* buf; 40 struct local_buffer* buf;
41 int i, ok = 0; 41 int i, ok = 0, err;
42 printk("Allocated %u sched_trace_xxx() events per CPU " 42 printk("Allocated %u sched_trace_xxx() events per CPU "
43 "(buffer size: %d bytes)\n", 43 "(buffer size: %d bytes)\n",
44 NO_EVENTS, (int) sizeof(struct local_buffer)); 44 NO_EVENTS, (int) sizeof(struct local_buffer));
45 ftdev_init(&st_dev, THIS_MODULE, "sched_trace"); 45
46 for (i = 0; i < NR_CPUS; i++) { 46 err = ftdev_init(&st_dev, THIS_MODULE,
47 num_online_cpus(), "sched_trace");
48 if (err)
49 goto err_out;
50
51 for (i = 0; i < st_dev.minor_cnt; i++) {
47 buf = &per_cpu(st_event_buffer, i); 52 buf = &per_cpu(st_event_buffer, i);
48 ok += init_ft_buffer(&buf->ftbuf, NO_EVENTS, 53 ok += init_ft_buffer(&buf->ftbuf, NO_EVENTS,
49 sizeof(struct st_event_record), 54 sizeof(struct st_event_record),
@@ -51,16 +56,32 @@ static int __init init_sched_task_trace(void)
51 buf->record); 56 buf->record);
52 st_dev.minor[i].buf = &buf->ftbuf; 57 st_dev.minor[i].buf = &buf->ftbuf;
53 } 58 }
54 if (ok == NR_CPUS) { 59 if (ok == st_dev.minor_cnt) {
55 st_dev.minor_cnt = NR_CPUS;
56 st_dev.can_open = st_dev_can_open; 60 st_dev.can_open = st_dev_can_open;
57 return register_ftdev(&st_dev); 61 err = register_ftdev(&st_dev);
62 if (err)
63 goto err_dealloc;
58 } else { 64 } else {
59 return -EINVAL; 65 err = -EINVAL;
66 goto err_dealloc;
60 } 67 }
68
69 return 0;
70
71err_dealloc:
72 ftdev_exit(&st_dev);
73err_out:
74 printk(KERN_WARNING "Could not register sched_trace module\n");
75 return err;
76}
77
78static void __exit exit_sched_task_trace(void)
79{
80 ftdev_exit(&st_dev);
61} 81}
62 82
63module_init(init_sched_task_trace); 83module_init(init_sched_task_trace);
84module_exit(exit_sched_task_trace);
64 85
65 86
66static inline struct st_event_record* get_record(u8 type, struct task_struct* t) 87static inline struct st_event_record* get_record(u8 type, struct task_struct* t)