linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] mm: fix logic error of page_expected_state
@ 2022-09-14  3:37 zhaoyang.huang
  2022-09-14  3:37 ` [PATCH 2/2] mm: introduce __GFP_TRACKLEAK to track in-kernel allocation zhaoyang.huang
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: zhaoyang.huang @ 2022-09-14  3:37 UTC (permalink / raw)
  To: Andrew Morton, Catalin Marinas, Matthew Wilcox, Zhaoyang Huang,
	linux-mm, linux-kernel, ke.wang

From: Zhaoyang Huang <zhaoyang.huang@unisoc.com>

The page with special page type will be deemed as bad page wrongly since
type share the same address with mapcount.

Signed-off-by: Zhaoyang Huang <zhaoyang.huang@unisoc.com>
---
 include/linux/page-flags.h | 4 ++--
 mm/page_alloc.c            | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h
index e66f7aa..5d3274b 100644
--- a/include/linux/page-flags.h
+++ b/include/linux/page-flags.h
@@ -946,9 +946,9 @@ static inline bool is_page_hwpoison(struct page *page)
 #define PageType(page, flag)						\
 	((page->page_type & (PAGE_TYPE_BASE | flag)) == PAGE_TYPE_BASE)
 
-static inline int page_has_type(struct page *page)
+static inline bool page_has_type(struct page *page)
 {
-	return (int)page->page_type < PAGE_MAPCOUNT_RESERVE;
+	return page->page_type < PAGE_MAPCOUNT_RESERVE;
 }
 
 #define PAGE_TYPE_OPS(uname, lname)					\
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index e008a3d..3714680 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -1164,7 +1164,7 @@ int split_free_page(struct page *free_page,
 static inline bool page_expected_state(struct page *page,
 					unsigned long check_flags)
 {
-	if (unlikely(atomic_read(&page->_mapcount) != -1))
+	if (unlikely(!page_has_type(page) && atomic_read(&page->_mapcount) != -1))
 		return false;
 
 	if (unlikely((unsigned long)page->mapping |
-- 
1.9.1



^ permalink raw reply related	[flat|nested] 8+ messages in thread
* [PATCH 1/2] mm: fix logic error of bulkfree_pcp_prepare
@ 2022-09-13  6:10 zhaoyang.huang
  2022-09-13  6:10 ` [PATCH 2/2] mm: introduce __GFP_TRACKLEAK to track in-kernel allocation zhaoyang.huang
  0 siblings, 1 reply; 8+ messages in thread
From: zhaoyang.huang @ 2022-09-13  6:10 UTC (permalink / raw)
  To: Andrew Morton, Catalin Marinas, Matthew Wilcox, Zhaoyang Huang,
	linux-mm, linux-kernel, ke.wang

From: Zhaoyang Huang <zhaoyang.huang@unisoc.com>

free_pages_check return 0 when result is ok while bulkfree_pcp_prepare
treat it as false wrongly.

Signed-off-by: Zhaoyang Huang <zhaoyang.huang@unisoc.com>
---
 mm/page_alloc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index e008a3d..69b15e3 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -1424,7 +1424,7 @@ static bool free_pcp_prepare(struct page *page, unsigned int order)
 static bool bulkfree_pcp_prepare(struct page *page)
 {
 	if (debug_pagealloc_enabled_static())
-		return check_free_page(page);
+		return !check_free_page(page);
 	else
 		return false;
 }
@@ -1445,7 +1445,7 @@ static bool free_pcp_prepare(struct page *page, unsigned int order)
 
 static bool bulkfree_pcp_prepare(struct page *page)
 {
-	return check_free_page(page);
+	return !check_free_page(page);
 }
 #endif /* CONFIG_DEBUG_VM */
 
-- 
1.9.1



^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2022-09-14 10:51 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-09-14  3:37 [PATCH 1/2] mm: fix logic error of page_expected_state zhaoyang.huang
2022-09-14  3:37 ` [PATCH 2/2] mm: introduce __GFP_TRACKLEAK to track in-kernel allocation zhaoyang.huang
2022-09-14  8:26   ` Matthew Wilcox
2022-09-14  4:35 ` [PATCH 1/2] mm: fix logic error of page_expected_state Zhaoyang Huang
2022-09-14  7:35 ` Matthew Wilcox
2022-09-14  8:14   ` Zhaoyang Huang
2022-09-14 10:51 ` Zhaoyang Huang
  -- strict thread matches above, loose matches on Subject: below --
2022-09-13  6:10 [PATCH 1/2] mm: fix logic error of bulkfree_pcp_prepare zhaoyang.huang
2022-09-13  6:10 ` [PATCH 2/2] mm: introduce __GFP_TRACKLEAK to track in-kernel allocation zhaoyang.huang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).