From: David Hildenbrand <david@redhat.com>
To: linux-mm@kvack.org
Cc: David Hildenbrand <david@redhat.com>,
Andrew Morton <akpm@linux-foundation.org>,
Michal Hocko <mhocko@suse.com>, Vlastimil Babka <vbabka@suse.cz>,
Dan Williams <dan.j.williams@intel.com>,
Reza Arbab <arbab@linux.vnet.ibm.com>,
Pavel Tatashin <pasha.tatashin@oracle.com>,
Thomas Gleixner <tglx@linutronix.de>,
open list <linux-kernel@vger.kernel.org>
Subject: [PATCH RFC 6/8] mm: offline_pages() is also limited by MAX_ORDER
Date: Fri, 13 Apr 2018 15:33:18 +0200 [thread overview]
Message-ID: <20180413133320.3557-1-david@redhat.com> (raw)
In-Reply-To: <20180413131632.1413-1-david@redhat.com>
Page blocks might contain references to the next page block. So
a page block cannot be offlined independently. E.g. on x86: page block
size is 2MB, MAX_ORDER -1 (10) allows 4MB allocations.
-> Right now, __offline_isolated_pages() will mark pages in the following
page block as reserved.
Let document offline_pages() while at it.
Signed-off-by: David Hildenbrand <david@redhat.com>
---
mm/memory_hotplug.c | 22 ++++++++++++++++++++--
1 file changed, 20 insertions(+), 2 deletions(-)
diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
index 3a8d56476233..1d6054edc241 100644
--- a/mm/memory_hotplug.c
+++ b/mm/memory_hotplug.c
@@ -1598,11 +1598,14 @@ static int __ref __offline_pages(unsigned long start_pfn,
struct zone *zone;
struct memory_notify arg;
- /* at least, alignment against pageblock is necessary */
if (!IS_ALIGNED(start_pfn, pageblock_nr_pages))
return -EINVAL;
+ if (!IS_ALIGNED(start_pfn, (1 << (MAX_ORDER - 1))))
+ return -EINVAL;
if (!IS_ALIGNED(end_pfn, pageblock_nr_pages))
return -EINVAL;
+ if (!IS_ALIGNED(end_pfn, (1 << (MAX_ORDER - 1))))
+ return -EINVAL;
/* This makes hotplug much easier...and readable.
we assume this for now. .*/
if (!test_pages_in_a_zone(start_pfn, end_pfn, &valid_start, &valid_end))
@@ -1699,7 +1702,22 @@ static int __ref __offline_pages(unsigned long start_pfn,
return ret;
}
-/* Must be protected by mem_hotplug_begin() or a device_lock */
+/**
+ * offline_pages - offline pages in a given range (that are currently online)
+ * @start_pfn: start pfn of the memory range
+ * @nr_pages: the number of pages
+ *
+ * This function tries to offline the given pages. The alignment/size that
+ * can be used is max(pageblock_nr_pages, 1 << (MAX_ORDER - 1)).
+ *
+ * Returns 0 if sucessful, -EBUSY if the pages cannot be offlined and
+ * -EINVAL if start_pfn/nr_pages is not properly aligned or not in a zone.
+ * -EINTR is returned if interrupted by a signal.
+ *
+ * Bad things will happen if pages are already offline.
+ *
+ * Must be protected by mem_hotplug_begin() or a device_lock
+ */
int offline_pages(unsigned long start_pfn, unsigned long nr_pages)
{
return __offline_pages(start_pfn, start_pfn + nr_pages);
--
2.14.3
next prev parent reply other threads:[~2018-04-13 13:33 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-13 13:16 [PATCH RFC 0/8] mm: online/offline 4MB chunks controlled by device driver David Hildenbrand
2018-04-13 13:16 ` [PATCH RFC 1/8] mm/memory_hotplug: Revert "mm/memory_hotplug: optimize memory hotplug" David Hildenbrand
2018-04-13 13:16 ` [PATCH RFC 2/8] mm: introduce PG_offline David Hildenbrand
2018-04-13 13:40 ` Michal Hocko
2018-04-13 13:46 ` David Hildenbrand
2018-04-17 11:50 ` David Hildenbrand
2018-04-13 17:11 ` Matthew Wilcox
2018-04-16 8:31 ` David Hildenbrand
2018-04-21 16:52 ` Vlastimil Babka
2018-04-22 3:01 ` Matthew Wilcox
2018-04-22 8:17 ` David Hildenbrand
2018-04-22 14:02 ` Matthew Wilcox
2018-04-22 15:13 ` David Hildenbrand
2018-04-29 21:08 ` Michal Hocko
2018-04-30 6:31 ` David Hildenbrand
2018-04-20 7:30 ` David Hildenbrand
2018-04-13 13:16 ` [PATCH RFC 3/8] mm: use PG_offline in online/offlining code David Hildenbrand
2018-04-13 13:31 ` [PATCH RFC 4/8] kdump: expose PG_offline David Hildenbrand
2018-04-13 13:33 ` [PATCH RFC 5/8] mm: only mark section offline when all pages are offline David Hildenbrand
2018-04-13 13:33 ` David Hildenbrand [this message]
2018-04-13 13:33 ` [PATCH RFC 7/8] mm: allow to control onlining/offlining of memory by a driver David Hildenbrand
2018-04-13 15:59 ` Michal Hocko
2018-04-13 16:32 ` David Hildenbrand
2018-04-13 13:33 ` [PATCH RFC 8/8] mm: export more functions used to online/offline memory David Hildenbrand
2018-04-13 13:44 ` [PATCH RFC 0/8] mm: online/offline 4MB chunks controlled by device driver Michal Hocko
2018-04-13 14:01 ` David Hildenbrand
2018-04-13 14:20 ` Michal Hocko
2018-04-13 14:59 ` David Hildenbrand
2018-04-13 15:02 ` David Hildenbrand
2018-04-13 16:03 ` Michal Hocko
2018-04-13 16:36 ` David Hildenbrand
2018-04-13 15:59 ` Michal Hocko
2018-04-13 16:31 ` David Hildenbrand
2018-04-16 14:08 ` Michal Hocko
2018-04-16 14:48 ` David Hildenbrand
2018-04-18 15:46 ` David Hildenbrand
2018-04-19 7:33 ` Michal Hocko
2018-04-26 15:30 ` David Hildenbrand
2018-04-29 21:05 ` Michal Hocko
2018-04-30 6:24 ` David Hildenbrand
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=20180413133320.3557-1-david@redhat.com \
--to=david@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=arbab@linux.vnet.ibm.com \
--cc=dan.j.williams@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@suse.com \
--cc=pasha.tatashin@oracle.com \
--cc=tglx@linutronix.de \
--cc=vbabka@suse.cz \
/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