[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1682554137-13938-13-git-send-email-anthony.yznaga@oracle.com>
Date: Wed, 26 Apr 2023 17:08:48 -0700
From: Anthony Yznaga <anthony.yznaga@...cle.com>
To: linux-mm@...ck.org, linux-kernel@...r.kernel.org
Cc: tglx@...utronix.de, mingo@...hat.com, bp@...en8.de, x86@...nel.org,
hpa@...or.com, dave.hansen@...ux.intel.com, luto@...nel.org,
peterz@...radead.org, rppt@...nel.org, akpm@...ux-foundation.org,
ebiederm@...ssion.com, keescook@...omium.org, graf@...zon.com,
jason.zeng@...el.com, lei.l.li@...el.com,
steven.sistare@...cle.com, fam.zheng@...edance.com,
mgalaxy@...mai.com, kexec@...ts.infradead.org
Subject: [RFC v3 12/21] PKRAM: free the preserved ranges list
Free the pages used to pass the preserved ranges to the new boot.
Signed-off-by: Anthony Yznaga <anthony.yznaga@...cle.com>
---
arch/x86/mm/init_64.c | 1 +
include/linux/pkram.h | 2 ++
mm/pkram.c | 20 ++++++++++++++++++++
3 files changed, 23 insertions(+)
diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
index a46ffb434f39..9e68f07367fa 100644
--- a/arch/x86/mm/init_64.c
+++ b/arch/x86/mm/init_64.c
@@ -1340,6 +1340,7 @@ void __init mem_init(void)
after_bootmem = 1;
x86_init.hyper.init_after_bootmem();
+ pkram_cleanup();
totalram_pages_add(pkram_reserved_pages);
/*
* Must be done after boot memory is put on freelist, because here we
diff --git a/include/linux/pkram.h b/include/linux/pkram.h
index 53d5a1ec42ff..c909aa299fc4 100644
--- a/include/linux/pkram.h
+++ b/include/linux/pkram.h
@@ -102,9 +102,11 @@ int pkram_prepare_save(struct pkram_stream *ps, const char *name,
#ifdef CONFIG_PKRAM
extern unsigned long pkram_reserved_pages;
void pkram_reserve(void);
+void pkram_cleanup(void);
#else
#define pkram_reserved_pages 0UL
static inline void pkram_reserve(void) { }
+static inline void pkram_cleanup(void) { }
#endif
#endif /* _LINUX_PKRAM_H */
diff --git a/mm/pkram.c b/mm/pkram.c
index b711f94dbef4..c63b27bb711b 100644
--- a/mm/pkram.c
+++ b/mm/pkram.c
@@ -1456,3 +1456,23 @@ int __init pkram_merge_with_reserved(void)
return 0;
}
+
+void __init pkram_cleanup(void)
+{
+ struct pkram_region_list *rl;
+ unsigned long next_pfn;
+
+ if (!pkram_sb || !pkram_reserved_pages)
+ return;
+
+ next_pfn = pkram_sb->region_list_pfn;
+
+ while (next_pfn) {
+ struct page *page = pfn_to_page(next_pfn);
+
+ rl = pfn_to_kaddr(next_pfn);
+ next_pfn = rl->next_pfn;
+ __free_pages_core(page, 0);
+ pkram_reserved_pages--;
+ }
+}
--
1.9.4
Powered by blists - more mailing lists