[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190626082756.GD30863@linux>
Date: Wed, 26 Jun 2019 10:27:56 +0200
From: Oscar Salvador <osalvador@...e.de>
To: David Hildenbrand <david@...hat.com>
Cc: akpm@...ux-foundation.org, mhocko@...e.com,
dan.j.williams@...el.com, pasha.tatashin@...een.com,
Jonathan.Cameron@...wei.com, anshuman.khandual@....com,
vbabka@...e.cz, linux-mm@...ck.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2 0/5] Allocate memmap from hotadded memory
On Wed, Jun 26, 2019 at 10:15:16AM +0200, Oscar Salvador wrote:
> On Wed, Jun 26, 2019 at 10:11:06AM +0200, David Hildenbrand wrote:
> > Back then, I already mentioned that we might have some users that
> > remove_memory() they never added in a granularity it wasn't added. My
> > concerns back then were never fully sorted out.
> >
> > arch/powerpc/platforms/powernv/memtrace.c
> >
> > - Will remove memory in memory block size chunks it never added
> > - What if that memory resides on a DIMM added via MHP_MEMMAP_DEVICE?
> >
> > Will it at least bail out? Or simply break?
> >
> > IOW: I am not yet 100% convinced that MHP_MEMMAP_DEVICE is save to be
> > introduced.
>
> Uhm, I will take a closer look and see if I can clear your concerns.
> TBH, I did not try to use arch/powerpc/platforms/powernv/memtrace.c
> yet.
>
> I will get back to you once I tried it out.
On a second though, it would be quite trivial to implement a check in
remove_memory() that does not allow to remove memory used with MHP_MEMMAP_DEVICE
in a different granularity:
+static bool check_vmemmap_granularity(u64 start, u64 size);
+{
+ unsigned long pfn;
+ unsigned int nr_pages;
+ struct page *p;
+
+ pfn = PHYS_PFN(start);
+ p = pfn_to_page(pfn);
+ nr_pages = size >> PAGE_SIZE;
+
+ if (PageVmemmap(p)) {
+ struct page *h = vmemmap_get_head(p);
+ unsigned long sections = (unsigned long)h->private;
+
+ if (sections * PAGES_PER_SECTION > nr_pages)
+ fail;
+ }
+ no_fail;
+}
+
+
static int __ref try_remove_memory(int nid, u64 start, u64 size)
{
int rc = 0;
BUG_ON(check_hotplug_memory_range(start, size));
mem_hotplug_begin();
+ rc = check_vmemmap_granularity(start, size);
+ if (rc)
+ goto done;
The above is quite hacky, but it gives an idea.
I will try the code from arch/powerpc/platforms/powernv/memtrace.c and see how
can I implement a check.
--
Oscar Salvador
SUSE L3
Powered by blists - more mailing lists