login
Login
/
Register
Search
Search this site:
Forums
News
Blogs
Features
Site
Home
»
Mailing list archives
»
linux-kernel
»
2010
»
December
»
17
Re: [BUG?] memory hotplug: include/linux/radix-tree.h:145 invoked rcu_dereference_check() without protection!
view
thread
Previous message: [
thread
] [
date
] [
author
]
Next message: [
thread
] [
date
] [
author
]
[view in full thread]
From: Minchan Kim
Subject:
Re: [BUG?] memory hotplug: include/linux/radix-tree.h:145 invoked rcu_dereference_check() without protection!
Date: Friday, December 17, 2010 - 8:13 am
On Fri, Dec 17, 2010 at 08:39:12AM +0000, Mel Gorman wrote:
quoted text
> On Fri, Dec 17, 2010 at 09:04:13AM +0900, Minchan Kim wrote: > > On Thu, Dec 16, 2010 at 10:50 PM, Gerald Schaefer > > <gerald.schaefer@de.ibm.com> wrote: > > > I got the same warning now after increasing /proc/sys/vm/nr_hugepages, see > > > below. Both cases are easily reproducible: memory unplug with big page cache, > > > or adding large pages during run-time. > > > > > > =================================================== > > > [ INFO: suspicious rcu_dereference_check() usage. ] > > > --------------------------------------------------- > > > include/linux/radix-tree.h:145 invoked rcu_dereference_check() without protection! > > > > > > other info that might help us debug this: > > > > > > > > > rcu_scheduler_active = 1, debug_locks = 0 > > > 1 lock held by bash/761: > > > #0: (&(&inode->i_data.tree_lock)->rlock){..-.-.}, at: [<00000000002263ae>] migrate_page_move_mapping+0x4a/0x2d8 > > > > > > stack backtrace: > > > CPU: 1 Not tainted 2.6.37-rc6 #4 > > > Process bash (pid: 761, task: 00000000181b5540, ksp: 00000000181bb7f8) > > > 00000000181bb818 00000000181bb798 0000000000000002 0000000000000000 > > > 00000000181bb838 00000000181bb7b0 00000000181bb7b0 000000000056bafa > > > 0000000000000000 000000003f42bdf0 0000000000000002 000000001c43be30 > > > 000003e00000000d 000003e00000000c 00000000181bb800 0000000000000000 > > > 0000000000000000 0000000000100bfa 00000000181bb798 00000000181bb7d8 > > > Call Trace: > > > ([<0000000000100b02>] show_trace+0xee/0x144) > > > [<000000000022654e>] migrate_page_move_mapping+0x1ea/0x2d8 > > > [<0000000000226c80>] migrate_page+0x38/0x68 > > > [<0000000000226d9a>] move_to_new_page+0xea/0x2bc > > > [<000000000022785a>] migrate_pages+0x496/0x568 > > > [<000000000021e24e>] compact_zone+0x432/0x7d8 > > > [<000000000021e772>] compact_zone_order+0x9e/0xbc > > > [<000000000021ed52>] try_to_compact_pages+0x1ba/0x24c > > > [<00000000001e1afa>] __alloc_pages_nodemask+0x86a/0xa64 > > > [<000000000021c80c>] alloc_fresh_huge_page.clone.2+0x68/0x18c > > > [<000000000021cc4c>] set_max_huge_pages.clone.0+0xa4/0x1ac > > > [<000000000021ce06>] hugetlb_sysctl_handler+0xb2/0xcc > > > [<00000000002a6572>] proc_sys_call_handler+0xe6/0x10c > > > [<00000000002a65be>] proc_sys_write+0x26/0x34 > > > [<00000000002336e0>] vfs_write+0xac/0x18c > > > [<00000000002338bc>] SyS_write+0x58/0xa8 > > > [<0000000000113976>] sysc_noemu+0x16/0x1c > > > [<0000020000162edc>] 0x20000162edc > > > INFO: lockdep is turned off. > > > > > > I honestly do not understand 100% why this is a false positive, seeing that > > > e.g. find_get_page() will also use radix_tree_deref_slot(), holding only the > > > rcu_read_lock, while migrate_page_move_mapping() has no rcu_read_lock() but > > > the &mapping->tree_lock instead. So I'm not quite sure how to fix this > > > properly, but simply adding rcu_read_lock/unlock() to the affected code paths, > > > even if it is not necessary for synchronization, would get rid of the warning, > > > like in the following patch. Any ideas? > > > > In case of anon page, we hold rcu_read_lock in unmap_and_move. > > The problem is file-backed page. In case of that, we hold lock_page > > and mapping->tree_lock as update-side lock. > > So we don't need rcu_read_lock. > > > > > > > > --- > > > fs/hugetlbfs/inode.c | 2 ++ > > > mm/migrate.c | 4 ++++ > > > 2 files changed, 6 insertions(+) > > > > > > --- a/fs/hugetlbfs/inode.c > > > +++ b/fs/hugetlbfs/inode.c > > > @@ -580,7 +580,9 @@ static int hugetlbfs_migrate_page(struct > > > { > > > int rc; > > > > > > + rcu_read_lock(); > > > rc = migrate_huge_page_move_mapping(mapping, newpage, page); > > > + rcu_read_unlock(); > > > if (rc) > > > return rc; > > > migrate_page_copy(newpage, page); > > > --- a/mm/migrate.c > > > +++ b/mm/migrate.c > > > @@ -417,7 +417,9 @@ int migrate_page(struct address_space *m > > > > > > BUG_ON(PageWriteback(page)); /* Writeback must be complete */ > > > > > > + rcu_read_lock(); > > > rc = migrate_page_move_mapping(mapping, newpage, page); > > > + rcu_read_unlock(); > > > > > > if (rc) > > > return rc; > > > @@ -444,7 +446,9 @@ int buffer_migrate_page(struct address_s > > > > > > head = page_buffers(page); > > > > > > + rcu_read_lock(); > > > rc = migrate_page_move_mapping(mapping, newpage, page); > > > + rcu_read_unlock(); > > > > > > if (rc) > > > return rc; > > > > > > > > > > > > > > > How about this? > > Maybe Paul have better idea. > > (It's apparently be word-wrapped.) > > > > heh, I wrote a patch almost identical to this and ran it overnight for testing > (test was a memory consumer running while a parallel process grew and shrunk > the hugepage pool). It passes but that is hardly a surprise. We differed
Good.
quoted text
> slightly in a number of respects though. > > > diff --git a/include/linux/radix-tree.h b/include/linux/radix-tree.h > > index ab2baa5..135af1e 100644 > > --- a/include/linux/radix-tree.h > > +++ b/include/linux/radix-tree.h > > @@ -146,6 +146,20 @@ static inline void *radix_tree_deref_slot(void **pslot) > > } > > > > /** > > + * radix_tree_deref_slot_nocheck - dereference a slot without RCU check > > + * @pslot: pointer to slot, returned by radix_tree_lookup_slot > > + * Returns: item that was stored in that slot with any direct pointer flag > > + * removed. > > + * > > + * This functions works like radix_tree_deref_slot except it doesn't check > > + * RCU rule. Normally this funcion is used with update-side lock. > > + * You should use this function very carefully. > > + */ > > +static inline void *radix_tree_deref_slot_nocheck(void **pslot) > > +{ > > + return rcu_dereference_protected(*pslot, 1); > > +} > > For this, I had > > diff --git a/include/linux/radix-tree.h b/include/linux/radix-tree.h > index ab2baa5..252d21c 100644 > --- a/include/linux/radix-tree.h > +++ b/include/linux/radix-tree.h > @@ -146,6 +146,25 @@ static inline void *radix_tree_deref_slot(void **pslot) > } > > /** > + * radix_tree_deref_slot_protected - dereference a slot without RCU lock but with tree lock held > + * @pslot: pointer to slot, returned by radix_tree_lookup_slot > + * Returns: item that was stored in that slot with any direct pointer flag > + * removed. > + * > + * For use with radix_tree_lookup_slot(). Caller must hold tree read > + * locked across slot lookup and dereference. Not required if write lock is > + * held (ie. items cannot be concurrently inserted). > + * > + * radix_tree_deref_retry must be used to confirm validity of the pointer if > + * only the read lock is held. > + */ > +static inline void *radix_tree_deref_slot_protected(void **pslot, > + spinlock_t *treelock) > +{ > + return rcu_dereference_protected(*pslot, lockdep_is_held(treelock)); > +} > + > +/** > * radix_tree_deref_retry - check radix_tree_deref_slot > * @arg: pointer returned by radix_tree_deref_slot > * Returns: 0 if retry is not required, otherwise retry is required > > In the documentation, I noted that the check might be without RCU but with > the knowledge that it's protected by the tree lock. I'm not a RCU expert > but this is only safe when you know there isn't a parallel updater and the > treelock should be preventing that, right?
I think so.
quoted text
> > Even so, other users of rcu_dereference_protected() check a lock condition > which I used tree lock for. I intended to read through the rest of > documentation properly this morning to determine if this was indeed the > right approach. > > I used the name _protected instead of _nocheck because the dereference > is still protected (by the tree lock) just not by RCU. Again, have to > check the documentation to ensure this is correct.
I agree _proected naming is good.
quoted text
> > > +/** > > * radix_tree_deref_retry - check radix_tree_deref_slot > > * @arg: pointer returned by radix_tree_deref_slot > > * Returns: 0 if retry is not required, otherwise retry is required > > diff --git a/mm/migrate.c b/mm/migrate.c > > index 2eb2243..5be2841 100644 > > --- a/mm/migrate.c > > +++ b/mm/migrate.c > > @@ -244,7 +244,8 @@ static int migrate_page_move_mapping(struct > > address_space *mappin > > > > expected_count = 2 + page_has_private(page); > > if (page_count(page) != expected_count || > > - (struct page *)radix_tree_deref_slot(pslot) != page) { > > + (struct page *)radix_tree_deref_slot_nocheck(pslot) > > + != page) { > > spin_unlock_irq(&mapping->tree_lock); > > return -EAGAIN; > > } > > We only differed here by my passing in the &mapping->tree_lock
I will add the comment in your formal patch.
quoted text
> > > > > @@ -316,7 +317,8 @@ int migrate_huge_page_move_mapping(struct > > address_space *mapping, > > > > expected_count = 2 + page_has_private(page); > > if (page_count(page) != expected_count || > > - (struct page *)radix_tree_deref_slot(pslot) != page) { > > + (struct page *)radix_tree_deref_slot_nocheck(pslot) > > + != page) { > > spin_unlock_irq(&mapping->tree_lock); > > return -EAGAIN; > > } > > -- > Mel Gorman > Part-time Phd Student Linux Technology Center > University of Limerick IBM Dublin Software Lab
-- Kind regards, Minchan Kim --
unsubscribe notice
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to
majordomo@vger.kernel.org
More majordomo info at
http://vger.kernel.org/majordomo-info.html
Please read the FAQ at
http://www.tux.org/lkml/
Previous message: [
thread
] [
date
] [
author
]
Next message: [
thread
] [
date
] [
author
]
Messages in current thread:
[BUG?] [Ext4] INFO: suspicious rcu_dereference_check() usage
, Arun Bhanu
, (Sun Nov 21, 4:26 am)
Re: [BUG?] [Ext4] INFO: suspicious rcu_dereference_check() ...
, Ted Ts'o
, (Sun Nov 21, 6:30 am)
Re: [BUG?] [Ext4] INFO: suspicious rcu_dereference_check() ...
, Minchan Kim
, (Sun Nov 21, 8:39 am)
Re: [BUG?] [Ext4] INFO: suspicious rcu_dereference_check() ...
, Ted Ts'o
, (Sun Nov 21, 10:37 am)
Re: [BUG?] [Ext4] INFO: suspicious rcu_dereference_check() ...
, Minchan Kim
, (Sun Nov 21, 5:38 pm)
Re: [BUG?] [Ext4] INFO: suspicious rcu_dereference_check() ...
, Milton Miller
, (Sun Nov 21, 8:31 pm)
Re: [BUG?] [Ext4] INFO: suspicious rcu_dereference_check() ...
, Paul E. McKenney
, (Sun Nov 21, 11:16 pm)
Re: [BUG?] [Ext4] INFO: suspicious rcu_dereference_check() ...
, KOSAKI Motohiro
, (Tue Nov 23, 12:16 am)
[BUG?] memory hotplug: include/linux/radix-tree.h:145 invo ...
, Gerald Schaefer
, (Tue Dec 7, 12:01 pm)
Re: [BUG?] memory hotplug: include/linux/radix-tree.h:145 ...
, KAMEZAWA Hiroyuki
, (Tue Dec 7, 6:19 pm)
Re: [BUG?] memory hotplug: include/linux/radix-tree.h:145 ...
, Gerald Schaefer
, (Thu Dec 16, 6:50 am)
Re: [BUG?] memory hotplug: include/linux/radix-tree.h:145 ...
, Minchan Kim
, (Thu Dec 16, 5:04 pm)
Re: [BUG?] memory hotplug: include/linux/radix-tree.h:145 ...
, Paul E. McKenney
, (Thu Dec 16, 10:47 pm)
Re: [BUG?] memory hotplug: include/linux/radix-tree.h:145 ...
, Eric Dumazet
, (Thu Dec 16, 10:59 pm)
Re: [BUG?] memory hotplug: include/linux/radix-tree.h:145 ...
, Mel Gorman
, (Fri Dec 17, 1:39 am)
Re: [BUG?] memory hotplug: include/linux/radix-tree.h:145 ...
, Mel Gorman
, (Fri Dec 17, 2:28 am)
Re: [BUG?] memory hotplug: include/linux/radix-tree.h:145 ...
, Minchan Kim
, (Fri Dec 17, 8:08 am)
Re: [BUG?] memory hotplug: include/linux/radix-tree.h:145 ...
, Minchan Kim
, (Fri Dec 17, 8:13 am)
Re: [BUG?] memory hotplug: include/linux/radix-tree.h:145 ...
, Minchan Kim
, (Fri Dec 17, 8:22 am)
Re: [BUG?] memory hotplug: include/linux/radix-tree.h:145 ...
, Paul E. McKenney
, (Fri Dec 17, 9:01 am)
Re: [BUG?] memory hotplug: include/linux/radix-tree.h:145 ...
, Paul E. McKenney
, (Fri Dec 17, 9:03 am)
Navigation
Mailing list archives
Recent posts
Popular discussions
linux-kernel
:
Rusty Russell
Re: 2.6.22-rc3-mm1
Gautham R Shenoy
[PATCH 1/8] Enhance process freezer interface for usage beyond software suspend
Jeffrey V. Merkey
Re: Versioning file system
James Bottomley
Re: [PATCH -mm 1/2] scsi: remove dma_is_consistent usage in 53c700
David Miller
Re: NO_HZ: timer interrupt stuck
git
:
Oliver Kullmann
Re: how to move with history?
Junio C Hamano
Re: [PATCH 2/3] git-add--interactive: remove hunk coalescing
Miles Bader
Re: way to automatically add untracked files?
Harvey Harrison
Re: [SoC RFC] libsvn-fs-git: A git backend for the subversion filesystem
Alex Riesen
Re: git exclude patterns for directory
git-commits-head
:
Linux Kernel Mailing List
V4L/DVB: tm6000: add special usb request to quit i2c tuner transfer
Linux Kernel Mailing List
OMAP: DSS2: SDI driver
Linux Kernel Mailing List
PCI: introduce pci_pcie_cap()
Linux Kernel Mailing List
netfilter: nf_conntrack_sip: add T.38 FAX support
Linux Kernel Mailing List
drivers/acpi: use kasprintf
linux-netdev
:
Timo Teräs
ip xfrm policy semantics
David Miller
Re: [2.6.30-rc3] powerpc: compilation error of mace module
Patrick McHardy
Re: [rfc 02/13] [RFC 02/13] netfilter: nf_conntrack_sip: Add callid parser
webmaster Maintenance
&#32852;&#31995;&#31995;&#32479;&#31649;&#29702;&#21592;
Krzysztof Oledzki
Re: Error: an inet prefix is expected rather than "0/0".
openbsd-misc
:
Ted Bullock
Re: Proliant DL380 G3 cannot get on network
Úlfar M. E. Johnson
installing openbsd in xen
Eric Furman
Re: Defending OpenBSD Performance
Damien Miller
Re: Patching a SSH 'Weakness'
frantisek holop
Re: mount ffs as msdos, system hangs
Colocation donated by:
Syndicate