<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel.git/block/cfq-iosched.c, branch linux-2.6.35.y</title>
<subtitle>Hosts the 0x221E linux distro kernel.
</subtitle>
<id>https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-2.6.35.y</id>
<link rel='self' href='https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-2.6.35.y'/>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/'/>
<updated>2011-08-01T20:54:58Z</updated>
<entry>
<title>cfq-iosched: fix a rcu warning</title>
<updated>2011-08-01T20:54:58Z</updated>
<author>
<name>Shaohua Li</name>
</author>
<published>2011-06-27T07:03:47Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=3cc36915ad70bb028e8b4f748ed4a4e99834e3c0'/>
<id>urn:sha1:3cc36915ad70bb028e8b4f748ed4a4e99834e3c0</id>
<content type='text'>
commit 3181faa85bda3dc3f5e630a1846526c9caaa38e3 upstream.

I got a rcu warnning at boot. the ioc-&gt;ioc_data is rcu_deferenced, but
doesn't hold rcu_read_lock.

Signed-off-by: Shaohua Li &lt;shaohua.li@intel.com&gt;
Signed-off-by: Jens Axboe &lt;jaxboe@fusionio.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@suse.de&gt;
Signed-off-by: Andi Kleen &lt;ak@linux.intel.com&gt;

</content>
</entry>
<entry>
<title>cfq-iosched: fix locking around ioc-&gt;ioc_data assignment</title>
<updated>2011-08-01T20:54:58Z</updated>
<author>
<name>Jens Axboe</name>
</author>
<published>2011-06-05T04:01:13Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=cf4ca69d46d49eb6fd8803f6618dd60184892835'/>
<id>urn:sha1:cf4ca69d46d49eb6fd8803f6618dd60184892835</id>
<content type='text'>
commit ab4bd22d3cce6977dc039664cc2d052e3147d662 upstream.

Since we are modifying this RCU pointer, we need to hold
the lock protecting it around it.

This fixes a potential reuse and double free of a cfq
io_context structure. The bug has been in CFQ for a long
time, it hit very few people but those it did hit seemed
to see it a lot.

Tracked in RH bugzilla here:

https://bugzilla.redhat.com/show_bug.cgi?id=577968

Credit goes to Paul Bolle for figuring out that the issue
was around the one-hit ioc-&gt;ioc_data cache. Thanks to his
hard work the issue is now fixed.

Signed-off-by: Jens Axboe &lt;jaxboe@fusionio.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@suse.de&gt;
Signed-off-by: Andi Kleen &lt;ak@linux.intel.com&gt;

</content>
</entry>
<entry>
<title>cfq-iosched: Fixed boot warning with BLK_CGROUP=y and CFQ_GROUP_IOSCHED=n</title>
<updated>2010-06-18T17:57:47Z</updated>
<author>
<name>Vivek Goyal</name>
</author>
<published>2010-06-18T14:39:47Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=e98ef89b30b8a2e882b11d4965347015770f3627'/>
<id>urn:sha1:e98ef89b30b8a2e882b11d4965347015770f3627</id>
<content type='text'>
Hi Jens,

Few days back Ingo noticed a CFQ boot time warning. This patch fixes it.
The issue here is that with CFQ_GROUP_IOSCHED=n, CFQ should not really
be making blkio stat related calls.

&gt; Hm, it's still not entirely fixed, as of 2.6.35-rc2-00131-g7908a9e. With
&gt; some
&gt; configs i get bad spinlock warnings during bootup:
&gt;
&gt; [   28.968013] initcall net_olddevs_init+0x0/0x82 returned 0 after 93750
&gt; usecs
&gt; [   28.972003] calling  b44_init+0x0/0x55 @ 1
&gt; [   28.976009] bus: 'pci': add driver b44
&gt; [   28.976374]  sda:
&gt; [   28.978157] BUG: spinlock bad magic on CPU#1, async/0/117
&gt; [   28.980000]  lock: 7e1c5bbc, .magic: 00000000, .owner: &lt;none&gt;/-1, +.owner_cpu: 0
&gt; [   28.980000] Pid: 117, comm: async/0 Not tainted +2.6.35-rc2-tip-01092-g010e7ef-dirty #8183
&gt; [   28.980000] Call Trace:
&gt; [   28.980000]  [&lt;41ba6d55&gt;] ? printk+0x20/0x24
&gt; [   28.980000]  [&lt;4134b7b7&gt;] spin_bug+0x7c/0x87
&gt; [   28.980000]  [&lt;4134b853&gt;] do_raw_spin_lock+0x1e/0x123
&gt; [   28.980000]  [&lt;41ba92ca&gt;] ? _raw_spin_lock_irqsave+0x12/0x20
&gt; [   28.980000]  [&lt;41ba92d2&gt;] _raw_spin_lock_irqsave+0x1a/0x20
&gt; [   28.980000]  [&lt;4133476f&gt;] blkiocg_update_io_add_stats+0x25/0xfb
&gt; [   28.980000]  [&lt;41335dae&gt;] ? cfq_prio_tree_add+0xb1/0xc1
&gt; [   28.980000]  [&lt;41337bc7&gt;] cfq_insert_request+0x8c/0x425

Signed-off-by: Vivek Goyal &lt;vgoyal@redhat.com&gt;
Signed-off-by: Jens Axboe &lt;jaxboe@fusionio.com&gt;
</content>
</entry>
<entry>
<title>cfq: Don't allow queue merges for queues that have no process references</title>
<updated>2010-06-17T18:17:35Z</updated>
<author>
<name>Jeff Moyer</name>
</author>
<published>2010-06-17T14:19:11Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=c10b61f0910466b4b99c266a7d76ac4390743fb5'/>
<id>urn:sha1:c10b61f0910466b4b99c266a7d76ac4390743fb5</id>
<content type='text'>
Hi,

A user reported a kernel bug when running a particular program that did
the following:

created 32 threads
- each thread took a mutex, grabbed a global offset, added a buffer size
  to that offset, released the lock
- read from the given offset in the file
- created a new thread to do the same
- exited

The result is that cfq's close cooperator logic would trigger, as the
threads were issuing I/O within the mean seek distance of one another.
This workload managed to routinely trigger a use after free bug when
walking the list of merge candidates for a particular cfqq
(cfqq-&gt;new_cfqq).  The logic used for merging queues looks like this:

static void cfq_setup_merge(struct cfq_queue *cfqq, struct cfq_queue *new_cfqq)
{
	int process_refs, new_process_refs;
	struct cfq_queue *__cfqq;

	/* Avoid a circular list and skip interim queue merges */
	while ((__cfqq = new_cfqq-&gt;new_cfqq)) {
		if (__cfqq == cfqq)
			return;
		new_cfqq = __cfqq;
	}

	process_refs = cfqq_process_refs(cfqq);
	/*
	 * If the process for the cfqq has gone away, there is no
	 * sense in merging the queues.
	 */
	if (process_refs == 0)
		return;

	/*
	 * Merge in the direction of the lesser amount of work.
	 */
	new_process_refs = cfqq_process_refs(new_cfqq);
	if (new_process_refs &gt;= process_refs) {
		cfqq-&gt;new_cfqq = new_cfqq;
		atomic_add(process_refs, &amp;new_cfqq-&gt;ref);
	} else {
		new_cfqq-&gt;new_cfqq = cfqq;
		atomic_add(new_process_refs, &amp;cfqq-&gt;ref);
	}
}

When a merge candidate is found, we add the process references for the
queue with less references to the queue with more.  The actual merging
of queues happens when a new request is issued for a given cfqq.  In the
case of the test program, it only does a single pread call to read in
1MB, so the actual merge never happens.

Normally, this is fine, as when the queue exits, we simply drop the
references we took on the other cfqqs in the merge chain:

	/*
	 * If this queue was scheduled to merge with another queue, be
	 * sure to drop the reference taken on that queue (and others in
	 * the merge chain).  See cfq_setup_merge and cfq_merge_cfqqs.
	 */
	__cfqq = cfqq-&gt;new_cfqq;
	while (__cfqq) {
		if (__cfqq == cfqq) {
			WARN(1, "cfqq-&gt;new_cfqq loop detected\n");
			break;
		}
		next = __cfqq-&gt;new_cfqq;
		cfq_put_queue(__cfqq);
		__cfqq = next;
	}

However, there is a hole in this logic.  Consider the following (and
keep in mind that each I/O keeps a reference to the cfqq):

q1-&gt;new_cfqq = q2   // q2 now has 2 process references
q3-&gt;new_cfqq = q2   // q2 now has 3 process references

// the process associated with q2 exits
// q2 now has 2 process references

// queue 1 exits, drops its reference on q2
// q2 now has 1 process reference

// q3 exits, so has 0 process references, and hence drops its references
// to q2, which leaves q2 also with 0 process references

q4 comes along and wants to merge with q3

q3-&gt;new_cfqq still points at q2!  We follow that link and end up at an
already freed cfqq.

So, the fix is to not follow a merge chain if the top-most queue does
not have a process reference, otherwise any queue in the chain could be
already freed.  I also changed the logic to disallow merging with a
queue that does not have any process references.  Previously, we did
this check for one of the merge candidates, but not the other.  That
doesn't really make sense.

Without the attached patch, my system would BUG within a couple of
seconds of running the reproducer program.  With the patch applied, my
system ran the program for over an hour without issues.

This addresses the following bugzilla:
    https://bugzilla.kernel.org/show_bug.cgi?id=16217

Thanks a ton to Phil Carns for providing the bug report and an excellent
reproducer.

[ Note for stable: this applies to 2.6.32/33/34 ].

Signed-off-by: Jeff Moyer &lt;jmoyer@redhat.com&gt;
Reported-by: Phil Carns &lt;carns@mcs.anl.gov&gt;
Cc: stable@kernel.org
Signed-off-by: Jens Axboe &lt;jaxboe@fusionio.com&gt;
</content>
</entry>
<entry>
<title>cfq-iosched: fix an oops caused by slab leak</title>
<updated>2010-05-25T08:17:26Z</updated>
<author>
<name>Shaohua Li</name>
</author>
<published>2010-05-25T08:16:53Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=d02a2c077fb81f3224c770be62a318165b23b486'/>
<id>urn:sha1:d02a2c077fb81f3224c770be62a318165b23b486</id>
<content type='text'>
I got below oops when unloading cfq-iosched. Considering scenario:
queue A merge to B, C merge to D and B will be merged to D. Before B is merged
to D, we do split B. We should put B's reference for D.

[  807.768536] =============================================================================
[  807.768539] BUG cfq_queue: Objects remaining on kmem_cache_close()
[  807.768541] -----------------------------------------------------------------------------
[  807.768543]
[  807.768546] INFO: Slab 0xffffea0003e6b4e0 objects=26 used=1 fp=0xffff88011d584fd8 flags=0x200000000004082
[  807.768550] Pid: 5946, comm: rmmod Tainted: G        W   2.6.34-07097-gf4b87de-dirty #724
[  807.768552] Call Trace:
[  807.768560]  [&lt;ffffffff81104e8d&gt;] slab_err+0x8f/0x9d
[  807.768564]  [&lt;ffffffff811059e1&gt;] ? flush_cpu_slab+0x0/0x93
[  807.768569]  [&lt;ffffffff8164be52&gt;] ? add_preempt_count+0xe/0xca
[  807.768572]  [&lt;ffffffff8164bd9c&gt;] ? sub_preempt_count+0xe/0xb6
[  807.768577]  [&lt;ffffffff81648871&gt;] ? _raw_spin_unlock+0x15/0x30
[  807.768580]  [&lt;ffffffff8164bd9c&gt;] ? sub_preempt_count+0xe/0xb6
[  807.768584]  [&lt;ffffffff811061bc&gt;] list_slab_objects+0x9b/0x19f
[  807.768588]  [&lt;ffffffff8164bf0a&gt;] ? add_preempt_count+0xc6/0xca
[  807.768591]  [&lt;ffffffff81109e27&gt;] kmem_cache_destroy+0x13f/0x21d
[  807.768597]  [&lt;ffffffffa000ff13&gt;] cfq_slab_kill+0x1a/0x43 [cfq_iosched]
[  807.768601]  [&lt;ffffffffa000ffcf&gt;] cfq_exit+0x93/0x9e [cfq_iosched]
[  807.768606]  [&lt;ffffffff810973a2&gt;] sys_delete_module+0x1b1/0x219
[  807.768612]  [&lt;ffffffff8102fb5b&gt;] system_call_fastpath+0x16/0x1b
[  807.768618] INFO: Object 0xffff88011d584618 @offset=1560
[  807.768622] INFO: Allocated in cfq_get_queue+0x11e/0x274 [cfq_iosched] age=7173 cpu=1 pid=5496
[  807.768626] =============================================================================

Cc: stable@kernel.org
Signed-off-by: Shaohua Li &lt;shaohua.li@intel.com&gt;
Signed-off-by: Jens Axboe &lt;jens.axboe@oracle.com&gt;
</content>
</entry>
<entry>
<title>cfq-iosched: compact io_context radix_tree</title>
<updated>2010-05-24T07:06:59Z</updated>
<author>
<name>Konstantin Khlebnikov</name>
</author>
<published>2010-05-20T19:21:41Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=80b15c7389caa81a3860f9fc2ee47ec0ea572a63'/>
<id>urn:sha1:80b15c7389caa81a3860f9fc2ee47ec0ea572a63</id>
<content type='text'>
Use small consequent indexes as radix tree keys instead of sparse cfqd address.

This change will reduce radix tree depth from 11 (6 for 32-bit hosts)
to 1 if host have &lt;=64 disks under cfq control, or to 0 if there only one disk.
So, this patch save 10*560 bytes for each process (5*296 for 32-bit hosts)

For each cfqd allocate cic index from ida.
To unlink dead cic from tree without cfqd access store index into -&gt;key.
(bit 0 -- dead mark, bits 1..30 -- index: ida produce id in range 0..2^31-1)

Signed-off-by: Konstantin Khlebnikov &lt;khlebnikov@openvz.org&gt;
Signed-off-by: Jens Axboe &lt;jens.axboe@oracle.com&gt;
</content>
</entry>
<entry>
<title>cfq-iosched: remove dead_key from cfq_io_context</title>
<updated>2010-05-24T07:06:59Z</updated>
<author>
<name>Konstantin Khlebnikov</name>
</author>
<published>2010-05-20T19:21:34Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=bca4b914b5da3d8e7b9b647f620b71dc85c0c394'/>
<id>urn:sha1:bca4b914b5da3d8e7b9b647f620b71dc85c0c394</id>
<content type='text'>
Remove -&gt;dead_key field from cfq_io_context to shrink its size to 128 bytes.
(64 bytes for 32-bit hosts)

Use lower bit in -&gt;key as dead-mark, instead of moving key to separate field.
After this for dead cfq_io_context we got cic-&gt;key != cfqd automatically.
Thus, io_context's last-hit cache should work without changing.

Now to check -&gt;key for non-dead state compare it with cfqd,
instead of checking -&gt;key for non-null value as it was before.

Plus remove obsolete race protection in cfq_cic_lookup.
This race gone after v2.6.24-1728-g4ac845a

Signed-off-by: Konstantin Khlebnikov &lt;khlebnikov@openvz.org&gt;
Signed-off-by: Jens Axboe &lt;jens.axboe@oracle.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'master' into for-2.6.35</title>
<updated>2010-05-21T19:27:26Z</updated>
<author>
<name>Jens Axboe</name>
</author>
<published>2010-05-21T19:27:26Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=ee9a3607fb03e804ddf624544105f4e34260c380'/>
<id>urn:sha1:ee9a3607fb03e804ddf624544105f4e34260c380</id>
<content type='text'>
Conflicts:
	fs/ext3/fsync.c

Signed-off-by: Jens Axboe &lt;jens.axboe@oracle.com&gt;
</content>
</entry>
<entry>
<title>block: remove all rcu head initializations</title>
<updated>2010-05-21T18:01:02Z</updated>
<author>
<name>Paul E. McKenney</name>
</author>
<published>2010-05-19T06:27:30Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=f1ac2502e19c59e996242d406fcc60e4c563e8ce'/>
<id>urn:sha1:f1ac2502e19c59e996242d406fcc60e4c563e8ce</id>
<content type='text'>
Remove all rcu head inits. We don't care about the RCU head state before passing
it to call_rcu() anyway. Only leave the "on_stack" variants so debugobjects can
keep track of objects on stack.

Signed-off-by: Mathieu Desnoyers &lt;mathieu.desnoyers@efficios.com&gt;
Signed-off-by: Paul E. McKenney &lt;paulmck@linux.vnet.ibm.com&gt;
Signed-off-by: Jens Axboe &lt;jens.axboe@oracle.com&gt;
</content>
</entry>
<entry>
<title>blk-cgroup: Fix RCU correctness warning in cfq_init_queue()</title>
<updated>2010-05-06T06:54:00Z</updated>
<author>
<name>Vivek Goyal</name>
</author>
<published>2010-04-22T15:54:52Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=dcf097b247affd8b88ad410a92298590c5600f44'/>
<id>urn:sha1:dcf097b247affd8b88ad410a92298590c5600f44</id>
<content type='text'>
It is necessary to be in an RCU read-side critical section when invoking
css_id(), so this patch adds one to blkiocg_add_blkio_group().  This is
actually a false positive, because this is called at initialization time
and hence always refers to the root cgroup, which cannot go away.

[  103.790505] ===================================================
[  103.790509] [ INFO: suspicious rcu_dereference_check() usage. ]
[  103.790511] ---------------------------------------------------
[  103.790514] kernel/cgroup.c:4432 invoked rcu_dereference_check() without protection!
[  103.790517]
[  103.790517] other info that might help us debug this:
[  103.790519]
[  103.790521]
[  103.790521] rcu_scheduler_active = 1, debug_locks = 1
[  103.790524] 4 locks held by bash/4422:
[  103.790526]  #0:  (&amp;buffer-&gt;mutex){+.+.+.}, at: [&lt;ffffffff8114befa&gt;] sysfs_write_file+0x3c/0x144
[  103.790537]  #1:  (s_active#102){.+.+.+}, at: [&lt;ffffffff8114bfa5&gt;] sysfs_write_file+0xe7/0x144
[  103.790544]  #2:  (&amp;q-&gt;sysfs_lock){+.+.+.}, at: [&lt;ffffffff812263b1&gt;] queue_attr_store+0x49/0x8f
[  103.790552]  #3:  (&amp;(&amp;blkcg-&gt;lock)-&gt;rlock){......}, at: [&lt;ffffffff8122e4db&gt;] blkiocg_add_blkio_group+0x2b/0xad
[  103.790560]
[  103.790561] stack backtrace:
[  103.790564] Pid: 4422, comm: bash Not tainted 2.6.34-rc4-blkio-second-crash #81
[  103.790567] Call Trace:
[  103.790572]  [&lt;ffffffff81068f57&gt;] lockdep_rcu_dereference+0x9d/0xa5
[  103.790577]  [&lt;ffffffff8107fac1&gt;] css_id+0x44/0x57
[  103.790581]  [&lt;ffffffff8122e503&gt;] blkiocg_add_blkio_group+0x53/0xad
[  103.790586]  [&lt;ffffffff81231936&gt;] cfq_init_queue+0x139/0x32c
[  103.790591]  [&lt;ffffffff8121f2d0&gt;] elv_iosched_store+0xbf/0x1bf
[  103.790595]  [&lt;ffffffff812263d8&gt;] queue_attr_store+0x70/0x8f
[  103.790599]  [&lt;ffffffff8114bfa5&gt;] ? sysfs_write_file+0xe7/0x144
[  103.790603]  [&lt;ffffffff8114bfc6&gt;] sysfs_write_file+0x108/0x144
[  103.790609]  [&lt;ffffffff810f527f&gt;] vfs_write+0xae/0x10b
[  103.790612]  [&lt;ffffffff81069863&gt;] ? trace_hardirqs_on_caller+0x10c/0x130
[  103.790616]  [&lt;ffffffff810f539c&gt;] sys_write+0x4a/0x6e
[  103.790622]  [&lt;ffffffff81002b5b&gt;] system_call_fastpath+0x16/0x1b
[  103.790625]

Located-by: Miles Lane &lt;miles.lane@gmail.com&gt;
Signed-off-by: Vivek Goyal &lt;vgoyal@redhat.com&gt;
Signed-off-by: Paul E. McKenney &lt;paulmck@linux.vnet.ibm.com&gt;
Signed-off-by: Ingo Molnar &lt;mingo@elte.hu&gt;
Signed-off-by: Jens Axboe &lt;jens.axboe@oracle.com&gt;
</content>
</entry>
</feed>
