All of lore.kernel.org
 help / color / mirror / Atom feed
* + kasan-avoid-sleepable-page-allocation-from-atomic-context-v7.patch added to mm-hotfixes-unstable branch
@ 2025-05-12 22:23 Andrew Morton
  2025-05-12 23:50 ` Harry Yoo
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew Morton @ 2025-05-12 22:23 UTC (permalink / raw)
  To: mm-commits, ryabinin.a.a, harry.yoo, dja, agordeev, akpm


The patch titled
     Subject: kasan-avoid-sleepable-page-allocation-from-atomic-context-v7
has been added to the -mm mm-hotfixes-unstable branch.  Its filename is
     kasan-avoid-sleepable-page-allocation-from-atomic-context-v7.patch

This patch will shortly appear at
     https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/kasan-avoid-sleepable-page-allocation-from-atomic-context-v7.patch

This patch will later appear in the mm-hotfixes-unstable branch at
    git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

Before you just go and hit "reply", please:
   a) Consider who else should be cc'ed
   b) Prefer to cc a suitable mailing list as well
   c) Ideally: find the original patch on the mailing list and do a
      reply-to-all to that, adding suitable additional cc's

*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***

The -mm tree is included into linux-next via the mm-everything
branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
and is updated there every 2-3 working days

------------------------------------------------------
From: Alexander Gordeev <agordeev@linux.ibm.com>
Subject: kasan-avoid-sleepable-page-allocation-from-atomic-context-v7
Date: Mon, 12 May 2025 16:27:06 +0200

do not unnecessary free pages across iterations

Link: https://lkml.kernel.org/r/c8eeeb146382bcadabce5b5dcf92e6176ba4fb04.1747059374.git.agordeev@linux.ibm.com
Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
Suggested-by: Andrey Ryabinin <ryabinin.a.a@gmail.com>
Reviewed-by: Harry Yoo <harry.yoo@oracle.com>
Cc: Daniel Axtens <dja@axtens.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 mm/kasan/shadow.c |   15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

--- a/mm/kasan/shadow.c~kasan-avoid-sleepable-page-allocation-from-atomic-context-v7
+++ a/mm/kasan/shadow.c
@@ -337,9 +337,9 @@ static inline void free_pages_bulk(struc
 
 static int __kasan_populate_vmalloc(unsigned long start, unsigned long end)
 {
-	unsigned long nr_populated, nr_pages, nr_total = PFN_UP(end - start);
+	unsigned long nr_pages, nr_populated = 0, nr_total = PFN_UP(end - start);
 	struct vmalloc_populate_data data;
-	int ret;
+	int ret = 0;
 
 	data.pages = (struct page **)__get_free_page(GFP_KERNEL | __GFP_ZERO);
 	if (!data.pages)
@@ -349,25 +349,24 @@ static int __kasan_populate_vmalloc(unsi
 		nr_pages = min(nr_total, PAGE_SIZE / sizeof(data.pages[0]));
 		nr_populated = alloc_pages_bulk(GFP_KERNEL, nr_pages, data.pages);
 		if (nr_populated != nr_pages) {
-			free_pages_bulk(data.pages, nr_populated);
-			free_page((unsigned long)data.pages);
-			return -ENOMEM;
+			ret = -ENOMEM;
+			break;
 		}
 
 		data.start = start;
 		ret = apply_to_page_range(&init_mm, start, nr_pages * PAGE_SIZE,
 					  kasan_populate_vmalloc_pte, &data);
-		free_pages_bulk(data.pages, nr_pages);
 		if (ret)
-			return ret;
+			break;
 
 		start += nr_pages * PAGE_SIZE;
 		nr_total -= nr_pages;
 	}
 
+	free_pages_bulk(data.pages, nr_populated);
 	free_page((unsigned long)data.pages);
 
-	return 0;
+	return ret;
 }
 
 int kasan_populate_vmalloc(unsigned long addr, unsigned long size)
_

Patches currently in -mm which might be from agordeev@linux.ibm.com are

kasan-avoid-sleepable-page-allocation-from-atomic-context.patch
kasan-avoid-sleepable-page-allocation-from-atomic-context-v7.patch


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

end of thread, other threads:[~2025-05-13  1:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-12 22:23 + kasan-avoid-sleepable-page-allocation-from-atomic-context-v7.patch added to mm-hotfixes-unstable branch Andrew Morton
2025-05-12 23:50 ` Harry Yoo
2025-05-13  1:14   ` Andrew Morton

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.