diff options
author | Andrea Bastoni <bastoni@cs.unc.edu> | 2010-05-29 23:53:40 -0400 |
---|---|---|
committer | Andrea Bastoni <bastoni@cs.unc.edu> | 2010-05-29 23:57:43 -0400 |
commit | 521422c4ef2c64731f709030915a7b301709f4b4 (patch) | |
tree | 07ea9440d38493652b3d2d32fb8ad1fe8fbee6f3 /litmus/sched_trace.c | |
parent | 8e9830a5bdb081fd3f4387db3a3838a687dfdad2 (diff) |
Update kfifo and spinlock_t in sched_trace.c
- kfifo needs to be defined and used differently (see include/linux/kfifo.h)
- spinlock -> raw_spinlock
- include slab.h when using kmalloc and friends
This commit compiles and is the logical end of the merge of Litmus and
2.6.34.
Diffstat (limited to 'litmus/sched_trace.c')
-rw-r--r-- | litmus/sched_trace.c | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/litmus/sched_trace.c b/litmus/sched_trace.c index ad0b138d4b01..1fa2094b0495 100644 --- a/litmus/sched_trace.c +++ b/litmus/sched_trace.c | |||
@@ -5,6 +5,7 @@ | |||
5 | #include <linux/semaphore.h> | 5 | #include <linux/semaphore.h> |
6 | 6 | ||
7 | #include <linux/fs.h> | 7 | #include <linux/fs.h> |
8 | #include <linux/slab.h> | ||
8 | #include <linux/miscdevice.h> | 9 | #include <linux/miscdevice.h> |
9 | #include <asm/uaccess.h> | 10 | #include <asm/uaccess.h> |
10 | #include <linux/module.h> | 11 | #include <linux/module.h> |
@@ -32,7 +33,7 @@ typedef struct { | |||
32 | rwlock_t del_lock; | 33 | rwlock_t del_lock; |
33 | 34 | ||
34 | /* the buffer */ | 35 | /* the buffer */ |
35 | struct kfifo *kfifo; | 36 | struct kfifo kfifo; |
36 | } ring_buffer_t; | 37 | } ring_buffer_t; |
37 | 38 | ||
38 | /* Main buffer structure */ | 39 | /* Main buffer structure */ |
@@ -49,25 +50,26 @@ typedef struct { | |||
49 | void rb_init(ring_buffer_t* buf) | 50 | void rb_init(ring_buffer_t* buf) |
50 | { | 51 | { |
51 | rwlock_init(&buf->del_lock); | 52 | rwlock_init(&buf->del_lock); |
52 | buf->kfifo = NULL; | ||
53 | } | 53 | } |
54 | 54 | ||
55 | int rb_alloc_buf(ring_buffer_t* buf, unsigned int size) | 55 | int rb_alloc_buf(ring_buffer_t* buf, unsigned int size) |
56 | { | 56 | { |
57 | unsigned long flags; | 57 | unsigned long flags; |
58 | int ret = 0; | ||
58 | 59 | ||
59 | write_lock_irqsave(&buf->del_lock, flags); | 60 | write_lock_irqsave(&buf->del_lock, flags); |
60 | 61 | ||
61 | buf->kfifo = kfifo_alloc(size, GFP_ATOMIC, NULL); | 62 | /* kfifo size must be a power of 2 |
63 | * atm kfifo alloc is automatically rounding the size | ||
64 | */ | ||
65 | ret = kfifo_alloc(&buf->kfifo, size, GFP_ATOMIC); | ||
62 | 66 | ||
63 | write_unlock_irqrestore(&buf->del_lock, flags); | 67 | write_unlock_irqrestore(&buf->del_lock, flags); |
64 | 68 | ||
65 | if(IS_ERR(buf->kfifo)) { | 69 | if(ret < 0) |
66 | printk(KERN_ERR "kfifo_alloc failed\n"); | 70 | printk(KERN_ERR "kfifo_alloc failed\n"); |
67 | return PTR_ERR(buf->kfifo); | ||
68 | } | ||
69 | 71 | ||
70 | return 0; | 72 | return ret; |
71 | } | 73 | } |
72 | 74 | ||
73 | int rb_free_buf(ring_buffer_t* buf) | 75 | int rb_free_buf(ring_buffer_t* buf) |
@@ -76,10 +78,8 @@ int rb_free_buf(ring_buffer_t* buf) | |||
76 | 78 | ||
77 | write_lock_irqsave(&buf->del_lock, flags); | 79 | write_lock_irqsave(&buf->del_lock, flags); |
78 | 80 | ||
79 | BUG_ON(!buf->kfifo); | 81 | BUG_ON(!kfifo_initialized(&buf->kfifo)); |
80 | kfifo_free(buf->kfifo); | 82 | kfifo_free(&buf->kfifo); |
81 | |||
82 | buf->kfifo = NULL; | ||
83 | 83 | ||
84 | write_unlock_irqrestore(&buf->del_lock, flags); | 84 | write_unlock_irqrestore(&buf->del_lock, flags); |
85 | 85 | ||
@@ -98,12 +98,12 @@ int rb_put(ring_buffer_t* buf, char* mem, size_t len) | |||
98 | 98 | ||
99 | read_lock_irqsave(&buf->del_lock, flags); | 99 | read_lock_irqsave(&buf->del_lock, flags); |
100 | 100 | ||
101 | if (!buf->kfifo) { | 101 | if (!kfifo_initialized(&buf->kfifo)) { |
102 | error = -ENODEV; | 102 | error = -ENODEV; |
103 | goto out; | 103 | goto out; |
104 | } | 104 | } |
105 | 105 | ||
106 | if((__kfifo_put(buf->kfifo, mem, len)) < len) { | 106 | if((kfifo_in(&buf->kfifo, mem, len)) < len) { |
107 | error = -ENOMEM; | 107 | error = -ENOMEM; |
108 | goto out; | 108 | goto out; |
109 | } | 109 | } |
@@ -120,12 +120,12 @@ int rb_get(ring_buffer_t* buf, char* mem, size_t len) | |||
120 | int error = 0; | 120 | int error = 0; |
121 | 121 | ||
122 | read_lock_irqsave(&buf->del_lock, flags); | 122 | read_lock_irqsave(&buf->del_lock, flags); |
123 | if (!buf->kfifo) { | 123 | if (!kfifo_initialized(&buf->kfifo)) { |
124 | error = -ENODEV; | 124 | error = -ENODEV; |
125 | goto out; | 125 | goto out; |
126 | } | 126 | } |
127 | 127 | ||
128 | error = __kfifo_get(buf->kfifo, (unsigned char*)mem, len); | 128 | error = kfifo_out(&buf->kfifo, (unsigned char*)mem, len); |
129 | 129 | ||
130 | out: | 130 | out: |
131 | read_unlock_irqrestore(&buf->del_lock, flags); | 131 | read_unlock_irqrestore(&buf->del_lock, flags); |
@@ -135,7 +135,7 @@ int rb_get(ring_buffer_t* buf, char* mem, size_t len) | |||
135 | /* | 135 | /* |
136 | * Device Driver management | 136 | * Device Driver management |
137 | */ | 137 | */ |
138 | static spinlock_t log_buffer_lock = SPIN_LOCK_UNLOCKED; | 138 | static DEFINE_RAW_SPINLOCK(log_buffer_lock); |
139 | static trace_buffer_t log_buffer; | 139 | static trace_buffer_t log_buffer; |
140 | 140 | ||
141 | static void init_log_buffer(void) | 141 | static void init_log_buffer(void) |
@@ -170,12 +170,12 @@ void sched_trace_log_message(const char* fmt, ...) | |||
170 | buf = __get_cpu_var(fmt_buffer); | 170 | buf = __get_cpu_var(fmt_buffer); |
171 | len = vscnprintf(buf, MSG_SIZE, fmt, args); | 171 | len = vscnprintf(buf, MSG_SIZE, fmt, args); |
172 | 172 | ||
173 | spin_lock(&log_buffer_lock); | 173 | raw_spin_lock(&log_buffer_lock); |
174 | /* Don't copy the trailing null byte, we don't want null bytes | 174 | /* Don't copy the trailing null byte, we don't want null bytes |
175 | * in a text file. | 175 | * in a text file. |
176 | */ | 176 | */ |
177 | rb_put(&log_buffer.buf, buf, len); | 177 | rb_put(&log_buffer.buf, buf, len); |
178 | spin_unlock(&log_buffer_lock); | 178 | raw_spin_unlock(&log_buffer_lock); |
179 | 179 | ||
180 | local_irq_restore(flags); | 180 | local_irq_restore(flags); |
181 | va_end(args); | 181 | va_end(args); |
@@ -265,8 +265,8 @@ static int log_open(struct inode *in, struct file *filp) | |||
265 | filp->private_data = tbuf; | 265 | filp->private_data = tbuf; |
266 | 266 | ||
267 | printk(KERN_DEBUG | 267 | printk(KERN_DEBUG |
268 | "sched_trace kfifo at 0x%p with buffer starting at: 0x%p\n", | 268 | "sched_trace kfifo with buffer starting at: 0x%p\n", |
269 | tbuf->buf.kfifo, &((tbuf->buf.kfifo)->buffer)); | 269 | (tbuf->buf.kfifo).buffer); |
270 | 270 | ||
271 | /* override printk() */ | 271 | /* override printk() */ |
272 | trace_override++; | 272 | trace_override++; |