<feed xmlns='http://www.w3.org/2005/Atom'>
<title>lwn.git/lib/radix-tree.c, branch v2.6.35.1</title>
<subtitle>Linux kernel documentation tree maintained by Jonathan Corbet</subtitle>
<id>http://mirrors.hust.edu.cn/git/lwn.git/atom?h=v2.6.35.1</id>
<link rel='self' href='http://mirrors.hust.edu.cn/git/lwn.git/atom?h=v2.6.35.1'/>
<link rel='alternate' type='text/html' href='http://mirrors.hust.edu.cn/git/lwn.git/'/>
<updated>2010-05-27T16:12:53+00:00</updated>
<entry>
<title>radix-tree: fix radix_tree_prev_hole() underflow case</title>
<updated>2010-05-27T16:12:53+00:00</updated>
<author>
<name>Cesar Eduardo Barros</name>
<email>cesarb@cesarb.net</email>
</author>
<published>2010-05-26T21:44:27+00:00</published>
<link rel='alternate' type='text/html' href='http://mirrors.hust.edu.cn/git/lwn.git/commit/?id=edcd1d843adf09d1742d49ae04fa51bb63ddd1c3'/>
<id>urn:sha1:edcd1d843adf09d1742d49ae04fa51bb63ddd1c3</id>
<content type='text'>
radix_tree_prev_hole() used LONG_MAX to detect underflow; however,
ULONG_MAX is clearly what was intended, both here and by its only user
(count_history_pages at mm/readahead.c).

Reviewed-by: Wu Fengguang &lt;fengguang.wu@intel.com&gt;
Signed-off-by: Cesar Eduardo Barros &lt;cesarb@cesarb.net&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>radix_tree_tag_get() is not as safe as the docs make out [ver #2]</title>
<updated>2010-04-09T17:12:03+00:00</updated>
<author>
<name>David Howells</name>
<email>dhowells@redhat.com</email>
</author>
<published>2010-04-06T21:36:20+00:00</published>
<link rel='alternate' type='text/html' href='http://mirrors.hust.edu.cn/git/lwn.git/commit/?id=ce82653d6cfcc95ba88c25908664878459fb1b8d'/>
<id>urn:sha1:ce82653d6cfcc95ba88c25908664878459fb1b8d</id>
<content type='text'>
radix_tree_tag_get() is not safe to use concurrently with radix_tree_tag_set()
or radix_tree_tag_clear().  The problem is that the double tag_get() in
radix_tree_tag_get():

		if (!tag_get(node, tag, offset))
			saw_unset_tag = 1;
		if (height == 1) {
			int ret = tag_get(node, tag, offset);

may see the value change due to the action of set/clear.  RCU is no protection
against this as no pointers are being changed, no nodes are being replaced
according to a COW protocol - set/clear alter the node directly.

The documentation in linux/radix-tree.h, however, says that
radix_tree_tag_get() is an exception to the rule that "any function modifying
the tree or tags (...) must exclude other modifications, and exclude any
functions reading the tree".

The problem is that the next statement in radix_tree_tag_get() checks that the
tag doesn't vary over time:

			BUG_ON(ret &amp;&amp; saw_unset_tag);

This has been seen happening in FS-Cache:

	https://www.redhat.com/archives/linux-cachefs/2010-April/msg00013.html

To this end, remove the BUG_ON() from radix_tree_tag_get() and note in various
comments that the value of the tag may change whilst the RCU read lock is held,
and thus that the return value of radix_tree_tag_get() may not be relied upon
unless radix_tree_tag_set/clear() and radix_tree_delete() are excluded from
running concurrently with it.

Reported-by: Romain DEGEZ &lt;romain.degez@smartjog.com&gt;
Signed-off-by: David Howells &lt;dhowells@redhat.com&gt;
Acked-by: Nick Piggin &lt;npiggin@suse.de&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h</title>
<updated>2010-03-30T13:02:32+00:00</updated>
<author>
<name>Tejun Heo</name>
<email>tj@kernel.org</email>
</author>
<published>2010-03-24T08:04:11+00:00</published>
<link rel='alternate' type='text/html' href='http://mirrors.hust.edu.cn/git/lwn.git/commit/?id=5a0e3ad6af8660be21ca98a971cd00f331318c05'/>
<id>urn:sha1:5a0e3ad6af8660be21ca98a971cd00f331318c05</id>
<content type='text'>
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files.  percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.

percpu.h -&gt; slab.h dependency is about to be removed.  Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability.  As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.

  http://userweb.kernel.org/~tj/misc/slabh-sweep.py

The script does the followings.

* Scan files for gfp and slab usages and update includes such that
  only the necessary includes are there.  ie. if only gfp is used,
  gfp.h, if slab is used, slab.h.

* When the script inserts a new include, it looks at the include
  blocks and try to put the new include such that its order conforms
  to its surrounding.  It's put in the include block which contains
  core kernel includes, in the same order that the rest are ordered -
  alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
  doesn't seem to be any matching order.

* If the script can't find a place to put a new include (mostly
  because the file doesn't have fitting include block), it prints out
  an error message indicating which .h file needs to be added to the
  file.

The conversion was done in the following steps.

1. The initial automatic conversion of all .c files updated slightly
   over 4000 files, deleting around 700 includes and adding ~480 gfp.h
   and ~3000 slab.h inclusions.  The script emitted errors for ~400
   files.

2. Each error was manually checked.  Some didn't need the inclusion,
   some needed manual addition while adding it to implementation .h or
   embedding .c file was more appropriate for others.  This step added
   inclusions to around 150 files.

3. The script was run again and the output was compared to the edits
   from #2 to make sure no file was left behind.

4. Several build tests were done and a couple of problems were fixed.
   e.g. lib/decompress_*.c used malloc/free() wrappers around slab
   APIs requiring slab.h to be added manually.

5. The script was run on all .h files but without automatically
   editing them as sprinkling gfp.h and slab.h inclusions around .h
   files could easily lead to inclusion dependency hell.  Most gfp.h
   inclusion directives were ignored as stuff from gfp.h was usually
   wildly available and often used in preprocessor macros.  Each
   slab.h inclusion directive was examined and added manually as
   necessary.

6. percpu.h was updated not to include slab.h.

7. Build test were done on the following configurations and failures
   were fixed.  CONFIG_GCOV_KERNEL was turned off for all tests (as my
   distributed build env didn't work with gcov compiles) and a few
   more options had to be turned off depending on archs to make things
   build (like ipr on powerpc/64 which failed due to missing writeq).

   * x86 and x86_64 UP and SMP allmodconfig and a custom test config.
   * powerpc and powerpc64 SMP allmodconfig
   * sparc and sparc64 SMP allmodconfig
   * ia64 SMP allmodconfig
   * s390 SMP allmodconfig
   * alpha SMP allmodconfig
   * um on x86_64 SMP allmodconfig

8. percpu.h modifications were reverted so that it could be applied as
   a separate patch and serve as bisection point.

Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.

Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
Guess-its-ok-by: Christoph Lameter &lt;cl@linux-foundation.org&gt;
Cc: Ingo Molnar &lt;mingo@redhat.com&gt;
Cc: Lee Schermerhorn &lt;Lee.Schermerhorn@hp.com&gt;
</content>
</entry>
<entry>
<title>radix-tree: Disable RCU lockdep checking in radix tree</title>
<updated>2010-02-25T09:34:50+00:00</updated>
<author>
<name>Paul E. McKenney</name>
<email>paulmck@linux.vnet.ibm.com</email>
</author>
<published>2010-02-23T01:04:54+00:00</published>
<link rel='alternate' type='text/html' href='http://mirrors.hust.edu.cn/git/lwn.git/commit/?id=2676a58c980b7ef076cc9bbff3fd8c9d2d5417ea'/>
<id>urn:sha1:2676a58c980b7ef076cc9bbff3fd8c9d2d5417ea</id>
<content type='text'>
Because the radix tree is used with many different locking
designs, we cannot do any effective checking without changing
the radix-tree APIs. It might make sense to do this later, but
only if the RCU lockdep checking proves itself sufficiently
valuable.

Signed-off-by: Paul E. McKenney &lt;paulmck@linux.vnet.ibm.com&gt;
Cc: laijs@cn.fujitsu.com
Cc: dipankar@in.ibm.com
Cc: mathieu.desnoyers@polymtl.ca
Cc: josh@joshtriplett.org
Cc: dvhltc@us.ibm.com
Cc: niv@us.ibm.com
Cc: peterz@infradead.org
Cc: rostedt@goodmis.org
Cc: Valdis.Kletnieks@vt.edu
Cc: dhowells@redhat.com
LKML-Reference: &lt;1266887105-1528-10-git-send-email-paulmck@linux.vnet.ibm.com&gt;
Signed-off-by: Ingo Molnar &lt;mingo@elte.hu&gt;
</content>
</entry>
<entry>
<title>FS-Cache: Don't delete pending pages from the page-store tracking tree</title>
<updated>2009-11-19T18:11:29+00:00</updated>
<author>
<name>David Howells</name>
<email>dhowells@redhat.com</email>
</author>
<published>2009-11-19T18:11:29+00:00</published>
<link rel='alternate' type='text/html' href='http://mirrors.hust.edu.cn/git/lwn.git/commit/?id=285e728b0ac55b53a673114096168d6f74930167'/>
<id>urn:sha1:285e728b0ac55b53a673114096168d6f74930167</id>
<content type='text'>
Don't delete pending pages from the page-store tracking tree, but rather send
them for another write as they've presumably been updated.

Signed-off-by: David Howells &lt;dhowells@redhat.com&gt;
</content>
</entry>
<entry>
<title>FS-Cache: Use radix tree preload correctly in tracking of pages to be stored</title>
<updated>2009-11-19T18:11:14+00:00</updated>
<author>
<name>David Howells</name>
<email>dhowells@redhat.com</email>
</author>
<published>2009-11-19T18:11:14+00:00</published>
<link rel='alternate' type='text/html' href='http://mirrors.hust.edu.cn/git/lwn.git/commit/?id=b34df792b4e9e311db47fad27949095d0629c197'/>
<id>urn:sha1:b34df792b4e9e311db47fad27949095d0629c197</id>
<content type='text'>
__fscache_write_page() attempts to load the radix tree preallocation pool for
the CPU it is on before calling radix_tree_insert(), as the insertion must be
done inside a pair of spinlocks.

Use of the preallocation pool, however, is contingent on the radix tree being
initialised without __GFP_WAIT specified.  __fscache_acquire_cookie() was
passing GFP_NOFS to INIT_RADIX_TREE() - but that includes __GFP_WAIT.

The solution is to AND out __GFP_WAIT.

Additionally, the banner comment to radix_tree_preload() is altered to make
note of this prerequisite.  Possibly there should be a WARN_ON() too.

Without this fix, I have seen the following recursive deadlock caused by
radix_tree_insert() attempting to allocate memory inside the spinlocked
region, which resulted in FS-Cache being called back into to release memory -
which required the spinlock already held.

=============================================
[ INFO: possible recursive locking detected ]
2.6.32-rc6-cachefs #24
---------------------------------------------
nfsiod/7916 is trying to acquire lock:
 (&amp;cookie-&gt;lock){+.+.-.}, at: [&lt;ffffffffa0076872&gt;] __fscache_uncache_page+0xdb/0x160 [fscache]

but task is already holding lock:
 (&amp;cookie-&gt;lock){+.+.-.}, at: [&lt;ffffffffa0076acc&gt;] __fscache_write_page+0x15c/0x3f3 [fscache]

other info that might help us debug this:
5 locks held by nfsiod/7916:
 #0:  (nfsiod){+.+.+.}, at: [&lt;ffffffff81048290&gt;] worker_thread+0x19a/0x2e2
 #1:  (&amp;task-&gt;u.tk_work#2){+.+.+.}, at: [&lt;ffffffff81048290&gt;] worker_thread+0x19a/0x2e2
 #2:  (&amp;cookie-&gt;lock){+.+.-.}, at: [&lt;ffffffffa0076acc&gt;] __fscache_write_page+0x15c/0x3f3 [fscache]
 #3:  (&amp;object-&gt;lock#2){+.+.-.}, at: [&lt;ffffffffa0076b07&gt;] __fscache_write_page+0x197/0x3f3 [fscache]
 #4:  (&amp;cookie-&gt;stores_lock){+.+...}, at: [&lt;ffffffffa0076b0f&gt;] __fscache_write_page+0x19f/0x3f3 [fscache]

stack backtrace:
Pid: 7916, comm: nfsiod Not tainted 2.6.32-rc6-cachefs #24
Call Trace:
 [&lt;ffffffff8105ac7f&gt;] __lock_acquire+0x1649/0x16e3
 [&lt;ffffffff81059ded&gt;] ? __lock_acquire+0x7b7/0x16e3
 [&lt;ffffffff8100e27d&gt;] ? dump_trace+0x248/0x257
 [&lt;ffffffff8105ad70&gt;] lock_acquire+0x57/0x6d
 [&lt;ffffffffa0076872&gt;] ? __fscache_uncache_page+0xdb/0x160 [fscache]
 [&lt;ffffffff8135467c&gt;] _spin_lock+0x2c/0x3b
 [&lt;ffffffffa0076872&gt;] ? __fscache_uncache_page+0xdb/0x160 [fscache]
 [&lt;ffffffffa0076872&gt;] __fscache_uncache_page+0xdb/0x160 [fscache]
 [&lt;ffffffffa0077eb7&gt;] ? __fscache_check_page_write+0x0/0x71 [fscache]
 [&lt;ffffffffa00b4755&gt;] nfs_fscache_release_page+0x86/0xc4 [nfs]
 [&lt;ffffffffa00907f0&gt;] nfs_release_page+0x3c/0x41 [nfs]
 [&lt;ffffffff81087ffb&gt;] try_to_release_page+0x32/0x3b
 [&lt;ffffffff81092c2b&gt;] shrink_page_list+0x316/0x4ac
 [&lt;ffffffff81058a9b&gt;] ? mark_held_locks+0x52/0x70
 [&lt;ffffffff8135451b&gt;] ? _spin_unlock_irq+0x2b/0x31
 [&lt;ffffffff81093153&gt;] shrink_inactive_list+0x392/0x67c
 [&lt;ffffffff81058a9b&gt;] ? mark_held_locks+0x52/0x70
 [&lt;ffffffff810934ca&gt;] shrink_list+0x8d/0x8f
 [&lt;ffffffff81093744&gt;] shrink_zone+0x278/0x33c
 [&lt;ffffffff81052c70&gt;] ? ktime_get_ts+0xad/0xba
 [&lt;ffffffff8109453b&gt;] try_to_free_pages+0x22e/0x392
 [&lt;ffffffff8109184c&gt;] ? isolate_pages_global+0x0/0x212
 [&lt;ffffffff8108e16b&gt;] __alloc_pages_nodemask+0x3dc/0x5cf
 [&lt;ffffffff810ae24a&gt;] cache_alloc_refill+0x34d/0x6c1
 [&lt;ffffffff811bcf74&gt;] ? radix_tree_node_alloc+0x52/0x5c
 [&lt;ffffffff810ae929&gt;] kmem_cache_alloc+0xb2/0x118
 [&lt;ffffffff811bcf74&gt;] radix_tree_node_alloc+0x52/0x5c
 [&lt;ffffffff811bcfd5&gt;] radix_tree_insert+0x57/0x19c
 [&lt;ffffffffa0076b53&gt;] __fscache_write_page+0x1e3/0x3f3 [fscache]
 [&lt;ffffffffa00b4248&gt;] __nfs_readpage_to_fscache+0x58/0x11e [nfs]
 [&lt;ffffffffa009bb77&gt;] nfs_readpage_release+0x34/0x9b [nfs]
 [&lt;ffffffffa009c0d9&gt;] nfs_readpage_release_full+0x32/0x4b [nfs]
 [&lt;ffffffffa0006cff&gt;] rpc_release_calldata+0x12/0x14 [sunrpc]
 [&lt;ffffffffa0006e2d&gt;] rpc_free_task+0x59/0x61 [sunrpc]
 [&lt;ffffffffa0006f03&gt;] rpc_async_release+0x10/0x12 [sunrpc]
 [&lt;ffffffff810482e5&gt;] worker_thread+0x1ef/0x2e2
 [&lt;ffffffff81048290&gt;] ? worker_thread+0x19a/0x2e2
 [&lt;ffffffff81352433&gt;] ? thread_return+0x3e/0x101
 [&lt;ffffffffa0006ef3&gt;] ? rpc_async_release+0x0/0x12 [sunrpc]
 [&lt;ffffffff8104bff5&gt;] ? autoremove_wake_function+0x0/0x34
 [&lt;ffffffff81058d25&gt;] ? trace_hardirqs_on+0xd/0xf
 [&lt;ffffffff810480f6&gt;] ? worker_thread+0x0/0x2e2
 [&lt;ffffffff8104bd21&gt;] kthread+0x7a/0x82
 [&lt;ffffffff8100beda&gt;] child_rip+0xa/0x20
 [&lt;ffffffff8100b87c&gt;] ? restore_args+0x0/0x30
 [&lt;ffffffff8104c2b9&gt;] ? add_wait_queue+0x15/0x44
 [&lt;ffffffff8104bca7&gt;] ? kthread+0x0/0x82
 [&lt;ffffffff8100bed0&gt;] ? child_rip+0x0/0x20

Signed-off-by: David Howells &lt;dhowells@redhat.com&gt;
</content>
</entry>
<entry>
<title>lib: do code optimization for radix_tree_lookup() and radix_tree_lookup_slot()</title>
<updated>2009-06-17T02:47:49+00:00</updated>
<author>
<name>Huang Shijie</name>
<email>shijie8@gmail.com</email>
</author>
<published>2009-06-16T22:33:42+00:00</published>
<link rel='alternate' type='text/html' href='http://mirrors.hust.edu.cn/git/lwn.git/commit/?id=b72b71c6cb6ecc564d4d5f9c512a7df269837846'/>
<id>urn:sha1:b72b71c6cb6ecc564d4d5f9c512a7df269837846</id>
<content type='text'>
radix_tree_lookup() and radix_tree_lookup_slot() have much the
same code except for the return value.

Introduce radix_tree_lookup_element() to do the real work.

/*
 * is_slot == 1 : search for the slot.
 * is_slot == 0 : search for the node.
 */
static void * radix_tree_lookup_element(struct radix_tree_root *root,
					unsigned long index, int is_slot);

Signed-off-by: Huang Shijie &lt;shijie8@gmail.com&gt;
Cc: Nick Piggin &lt;nickpiggin@yahoo.com.au&gt;
Cc: Christoph Lameter &lt;cl@linux-foundation.org&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>radix-tree: add radix_tree_prev_hole()</title>
<updated>2009-06-17T02:47:30+00:00</updated>
<author>
<name>Wu Fengguang</name>
<email>fengguang.wu@intel.com</email>
</author>
<published>2009-06-16T22:31:32+00:00</published>
<link rel='alternate' type='text/html' href='http://mirrors.hust.edu.cn/git/lwn.git/commit/?id=dc566127dd161b6c997466a2349ac179527ea89b'/>
<id>urn:sha1:dc566127dd161b6c997466a2349ac179527ea89b</id>
<content type='text'>
The counterpart of radix_tree_next_hole(). To be used by context readahead.

Signed-off-by: Wu Fengguang &lt;fengguang.wu@intel.com&gt;
Cc: Vladislav Bolkhovitin &lt;vst@vlnb.net&gt;
Cc: Jens Axboe &lt;jens.axboe@oracle.com&gt;
Cc: Jeff Moyer &lt;jmoyer@redhat.com&gt;
Cc: Nick Piggin &lt;nickpiggin@yahoo.com.au&gt;
Cc: Ying Han &lt;yinghan@google.com&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/trivial</title>
<updated>2009-01-07T19:31:52+00:00</updated>
<author>
<name>Linus Torvalds</name>
<email>torvalds@linux-foundation.org</email>
</author>
<published>2009-01-07T19:31:52+00:00</published>
<link rel='alternate' type='text/html' href='http://mirrors.hust.edu.cn/git/lwn.git/commit/?id=57c44c5f6fb0a8002feb258c1af58e1a744b1fcb'/>
<id>urn:sha1:57c44c5f6fb0a8002feb258c1af58e1a744b1fcb</id>
<content type='text'>
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/trivial: (24 commits)
  trivial: chack -&gt; check typo fix in main Makefile
  trivial: Add a space (and a comma) to a printk in 8250 driver
  trivial: Fix misspelling of "firmware" in docs for ncr53c8xx/sym53c8xx
  trivial: Fix misspelling of "firmware" in powerpc Makefile
  trivial: Fix misspelling of "firmware" in usb.c
  trivial: Fix misspelling of "firmware" in qla1280.c
  trivial: Fix misspelling of "firmware" in a100u2w.c
  trivial: Fix misspelling of "firmware" in megaraid.c
  trivial: Fix misspelling of "firmware" in ql4_mbx.c
  trivial: Fix misspelling of "firmware" in acpi_memhotplug.c
  trivial: Fix misspelling of "firmware" in ipw2100.c
  trivial: Fix misspelling of "firmware" in atmel.c
  trivial: Fix misspelled firmware in Kconfig
  trivial: fix an -&gt; a typos in documentation and comments
  trivial: fix then -&gt; than typos in comments and documentation
  trivial: update Jesper Juhl CREDITS entry with new email
  trivial: fix singal -&gt; signal typo
  trivial: Fix incorrect use of "loose" in event.c
  trivial: printk: fix indentation of new_text_line declaration
  trivial: rtc-stk17ta8: fix sparse warning
  ...
</content>
</entry>
<entry>
<title>lib: radix_tree.c make percpu variable static</title>
<updated>2009-01-06T23:59:11+00:00</updated>
<author>
<name>Harvey Harrison</name>
<email>harvey.harrison@gmail.com</email>
</author>
<published>2009-01-06T22:40:50+00:00</published>
<link rel='alternate' type='text/html' href='http://mirrors.hust.edu.cn/git/lwn.git/commit/?id=8cef7d57a4a47ef7166acde05eea0bc4f723691c'/>
<id>urn:sha1:8cef7d57a4a47ef7166acde05eea0bc4f723691c</id>
<content type='text'>
radix_tree_preloads is unused outside of this file, make it static.

Noticed by sparse:
lib/radix-tree.c:84:1: warning: symbol 'per_cpu__radix_tree_preloads' was not declared. Should it be static?

Signed-off-by: Harvey Harrison &lt;harvey.harrison@gmail.com&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
</feed>
