• Maninder Singh's avatar
    mm/page_owner: fix recursion bug after changing skip entries · d2a5d00d
    Maninder Singh authored
    [ Upstream commit 299815a4fba9f3c7a81434dba0072148f1690608 ]
    
    This patch fixes commit 5f48f0bd ("mm, page_owner: skip unnecessary
    stack_trace entries").
    
    Because if we skip first two entries then logic of checking count value
    as 2 for recursion is broken and code will go in one depth recursion.
    
    so we need to check only one call of _RET_IP(__set_page_owner) while
    checking for recursion.
    
    Current Backtrace while checking for recursion:-
    
      (save_stack)             from (__set_page_owner)  // (But recursion returns true here)
      (__set_page_owner)       from (get_page_from_freelist)
      (get_page_from_freelist) from (__alloc_pages_nodemask)
      (__alloc_pages_nodemask) from (depot_save_stack)
      (depot_save_stack)       from (save_stack)       // recursion should return true here
      (save_stack)             from (__set_page_owner)
      (__set_page_owner)       from (get_page_from_freelist)
      (get_page_from_freelist) from (__alloc_pages_nodemask+)
      (__alloc_pages_nodemask) from (depot_save_stack)
      (depot_save_stack)       from (save_stack)
      (save_stack)             from (__set_page_owner)
      (__set_page_owner)       from (get_page_from_freelist)
    
    Correct Backtrace with fix:
    
      (save_stack)             from (__set_page_owner) // recursion returned true here
      (__set_page_owner)       from (get_page_from_freelist)
      (get_page_from_freelist) from (__alloc_pages_nodemask+)
      (__alloc_pages_nodemask) from (depot_save_stack)
      (depot_save_stack)       from (save_stack)
      (save_stack)             from (__set_page_owner)
      (__set_page_owner)       from (get_page_from_freelist)
    
    Link: http://lkml.kernel.org/r/1521607043-34670-1-git-send-email-maninder1.s@samsung.com
    Fixes: 5f48f0bd ("mm, page_owner: skip unnecessary stack_trace entries")
    Signed-off-by: 's avatarManinder Singh <maninder1.s@samsung.com>
    Signed-off-by: 's avatarVaneet Narang <v.narang@samsung.com>
    Acked-by: 's avatarVlastimil Babka <vbabka@suse.cz>
    Cc: Michal Hocko <mhocko@suse.com>
    Cc: Oscar Salvador <osalvador@techadventures.net>
    Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Cc: Ayush Mittal <ayush.m@samsung.com>
    Cc: Prakash Gupta <guptap@codeaurora.org>
    Cc: Vinayak Menon <vinmenon@codeaurora.org>
    Cc: Vasyl Gomonovych <gomonovych@gmail.com>
    Cc: Amit Sahrawat <a.sahrawat@samsung.com>
    Cc: <pankaj.m@samsung.com>
    Cc: Vaneet Narang <v.narang@samsung.com>
    Signed-off-by: 's avatarAndrew Morton <akpm@linux-foundation.org>
    Signed-off-by: 's avatarLinus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: 's avatarSasha Levin <alexander.levin@microsoft.com>
    Signed-off-by: 's avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    d2a5d00d