* [PATCH] mm/page_alloc:Check pfn valid once in every page blocks
@ 2020-06-27 17:17 skseofh
2020-06-27 17:46 ` Matthew Wilcox
0 siblings, 1 reply; 2+ messages in thread
From: skseofh @ 2020-06-27 17:17 UTC (permalink / raw)
To: akpm; +Cc: linux-mm
Hi, all
Please check the patch below.
Thanks:)
No need to check validity for every pfn in [spfn, epfn).
---
mm/page_alloc.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 174c849ba9f2..212460c9fe0f 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -6936,11 +6936,19 @@ void __init free_area_init_memoryless_node(int nid)
*/
static u64 __init init_unavailable_range(unsigned long spfn, unsigned long epfn)
{
- unsigned long pfn;
+ unsigned long pfn, block_pfn;
u64 pgcnt = 0;
+ bool in_block = 0;
+
+ block_pfn = ALIGN_DOWN(spfn, pageblock_nr_pages);
for (pfn = spfn; pfn < epfn; pfn++) {
- if (!pfn_valid(ALIGN_DOWN(pfn, pageblock_nr_pages))) {
+ if (block_pfn != ALIGN_DOWN(pfn, pageblock_nr_pages)) {
+ block_pfn = ALIGN_DOWN(pfn, pageblock_nr_pages);
+ in_block = 0;
+ }
+
+ if (!in_block && !pfn_valid(ALIGN_DOWN(pfn, pageblock_nr_pages))) {
pfn = ALIGN_DOWN(pfn, pageblock_nr_pages)
+ pageblock_nr_pages - 1;
continue;
@@ -6953,6 +6961,7 @@ static u64 __init init_unavailable_range(unsigned long spfn, unsigned long epfn)
__init_single_page(pfn_to_page(pfn), pfn, 0, 0);
__SetPageReserved(pfn_to_page(pfn));
pgcnt++;
+ in_block = 1;
}
return pgcnt;
--
2.17.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] mm/page_alloc:Check pfn valid once in every page blocks
2020-06-27 17:17 [PATCH] mm/page_alloc:Check pfn valid once in every page blocks skseofh
@ 2020-06-27 17:46 ` Matthew Wilcox
0 siblings, 0 replies; 2+ messages in thread
From: Matthew Wilcox @ 2020-06-27 17:46 UTC (permalink / raw)
To: skseofh; +Cc: akpm, linux-mm
On Sun, Jun 28, 2020 at 02:17:22AM +0900, skseofh wrote:
> Hi, all
>
> Please check the patch below.
> Thanks:)
>
>
> No need to check validity for every pfn in [spfn, epfn).
> ---
> mm/page_alloc.c | 13 +++++++++++--
> 1 file changed, 11 insertions(+), 2 deletions(-)
OK, so first, this is more code and added complexity. You haven't justified
the extra code or complexity by giving us performance numbers.
> {
> - unsigned long pfn;
> + unsigned long pfn, block_pfn;
> u64 pgcnt = 0;
> + bool in_block = 0;
If something's a bool, then use 'true' and 'false', not 1 and 0.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-06-27 17:46 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-27 17:17 [PATCH] mm/page_alloc:Check pfn valid once in every page blocks skseofh
2020-06-27 17:46 ` Matthew Wilcox
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).