Skip to content

Commit 096a705

Browse files
committed
Merge branch 'for-3.1/core' of git://git.kernel.dk/linux-block
* 'for-3.1/core' of git://git.kernel.dk/linux-block: (24 commits) block: strict rq_affinity backing-dev: use synchronize_rcu_expedited instead of synchronize_rcu block: fix patch import error in max_discard_sectors check block: reorder request_queue to remove 64 bit alignment padding CFQ: add think time check for group CFQ: add think time check for service tree CFQ: move think time check variables to a separate struct fixlet: Remove fs_excl from struct task. cfq: Remove special treatment for metadata rqs. block: document blk_plug list access block: avoid building too big plug list compat_ioctl: fix make headers_check regression block: eliminate potential for infinite loop in blkdev_issue_discard compat_ioctl: fix warning caused by qemu block: flush MEDIA_CHANGE from drivers on close(2) blk-throttle: Make total_nr_queued unsigned block: Add __attribute__((format(printf...) and fix fallout fs/partitions/check.c: make local symbols static block:remove some spare spaces in genhd.c block:fix the comment error in blkdev.h ...
2 parents fea8031 + 5757a6d commit 096a705

28 files changed

+229
-208
lines changed

Documentation/block/queue-sysfs.txt

+7-3
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,13 @@ device.
4545

4646
rq_affinity (RW)
4747
----------------
48-
If this option is enabled, the block layer will migrate request completions
49-
to the CPU that originally submitted the request. For some workloads
50-
this provides a significant reduction in CPU cycles due to caching effects.
48+
If this option is '1', the block layer will migrate request completions to the
49+
cpu "group" that originally submitted the request. For some workloads this
50+
provides a significant reduction in CPU cycles due to caching effects.
51+
52+
For storage configurations that need to maximize distribution of completion
53+
processing setting this option to '2' forces the completion to run on the
54+
requesting cpu (bypassing the "group" aggregation logic).
5155

5256
scheduler (RW)
5357
--------------

block/blk-core.c

+7-4
Original file line numberDiff line numberDiff line change
@@ -1282,10 +1282,8 @@ static int __make_request(struct request_queue *q, struct bio *bio)
12821282
init_request_from_bio(req, bio);
12831283

12841284
if (test_bit(QUEUE_FLAG_SAME_COMP, &q->queue_flags) ||
1285-
bio_flagged(bio, BIO_CPU_AFFINE)) {
1286-
req->cpu = blk_cpu_to_group(get_cpu());
1287-
put_cpu();
1288-
}
1285+
bio_flagged(bio, BIO_CPU_AFFINE))
1286+
req->cpu = smp_processor_id();
12891287

12901288
plug = current->plug;
12911289
if (plug) {
@@ -1305,7 +1303,10 @@ static int __make_request(struct request_queue *q, struct bio *bio)
13051303
plug->should_sort = 1;
13061304
}
13071305
list_add_tail(&req->queuelist, &plug->list);
1306+
plug->count++;
13081307
drive_stat_acct(req, 1);
1308+
if (plug->count >= BLK_MAX_REQUEST_COUNT)
1309+
blk_flush_plug_list(plug, false);
13091310
} else {
13101311
spin_lock_irq(q->queue_lock);
13111312
add_acct_request(q, req, where);
@@ -2629,6 +2630,7 @@ void blk_start_plug(struct blk_plug *plug)
26292630
INIT_LIST_HEAD(&plug->list);
26302631
INIT_LIST_HEAD(&plug->cb_list);
26312632
plug->should_sort = 0;
2633+
plug->count = 0;
26322634

26332635
/*
26342636
* If this is a nested plug, don't actually assign it. It will be
@@ -2712,6 +2714,7 @@ void blk_flush_plug_list(struct blk_plug *plug, bool from_schedule)
27122714
return;
27132715

27142716
list_splice_init(&plug->list, &list);
2717+
plug->count = 0;
27152718

27162719
if (plug->should_sort) {
27172720
list_sort(NULL, &list, plug_rq_cmp);

block/blk-ioc.c

+20-20
Original file line numberDiff line numberDiff line change
@@ -82,26 +82,26 @@ void exit_io_context(struct task_struct *task)
8282

8383
struct io_context *alloc_io_context(gfp_t gfp_flags, int node)
8484
{
85-
struct io_context *ret;
85+
struct io_context *ioc;
8686

87-
ret = kmem_cache_alloc_node(iocontext_cachep, gfp_flags, node);
88-
if (ret) {
89-
atomic_long_set(&ret->refcount, 1);
90-
atomic_set(&ret->nr_tasks, 1);
91-
spin_lock_init(&ret->lock);
92-
ret->ioprio_changed = 0;
93-
ret->ioprio = 0;
94-
ret->last_waited = 0; /* doesn't matter... */
95-
ret->nr_batch_requests = 0; /* because this is 0 */
96-
INIT_RADIX_TREE(&ret->radix_root, GFP_ATOMIC | __GFP_HIGH);
97-
INIT_HLIST_HEAD(&ret->cic_list);
98-
ret->ioc_data = NULL;
87+
ioc = kmem_cache_alloc_node(iocontext_cachep, gfp_flags, node);
88+
if (ioc) {
89+
atomic_long_set(&ioc->refcount, 1);
90+
atomic_set(&ioc->nr_tasks, 1);
91+
spin_lock_init(&ioc->lock);
92+
ioc->ioprio_changed = 0;
93+
ioc->ioprio = 0;
94+
ioc->last_waited = 0; /* doesn't matter... */
95+
ioc->nr_batch_requests = 0; /* because this is 0 */
96+
INIT_RADIX_TREE(&ioc->radix_root, GFP_ATOMIC | __GFP_HIGH);
97+
INIT_HLIST_HEAD(&ioc->cic_list);
98+
ioc->ioc_data = NULL;
9999
#if defined(CONFIG_BLK_CGROUP) || defined(CONFIG_BLK_CGROUP_MODULE)
100-
ret->cgroup_changed = 0;
100+
ioc->cgroup_changed = 0;
101101
#endif
102102
}
103103

104-
return ret;
104+
return ioc;
105105
}
106106

107107
/*
@@ -139,19 +139,19 @@ struct io_context *current_io_context(gfp_t gfp_flags, int node)
139139
*/
140140
struct io_context *get_io_context(gfp_t gfp_flags, int node)
141141
{
142-
struct io_context *ret = NULL;
142+
struct io_context *ioc = NULL;
143143

144144
/*
145145
* Check for unlikely race with exiting task. ioc ref count is
146146
* zero when ioc is being detached.
147147
*/
148148
do {
149-
ret = current_io_context(gfp_flags, node);
150-
if (unlikely(!ret))
149+
ioc = current_io_context(gfp_flags, node);
150+
if (unlikely(!ioc))
151151
break;
152-
} while (!atomic_long_inc_not_zero(&ret->refcount));
152+
} while (!atomic_long_inc_not_zero(&ioc->refcount));
153153

154-
return ret;
154+
return ioc;
155155
}
156156
EXPORT_SYMBOL(get_io_context);
157157

block/blk-lib.c

+4-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,10 @@ int blkdev_issue_discard(struct block_device *bdev, sector_t sector,
5959
* granularity
6060
*/
6161
max_discard_sectors = min(q->limits.max_discard_sectors, UINT_MAX >> 9);
62-
if (q->limits.discard_granularity) {
62+
if (unlikely(!max_discard_sectors)) {
63+
/* Avoid infinite loop below. Being cautious never hurts. */
64+
return -EOPNOTSUPP;
65+
} else if (q->limits.discard_granularity) {
6366
unsigned int disc_sects = q->limits.discard_granularity >> 9;
6467

6568
max_discard_sectors &= ~(disc_sects - 1);

block/blk-softirq.c

+7-4
Original file line numberDiff line numberDiff line change
@@ -103,22 +103,25 @@ static struct notifier_block __cpuinitdata blk_cpu_notifier = {
103103

104104
void __blk_complete_request(struct request *req)
105105
{
106+
int ccpu, cpu, group_cpu = NR_CPUS;
106107
struct request_queue *q = req->q;
107108
unsigned long flags;
108-
int ccpu, cpu, group_cpu;
109109

110110
BUG_ON(!q->softirq_done_fn);
111111

112112
local_irq_save(flags);
113113
cpu = smp_processor_id();
114-
group_cpu = blk_cpu_to_group(cpu);
115114

116115
/*
117116
* Select completion CPU
118117
*/
119-
if (test_bit(QUEUE_FLAG_SAME_COMP, &q->queue_flags) && req->cpu != -1)
118+
if (test_bit(QUEUE_FLAG_SAME_COMP, &q->queue_flags) && req->cpu != -1) {
120119
ccpu = req->cpu;
121-
else
120+
if (!test_bit(QUEUE_FLAG_SAME_FORCE, &q->queue_flags)) {
121+
ccpu = blk_cpu_to_group(ccpu);
122+
group_cpu = blk_cpu_to_group(cpu);
123+
}
124+
} else
122125
ccpu = cpu;
123126

124127
if (ccpu == cpu || ccpu == group_cpu) {

block/blk-sysfs.c

+9-4
Original file line numberDiff line numberDiff line change
@@ -244,8 +244,9 @@ static ssize_t queue_nomerges_store(struct request_queue *q, const char *page,
244244
static ssize_t queue_rq_affinity_show(struct request_queue *q, char *page)
245245
{
246246
bool set = test_bit(QUEUE_FLAG_SAME_COMP, &q->queue_flags);
247+
bool force = test_bit(QUEUE_FLAG_SAME_FORCE, &q->queue_flags);
247248

248-
return queue_var_show(set, page);
249+
return queue_var_show(set << force, page);
249250
}
250251

251252
static ssize_t
@@ -257,10 +258,14 @@ queue_rq_affinity_store(struct request_queue *q, const char *page, size_t count)
257258

258259
ret = queue_var_store(&val, page, count);
259260
spin_lock_irq(q->queue_lock);
260-
if (val)
261+
if (val) {
261262
queue_flag_set(QUEUE_FLAG_SAME_COMP, q);
262-
else
263-
queue_flag_clear(QUEUE_FLAG_SAME_COMP, q);
263+
if (val == 2)
264+
queue_flag_set(QUEUE_FLAG_SAME_FORCE, q);
265+
} else {
266+
queue_flag_clear(QUEUE_FLAG_SAME_COMP, q);
267+
queue_flag_clear(QUEUE_FLAG_SAME_FORCE, q);
268+
}
264269
spin_unlock_irq(q->queue_lock);
265270
#endif
266271
return ret;

block/blk-throttle.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,9 @@ static inline struct throtl_grp *tg_of_blkg(struct blkio_group *blkg)
142142
return NULL;
143143
}
144144

145-
static inline int total_nr_queued(struct throtl_data *td)
145+
static inline unsigned int total_nr_queued(struct throtl_data *td)
146146
{
147-
return (td->nr_queued[0] + td->nr_queued[1]);
147+
return td->nr_queued[0] + td->nr_queued[1];
148148
}
149149

150150
static inline struct throtl_grp *throtl_ref_get_tg(struct throtl_grp *tg)
@@ -927,7 +927,7 @@ static int throtl_dispatch(struct request_queue *q)
927927

928928
bio_list_init(&bio_list_on_stack);
929929

930-
throtl_log(td, "dispatch nr_queued=%d read=%u write=%u",
930+
throtl_log(td, "dispatch nr_queued=%u read=%u write=%u",
931931
total_nr_queued(td), td->nr_queued[READ],
932932
td->nr_queued[WRITE]);
933933

@@ -970,7 +970,7 @@ throtl_schedule_delayed_work(struct throtl_data *td, unsigned long delay)
970970
struct delayed_work *dwork = &td->throtl_work;
971971

972972
/* schedule work if limits changed even if no bio is queued */
973-
if (total_nr_queued(td) > 0 || td->limits_changed) {
973+
if (total_nr_queued(td) || td->limits_changed) {
974974
/*
975975
* We might have a work scheduled to be executed in future.
976976
* Cancel that and schedule a new one.

0 commit comments

Comments
 (0)