lkml.org 
[lkml]   [2012]   [Jun]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Date
    From
    Subject[PATCH v2 2/3] 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 <oleg@redhat.com>
    ---
    kernel/events/uprobes.c | 10 ++++++++++
    1 files changed, 10 insertions(+), 0 deletions(-)

    diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c
    index a1bbcab..88e903d 100644
    --- a/kernel/events/uprobes.c
    +++ b/kernel/events/uprobes.c
    @@ -771,6 +771,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;
    --
    1.5.5.1



    \
     
     \ /
      Last update: 2012-06-06 19:41    [W:5.080 / U:0.084 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site