linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Maninder Singh <maninder1.s@samsung.com>
To: akpm@linux-foundation.org, vbabka@suse.cz, mhocko@suse.com,
	osalvador@techadventures.net, gregkh@linuxfoundation.org,
	ayush.m@samsung.com, guptap@codeaurora.org,
	vinmenon@codeaurora.org, gomonovych@gmail.com
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	a.sahrawat@samsung.com, pankaj.m@samsung.com,
	Maninder Singh <maninder1.s@samsung.com>,
	Vaneet Narang <v.narang@samsung.com>
Subject: [PATCH 1/1] mm/page_owner: fix recursion bug after changing skip entries
Date: Wed, 21 Mar 2018 10:07:23 +0530	[thread overview]
Message-ID: <1521607043-34670-1-git-send-email-maninder1.s@samsung.com> (raw)
In-Reply-To: <CGME20180321043818epcas5p176fe0e0bbfce685420df2bfb7a421acd@epcas5p1.samsung.com>

This patch fixes "5f48f0bd4e368425db4424b9afd1bd251d32367a".
(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)

Signed-off-by: Maninder Singh <maninder1.s@samsung.com>
Signed-off-by: Vaneet Narang <v.narang@samsung.com>
---
 mm/page_owner.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/mm/page_owner.c b/mm/page_owner.c
index 8592543..46ab1c4 100644
--- a/mm/page_owner.c
+++ b/mm/page_owner.c
@@ -123,13 +123,13 @@ void __reset_page_owner(struct page *page, unsigned int order)
 static inline bool check_recursive_alloc(struct stack_trace *trace,
 					unsigned long ip)
 {
-	int i, count;
+	int i;
 
 	if (!trace->nr_entries)
 		return false;
 
-	for (i = 0, count = 0; i < trace->nr_entries; i++) {
-		if (trace->entries[i] == ip && ++count == 2)
+	for (i = 0; i < trace->nr_entries; i++) {
+		if (trace->entries[i] == ip)
 			return true;
 	}
 
-- 
1.7.1

       reply	other threads:[~2018-03-21  4:38 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20180321043818epcas5p176fe0e0bbfce685420df2bfb7a421acd@epcas5p1.samsung.com>
2018-03-21  4:37 ` Maninder Singh [this message]
2018-03-21  8:25   ` Vlastimil Babka

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1521607043-34670-1-git-send-email-maninder1.s@samsung.com \
    --to=maninder1.s@samsung.com \
    --cc=a.sahrawat@samsung.com \
    --cc=akpm@linux-foundation.org \
    --cc=ayush.m@samsung.com \
    --cc=gomonovych@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=guptap@codeaurora.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@suse.com \
    --cc=osalvador@techadventures.net \
    --cc=pankaj.m@samsung.com \
    --cc=v.narang@samsung.com \
    --cc=vbabka@suse.cz \
    --cc=vinmenon@codeaurora.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox