aboutsummaryrefslogtreecommitdiff
path: root/kernel
diff options
context:
space:
mode:
authorOleg Nesterov <[email protected]>2012-06-15 17:43:36 +0200
committerIngo Molnar <[email protected]>2012-06-16 09:10:44 +0200
commit7a5bfb66b07f22d2429db776da7bb8b57bfb5cff (patch)
treeaa6a419726f99052171f05b004db45692fef3315 /kernel
parent268720903f87e0b84b161626c4447b81671b5d18 (diff)
uprobes: Change build_map_info() to try kmalloc(GFP_NOWAIT) first
build_map_info() doesn't allocate the memory under i_mmap_mutex to avoid the deadlock with page reclaim. But it can try GFP_NOWAIT first, it should work in the likely case and thus we almost never need the pre-alloc-and-retry path. Signed-off-by: Oleg Nesterov <[email protected]> Acked-by: Srikar Dronamraju <[email protected]> Acked-by: Peter Zijlstra <[email protected]> Cc: Ananth N Mavinakayanahalli <[email protected]> Cc: Anton Arapov <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Ingo Molnar <[email protected]>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/events/uprobes.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c
index 4e0db3496d70..897417dbca8e 100644
--- a/kernel/events/uprobes.c
+++ b/kernel/events/uprobes.c
@@ -761,6 +761,16 @@ build_map_info(struct address_space *mapping, loff_t offset, bool is_register)
if (!valid_vma(vma, is_register))
continue;
+ if (!prev && !more) {
+ /*
+ * Needs GFP_NOWAIT to avoid i_mmap_mutex recursion through
+ * reclaim. This is optimistic, no harm done if it fails.
+ */
+ prev = kmalloc(sizeof(struct map_info),
+ GFP_NOWAIT | __GFP_NOMEMALLOC | __GFP_NOWARN);
+ if (prev)
+ prev->next = NULL;
+ }
if (!prev) {
more++;
continue;