Re: [PATCH v6 2/8] mm,memory_hotplug: Relax fully spanned sections check

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 07.04.21 09:42, Oscar Salvador wrote:
On Tue, Apr 06, 2021 at 10:43:01PM +0200, David Hildenbrand wrote:
But not end_pfn as given in my version or what am I missing?

Nah, was my fault, I managed to see:

  if (WARN_ON_ONCE(!nr_pages ||
          !IS_ALIGNED(start_pfn, pageblock_nr_pages))
          !IS_ALIGNED(start_pfn | nr_pages, PAGES_PER_SECTION)))

which would not work.

I agree that keeping the PAGES_PER_SECTION check maks this safer, so this all
should have been:

diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
index 0cdbbfbc5757..25e59d5dc13c 100644
--- a/mm/memory_hotplug.c
+++ b/mm/memory_hotplug.c
@@ -838,9 +838,14 @@ int __ref online_pages(unsigned long pfn, unsigned long nr_pages,
         int ret;
         struct memory_notify arg;
- /* We can only online full sections (e.g., SECTION_IS_ONLINE) */
+       /* We can only offline full sections (e.g., SECTION_IS_ONLINE).
+        * However, when using e.g: memmap_on_memory, some pages are initialized
+        * prior to calling in here. The remaining amount of pages must be
+        * pageblock aligned.
+        */
         if (WARN_ON_ONCE(!nr_pages ||
-                        !IS_ALIGNED(pfn | nr_pages, PAGES_PER_SECTION)))
+                        !IS_ALIGNED(pfn, pageblock_nr_pages) ||
+                        !IS_ALIGNED(pfn + nr_pages, PAGES_PER_SECTION)))
                 return -EINVAL;
mem_hotplug_begin();
@@ -1573,9 +1578,14 @@ int __ref offline_pages(unsigned long start_pfn, unsigned long nr_pages)
         int ret, node;
         char *reason;
- /* We can only offline full sections (e.g., SECTION_IS_ONLINE) */
+       /* We can only offline full sections (e.g., SECTION_IS_ONLINE).
+        * However, when using e.g: memmap_on_memory, some pages are initialized
+        * prior to calling in here. The remaining amount of pages must be
+        * pageblock aligned.
+        */
         if (WARN_ON_ONCE(!nr_pages ||
-                        !IS_ALIGNED(start_pfn | nr_pages, PAGES_PER_SECTION)))
+                        !IS_ALIGNED(start_pfn, pageblock_nr_pages) ||
+                        !IS_ALIGNED(start_pfn + nr_pages, PAGES_PER_SECTION)))
                 return -EINVAL;
mem_hotplug_begin();


Reviewed-by: David Hildenbrand <david@xxxxxxxxxx>

--
Thanks,

David / dhildenb





[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux