linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arun KS <arunks@codeaurora.org>
To: akpm@linux-foundation.org, dan.j.williams@intel.com,
	mhocko@suse.com, vbabka@suse.cz, pasha.tatashin@oracle.com,
	iamjoonsoo.kim@lge.com, osalvador@suse.de, arunks@codeaurora.org,
	malat@debian.org, gregkh@linuxfoundation.org,
	yasu.isimatu@gmail.com, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org
Cc: arunks.linux@gmail.com, vinmenon@codeaurora.org
Subject: [RFC] memory_hotplug: Free pages as pageblock_order
Date: Wed, 12 Sep 2018 14:56:45 +0530	[thread overview]
Message-ID: <1536744405-16752-1-git-send-email-arunks@codeaurora.org> (raw)

When free pages are done with pageblock_order, time spend on
coalescing pages by buddy allocator can be reduced. With
section size of 256MB, hot add latency of a single section
shows improvement from 50-60 ms to less than 1 ms, hence
improving the hot add latency by 60%.

If this looks okey, I'll modify users of set_online_page_callback
and resend clean patch.

Signed-off-by: Arun KS <arunks@codeaurora.org>
---
 include/linux/memory_hotplug.h |  1 +
 mm/memory_hotplug.c            | 52 ++++++++++++++++++++++++++++++++++++------
 2 files changed, 46 insertions(+), 7 deletions(-)

diff --git a/include/linux/memory_hotplug.h b/include/linux/memory_hotplug.h
index 34a2822..447047d 100644
--- a/include/linux/memory_hotplug.h
+++ b/include/linux/memory_hotplug.h
@@ -88,6 +88,7 @@ extern int test_pages_in_a_zone(unsigned long start_pfn, unsigned long end_pfn,
 extern void __offline_isolated_pages(unsigned long, unsigned long);
 
 typedef void (*online_page_callback_t)(struct page *page);
+typedef int (*online_pages_callback_t)(struct page *page, unsigned int order);
 
 extern int set_online_page_callback(online_page_callback_t callback);
 extern int restore_online_page_callback(online_page_callback_t callback);
diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
index 38d94b7..853104d 100644
--- a/mm/memory_hotplug.c
+++ b/mm/memory_hotplug.c
@@ -662,19 +662,57 @@ static void generic_online_page(struct page *page)
 	__online_page_free(page);
 }
 
+static int generic_online_pages(struct page *page, unsigned int order);
+static online_pages_callback_t online_pages_callback = generic_online_pages;
+
+static int generic_online_pages(struct page *page, unsigned int order)
+{
+	unsigned long nr_pages = 1 << order;
+	struct page *p = page;
+	unsigned int loop;
+
+	for (loop = 0 ; loop < nr_pages ; loop++, p++) {
+		__ClearPageReserved(p);
+		set_page_count(p, 0);
+	}
+	adjust_managed_page_count(page, nr_pages);
+	init_page_count(page);
+	__free_pages(page, order);
+
+	return 0;
+}
+
+static int online_pages_blocks(unsigned long start_pfn, unsigned long nr_pages)
+{
+	unsigned long pages_per_block = (1 << pageblock_order);
+	unsigned long nr_pageblocks = nr_pages / pages_per_block;
+//	unsigned long rem_pages = nr_pages % pages_per_block;
+	int i, ret, onlined_pages = 0;
+	struct page *page;
+
+	for (i = 0 ; i < nr_pageblocks ; i++) {
+		page = pfn_to_page(start_pfn + (i * pages_per_block));
+		ret = (*online_pages_callback)(page, pageblock_order);
+		if (!ret)
+			onlined_pages += pages_per_block;
+		else if (ret > 0)
+			onlined_pages += ret;
+	}
+/*
+	if (rem_pages)
+		onlined_pages += online_page_single(start_pfn + i, rem_pages);
+*/
+
+	return onlined_pages;
+}
+
 static int online_pages_range(unsigned long start_pfn, unsigned long nr_pages,
 			void *arg)
 {
-	unsigned long i;
 	unsigned long onlined_pages = *(unsigned long *)arg;
-	struct page *page;
 
 	if (PageReserved(pfn_to_page(start_pfn)))
-		for (i = 0; i < nr_pages; i++) {
-			page = pfn_to_page(start_pfn + i);
-			(*online_page_callback)(page);
-			onlined_pages++;
-		}
+		onlined_pages = online_pages_blocks(start_pfn, nr_pages);
 
 	online_mem_sections(start_pfn, start_pfn + nr_pages);
 
-- 
1.9.1


             reply	other threads:[~2018-09-12  9:27 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-12  9:26 Arun KS [this message]
2018-09-12 10:38 ` [RFC] memory_hotplug: Free pages as pageblock_order Michal Hocko
2018-09-12 12:57   ` Balbir Singh
2018-09-12 13:17     ` Michal Hocko
2018-09-12 14:42       ` Arun KS
2018-09-14  9:10         ` Michal Hocko
2018-09-19  1:18           ` Arun KS
2018-09-12 14:09     ` Arun KS

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=1536744405-16752-1-git-send-email-arunks@codeaurora.org \
    --to=arunks@codeaurora.org \
    --cc=akpm@linux-foundation.org \
    --cc=arunks.linux@gmail.com \
    --cc=dan.j.williams@intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=iamjoonsoo.kim@lge.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=malat@debian.org \
    --cc=mhocko@suse.com \
    --cc=osalvador@suse.de \
    --cc=pasha.tatashin@oracle.com \
    --cc=vbabka@suse.cz \
    --cc=vinmenon@codeaurora.org \
    --cc=yasu.isimatu@gmail.com \
    /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;
as well as URLs for NNTP newsgroup(s).