diff options
author | Jens Axboe <jens.axboe@oracle.com> | 2008-01-24 02:52:45 -0500 |
---|---|---|
committer | Jens Axboe <jens.axboe@oracle.com> | 2008-01-28 04:50:29 -0500 |
commit | fd0928df98b9578be8a786ac0cb78a47a5e17a20 (patch) | |
tree | 70a34cf207bea1bec28e59cf0dba7d20e7f8b0f1 /include/linux | |
parent | 91525300baf162e83e923b09ca286f9205e21522 (diff) |
ioprio: move io priority from task_struct to io_context
This is where it belongs and then it doesn't take up space for a
process that doesn't do IO.
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
Diffstat (limited to 'include/linux')
-rw-r--r-- | include/linux/blkdev.h | 81 | ||||
-rw-r--r-- | include/linux/init_task.h | 1 | ||||
-rw-r--r-- | include/linux/iocontext.h | 79 | ||||
-rw-r--r-- | include/linux/ioprio.h | 13 | ||||
-rw-r--r-- | include/linux/sched.h | 1 |
5 files changed, 93 insertions, 82 deletions
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 49b7a4c31a6d..510a18ba1ec5 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h | |||
@@ -34,83 +34,10 @@ struct sg_io_hdr; | |||
34 | #define BLKDEV_MIN_RQ 4 | 34 | #define BLKDEV_MIN_RQ 4 |
35 | #define BLKDEV_MAX_RQ 128 /* Default maximum */ | 35 | #define BLKDEV_MAX_RQ 128 /* Default maximum */ |
36 | 36 | ||
37 | /* | ||
38 | * This is the per-process anticipatory I/O scheduler state. | ||
39 | */ | ||
40 | struct as_io_context { | ||
41 | spinlock_t lock; | ||
42 | |||
43 | void (*dtor)(struct as_io_context *aic); /* destructor */ | ||
44 | void (*exit)(struct as_io_context *aic); /* called on task exit */ | ||
45 | |||
46 | unsigned long state; | ||
47 | atomic_t nr_queued; /* queued reads & sync writes */ | ||
48 | atomic_t nr_dispatched; /* number of requests gone to the drivers */ | ||
49 | |||
50 | /* IO History tracking */ | ||
51 | /* Thinktime */ | ||
52 | unsigned long last_end_request; | ||
53 | unsigned long ttime_total; | ||
54 | unsigned long ttime_samples; | ||
55 | unsigned long ttime_mean; | ||
56 | /* Layout pattern */ | ||
57 | unsigned int seek_samples; | ||
58 | sector_t last_request_pos; | ||
59 | u64 seek_total; | ||
60 | sector_t seek_mean; | ||
61 | }; | ||
62 | |||
63 | struct cfq_queue; | ||
64 | struct cfq_io_context { | ||
65 | struct rb_node rb_node; | ||
66 | void *key; | ||
67 | |||
68 | struct cfq_queue *cfqq[2]; | ||
69 | |||
70 | struct io_context *ioc; | ||
71 | |||
72 | unsigned long last_end_request; | ||
73 | sector_t last_request_pos; | ||
74 | |||
75 | unsigned long ttime_total; | ||
76 | unsigned long ttime_samples; | ||
77 | unsigned long ttime_mean; | ||
78 | |||
79 | unsigned int seek_samples; | ||
80 | u64 seek_total; | ||
81 | sector_t seek_mean; | ||
82 | |||
83 | struct list_head queue_list; | ||
84 | |||
85 | void (*dtor)(struct io_context *); /* destructor */ | ||
86 | void (*exit)(struct io_context *); /* called on task exit */ | ||
87 | }; | ||
88 | |||
89 | /* | ||
90 | * This is the per-process I/O subsystem state. It is refcounted and | ||
91 | * kmalloc'ed. Currently all fields are modified in process io context | ||
92 | * (apart from the atomic refcount), so require no locking. | ||
93 | */ | ||
94 | struct io_context { | ||
95 | atomic_t refcount; | ||
96 | struct task_struct *task; | ||
97 | |||
98 | unsigned int ioprio_changed; | ||
99 | |||
100 | /* | ||
101 | * For request batching | ||
102 | */ | ||
103 | unsigned long last_waited; /* Time last woken after wait for request */ | ||
104 | int nr_batch_requests; /* Number of requests left in the batch */ | ||
105 | |||
106 | struct as_io_context *aic; | ||
107 | struct rb_root cic_root; | ||
108 | void *ioc_data; | ||
109 | }; | ||
110 | |||
111 | void put_io_context(struct io_context *ioc); | 37 | void put_io_context(struct io_context *ioc); |
112 | void exit_io_context(void); | 38 | void exit_io_context(void); |
113 | struct io_context *get_io_context(gfp_t gfp_flags, int node); | 39 | struct io_context *get_io_context(gfp_t gfp_flags, int node); |
40 | struct io_context *alloc_io_context(gfp_t gfp_flags, int node); | ||
114 | void copy_io_context(struct io_context **pdst, struct io_context **psrc); | 41 | void copy_io_context(struct io_context **pdst, struct io_context **psrc); |
115 | void swap_io_context(struct io_context **ioc1, struct io_context **ioc2); | 42 | void swap_io_context(struct io_context **ioc1, struct io_context **ioc2); |
116 | 43 | ||
@@ -894,6 +821,12 @@ static inline void exit_io_context(void) | |||
894 | { | 821 | { |
895 | } | 822 | } |
896 | 823 | ||
824 | static inline int put_io_context(struct io_context *ioc) | ||
825 | { | ||
826 | return 1; | ||
827 | } | ||
828 | |||
829 | |||
897 | #endif /* CONFIG_BLOCK */ | 830 | #endif /* CONFIG_BLOCK */ |
898 | 831 | ||
899 | #endif | 832 | #endif |
diff --git a/include/linux/init_task.h b/include/linux/init_task.h index 796019b22b6f..e6b3f7080679 100644 --- a/include/linux/init_task.h +++ b/include/linux/init_task.h | |||
@@ -137,7 +137,6 @@ extern struct group_info init_groups; | |||
137 | .time_slice = HZ, \ | 137 | .time_slice = HZ, \ |
138 | .nr_cpus_allowed = NR_CPUS, \ | 138 | .nr_cpus_allowed = NR_CPUS, \ |
139 | }, \ | 139 | }, \ |
140 | .ioprio = 0, \ | ||
141 | .tasks = LIST_HEAD_INIT(tsk.tasks), \ | 140 | .tasks = LIST_HEAD_INIT(tsk.tasks), \ |
142 | .ptrace_children= LIST_HEAD_INIT(tsk.ptrace_children), \ | 141 | .ptrace_children= LIST_HEAD_INIT(tsk.ptrace_children), \ |
143 | .ptrace_list = LIST_HEAD_INIT(tsk.ptrace_list), \ | 142 | .ptrace_list = LIST_HEAD_INIT(tsk.ptrace_list), \ |
diff --git a/include/linux/iocontext.h b/include/linux/iocontext.h new file mode 100644 index 000000000000..186807ea62e2 --- /dev/null +++ b/include/linux/iocontext.h | |||
@@ -0,0 +1,79 @@ | |||
1 | #ifndef IOCONTEXT_H | ||
2 | #define IOCONTEXT_H | ||
3 | |||
4 | /* | ||
5 | * This is the per-process anticipatory I/O scheduler state. | ||
6 | */ | ||
7 | struct as_io_context { | ||
8 | spinlock_t lock; | ||
9 | |||
10 | void (*dtor)(struct as_io_context *aic); /* destructor */ | ||
11 | void (*exit)(struct as_io_context *aic); /* called on task exit */ | ||
12 | |||
13 | unsigned long state; | ||
14 | atomic_t nr_queued; /* queued reads & sync writes */ | ||
15 | atomic_t nr_dispatched; /* number of requests gone to the drivers */ | ||
16 | |||
17 | /* IO History tracking */ | ||
18 | /* Thinktime */ | ||
19 | unsigned long last_end_request; | ||
20 | unsigned long ttime_total; | ||
21 | unsigned long ttime_samples; | ||
22 | unsigned long ttime_mean; | ||
23 | /* Layout pattern */ | ||
24 | unsigned int seek_samples; | ||
25 | sector_t last_request_pos; | ||
26 | u64 seek_total; | ||
27 | sector_t seek_mean; | ||
28 | }; | ||
29 | |||
30 | struct cfq_queue; | ||
31 | struct cfq_io_context { | ||
32 | struct rb_node rb_node; | ||
33 | void *key; | ||
34 | |||
35 | struct cfq_queue *cfqq[2]; | ||
36 | |||
37 | struct io_context *ioc; | ||
38 | |||
39 | unsigned long last_end_request; | ||
40 | sector_t last_request_pos; | ||
41 | |||
42 | unsigned long ttime_total; | ||
43 | unsigned long ttime_samples; | ||
44 | unsigned long ttime_mean; | ||
45 | |||
46 | unsigned int seek_samples; | ||
47 | u64 seek_total; | ||
48 | sector_t seek_mean; | ||
49 | |||
50 | struct list_head queue_list; | ||
51 | |||
52 | void (*dtor)(struct io_context *); /* destructor */ | ||
53 | void (*exit)(struct io_context *); /* called on task exit */ | ||
54 | }; | ||
55 | |||
56 | /* | ||
57 | * This is the per-process I/O subsystem state. It is refcounted and | ||
58 | * kmalloc'ed. Currently all fields are modified in process io context | ||
59 | * (apart from the atomic refcount), so require no locking. | ||
60 | */ | ||
61 | struct io_context { | ||
62 | atomic_t refcount; | ||
63 | struct task_struct *task; | ||
64 | |||
65 | unsigned short ioprio; | ||
66 | unsigned short ioprio_changed; | ||
67 | |||
68 | /* | ||
69 | * For request batching | ||
70 | */ | ||
71 | unsigned long last_waited; /* Time last woken after wait for request */ | ||
72 | int nr_batch_requests; /* Number of requests left in the batch */ | ||
73 | |||
74 | struct as_io_context *aic; | ||
75 | struct rb_root cic_root; | ||
76 | void *ioc_data; | ||
77 | }; | ||
78 | |||
79 | #endif | ||
diff --git a/include/linux/ioprio.h b/include/linux/ioprio.h index baf29387cab4..2a3bb1bb7433 100644 --- a/include/linux/ioprio.h +++ b/include/linux/ioprio.h | |||
@@ -2,6 +2,7 @@ | |||
2 | #define IOPRIO_H | 2 | #define IOPRIO_H |
3 | 3 | ||
4 | #include <linux/sched.h> | 4 | #include <linux/sched.h> |
5 | #include <linux/iocontext.h> | ||
5 | 6 | ||
6 | /* | 7 | /* |
7 | * Gives us 8 prio classes with 13-bits of data for each class | 8 | * Gives us 8 prio classes with 13-bits of data for each class |
@@ -45,18 +46,18 @@ enum { | |||
45 | * the cpu scheduler nice value to an io priority | 46 | * the cpu scheduler nice value to an io priority |
46 | */ | 47 | */ |
47 | #define IOPRIO_NORM (4) | 48 | #define IOPRIO_NORM (4) |
48 | static inline int task_ioprio(struct task_struct *task) | 49 | static inline int task_ioprio(struct io_context *ioc) |
49 | { | 50 | { |
50 | if (ioprio_valid(task->ioprio)) | 51 | if (ioprio_valid(ioc->ioprio)) |
51 | return IOPRIO_PRIO_DATA(task->ioprio); | 52 | return IOPRIO_PRIO_DATA(ioc->ioprio); |
52 | 53 | ||
53 | return IOPRIO_NORM; | 54 | return IOPRIO_NORM; |
54 | } | 55 | } |
55 | 56 | ||
56 | static inline int task_ioprio_class(struct task_struct *task) | 57 | static inline int task_ioprio_class(struct io_context *ioc) |
57 | { | 58 | { |
58 | if (ioprio_valid(task->ioprio)) | 59 | if (ioprio_valid(ioc->ioprio)) |
59 | return IOPRIO_PRIO_CLASS(task->ioprio); | 60 | return IOPRIO_PRIO_CLASS(ioc->ioprio); |
60 | 61 | ||
61 | return IOPRIO_CLASS_BE; | 62 | return IOPRIO_CLASS_BE; |
62 | } | 63 | } |
diff --git a/include/linux/sched.h b/include/linux/sched.h index df5b24ee80b3..80837e7d527e 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h | |||
@@ -975,7 +975,6 @@ struct task_struct { | |||
975 | struct hlist_head preempt_notifiers; | 975 | struct hlist_head preempt_notifiers; |
976 | #endif | 976 | #endif |
977 | 977 | ||
978 | unsigned short ioprio; | ||
979 | /* | 978 | /* |
980 | * fpu_counter contains the number of consecutive context switches | 979 | * fpu_counter contains the number of consecutive context switches |
981 | * that the FPU is used. If this is over a threshold, the lazy fpu | 980 | * that the FPU is used. If this is over a threshold, the lazy fpu |