[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20180816173201.GC28097@redhat.com>
Date: Thu, 16 Aug 2018 13:32:01 -0400
From: Jerome Glisse <jglisse@...hat.com>
To: Oscar Salvador <osalvador@...hadventures.net>
Cc: Michal Hocko <mhocko@...nel.org>, akpm@...ux-foundation.org,
dan.j.williams@...el.com, Pavel.Tatashin@...rosoft.com,
david@...hat.com, yasu.isimatu@...il.com, logang@...tatee.com,
dave.jiang@...el.com, linux-mm@...ck.org,
linux-kernel@...r.kernel.org, Oscar Salvador <osalvador@...e.de>
Subject: Re: [RFC PATCH 2/3] mm/memory_hotplug: Create __shrink_pages and
move it to offline_pages
On Thu, Aug 16, 2018 at 04:58:49PM +0200, Oscar Salvador wrote:
> On Thu, Aug 09, 2018 at 12:58:21PM -0400, Jerome Glisse wrote:
> > I agree, i never thought about that before. Looking at existing resource
> > management i think the simplest solution would be to use a refcount on the
> > resources instead of the IORESOURCE_BUSY flags.
> >
> > So when you release resource as part of hotremove you would only dec the
> > refcount and a resource is not busy only when refcount is zero.
> >
> > Just the idea i had in mind. Right now i am working on other thing, Oscar
> > is this something you would like to work on ? Feel free to come up with
> > something better than my first idea :)
>
> So, I thought a bit about this.
> First I talked a bit with Jerome about the refcount idea.
> The problem with reconverting this to refcount is that it is too intrusive,
> and I think it is not really needed.
>
> I then thought about defining a new flag, something like
>
> #define IORESOURCE_NO_HOTREMOVE xxx
>
> but we ran out of bits for the flag field.
>
> I then thought about doing something like:
>
> struct resource {
> resource_size_t start;
> resource_size_t end;
> const char *name;
> unsigned long flags;
> unsigned long desc;
> struct resource *parent, *sibling, *child;
> #ifdef CONFIG_MEMORY_HOTREMOVE
> bool device_managed;
> #endif
> };
>
> but it is just too awful, not needed, and bytes consuming.
Agree the above is ugly.
>
> The only idea I had left is:
>
> register_memory_resource(), which defines a new resource for the added memory-chunk
> is only called from add_memory().
> This function is only being hit when we add memory-chunks.
>
> HMM/devm gets the resources their own way, calling devm_request_mem_region().
>
> So resources that are requested from HMM/devm, have the following flags:
>
> (IORESOURCE_MEM|IORESOURCE_BUSY)
>
> while resources that are requested via mem-hotplug have:
>
> (IORESOURCE_SYSTEM_RAM | IORESOURCE_BUSY)
>
> IORESOURCE_SYSTEM_RAM = (IORESOURCE_MEM|IORESOURCE_SYSRAM)
>
>
> release_mem_region_adjustable() is only being called from hot-remove path, so
> unless I am mistaken, all resources hitting that path should match IORESOURCE_SYSTEM_RAM.
>
> That leaves me with the idea that we could check for the resource->flags to contain IORESOURCE_SYSRAM,
> as I think it is only being set for memory-chunks that are added via memory-hot-add path.
>
> In case it is not, we know that that resource belongs to HMM/devm, so we can back off since
> they take care of releasing the resource via devm_release_mem_region.
>
> I am working on a RFC v2 containing this, but, Jerome, could you confirm above assumption, please?
I think you nail it. I am not 100% sure about devm as i have not
followed closely how persistent memory can be reported by ACPI. But
i am pretty sure it should never end up as SYSRAM.
Thank you for scratching your head on this :)
Cheers,
Jérôme
Powered by blists - more mailing lists