aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/elevator.h
diff options
context:
space:
mode:
authorJens Axboe <axboe@suse.de>2006-07-22 09:37:43 -0400
committerJens Axboe <axboe@nelson.home.kernel.dk>2006-09-30 14:29:36 -0400
commit4a893e837bb470867d74c05d6c6b97bba5a96185 (patch)
treea8795f4422eac82679309e1f1f500789c3fd9bff /include/linux/elevator.h
parentfc46379daf90dce57bf765c81d3b39f55150aac2 (diff)
[PATCH] elevator: define ioc counting mechanism
None of the in-kernel primitives for handling "atomic" counting seem to be a good fit. We need something that is essentially free for incrementing/decrementing, while the read side may be more expensive as we only ever need to do that when a device is removed from the kernel. Use a per-cpu variable for maintaining a per-cpu ioc count and define a reading mechanism that just sums up the values. Signed-off-by: Jens Axboe <axboe@suse.de>
Diffstat (limited to 'include/linux/elevator.h')
-rw-r--r--include/linux/elevator.h25
1 files changed, 25 insertions, 0 deletions
diff --git a/include/linux/elevator.h b/include/linux/elevator.h
index cc81645a3e18..9c5a04f6114c 100644
--- a/include/linux/elevator.h
+++ b/include/linux/elevator.h
@@ -1,6 +1,8 @@
1#ifndef _LINUX_ELEVATOR_H 1#ifndef _LINUX_ELEVATOR_H
2#define _LINUX_ELEVATOR_H 2#define _LINUX_ELEVATOR_H
3 3
4#include <linux/percpu.h>
5
4typedef int (elevator_merge_fn) (request_queue_t *, struct request **, 6typedef int (elevator_merge_fn) (request_queue_t *, struct request **,
5 struct bio *); 7 struct bio *);
6 8
@@ -178,4 +180,27 @@ enum {
178 INIT_LIST_HEAD(&(rq)->donelist); \ 180 INIT_LIST_HEAD(&(rq)->donelist); \
179 } while (0) 181 } while (0)
180 182
183/*
184 * io context count accounting
185 */
186#define elv_ioc_count_mod(name, __val) \
187 do { \
188 preempt_disable(); \
189 __get_cpu_var(name) += (__val); \
190 preempt_enable(); \
191 } while (0)
192
193#define elv_ioc_count_inc(name) elv_ioc_count_mod(name, 1)
194#define elv_ioc_count_dec(name) elv_ioc_count_mod(name, -1)
195
196#define elv_ioc_count_read(name) \
197({ \
198 unsigned long __val = 0; \
199 int __cpu; \
200 smp_wmb(); \
201 for_each_possible_cpu(__cpu) \
202 __val += per_cpu(name, __cpu); \
203 __val; \
204})
205
181#endif 206#endif