From: Pavel Tatashin <pasha.tatashin@soleen.com>
To: Oscar Salvador <osalvador@techadventures.net>
Cc: akpm@linux-foundation.org, mhocko@suse.com,
dan.j.williams@intel.com, yasu.isimatu@gmail.com,
rppt@linux.vnet.ibm.com, malat@debian.org,
linux-kernel@vger.kernel.org, pavel.tatashin@microsoft.com,
jglisse@redhat.com, Jonathan.Cameron@huawei.com,
rafael@kernel.org, david@redhat.com, dave.jiang@intel.com,
linux-mm@kvack.org, alexander.h.duyck@linux.intel.com,
Oscar Salvador <osalvador@suse.de>
Subject: Re: [PATCH 3/5] mm/memory_hotplug: Check for IORESOURCE_SYSRAM in release_mem_region_adjustable
Date: Mon, 12 Nov 2018 19:27:38 +0000 [thread overview]
Message-ID: <20181112192738.n3cbsgtbjokikvco@soleen.tm1wkky2jk1uhgkn0ivaxijq1c.bx.internal.cloudapp.net> (raw)
In-Reply-To: <20181015153034.32203-4-osalvador@techadventures.net>
On 18-10-15 17:30:32, Oscar Salvador wrote:
> From: Oscar Salvador <osalvador@suse.de>
>
> This is a preparation for the next patch.
>
> Currently, we only call release_mem_region_adjustable() in __remove_pages
> if the zone is not ZONE_DEVICE, because resources that belong to
> HMM/devm are being released by themselves with devm_release_mem_region.
>
> Since we do not want to touch any zone/page stuff during the removing
> of the memory (but during the offlining), we do not want to check for
> the zone here.
> So we need another way to tell release_mem_region_adjustable() to not
> realease the resource in case it belongs to HMM/devm.
>
> HMM/devm acquires/releases a resource through
> devm_request_mem_region/devm_release_mem_region.
>
> These resources have the flag IORESOURCE_MEM, while resources acquired by
> hot-add memory path (register_memory_resource()) contain
> IORESOURCE_SYSTEM_RAM.
>
> So, we can check for this flag in release_mem_region_adjustable, and if
> the resource does not contain such flag, we know that we are dealing with
> a HMM/devm resource, so we can back off.
>
> Signed-off-by: Oscar Salvador <osalvador@suse.de>
> ---
> kernel/resource.c | 16 ++++++++++++++++
> 1 file changed, 16 insertions(+)
>
> diff --git a/kernel/resource.c b/kernel/resource.c
> index 81937830a42f..c45decd7d6af 100644
> --- a/kernel/resource.c
> +++ b/kernel/resource.c
> @@ -1272,6 +1272,22 @@ int release_mem_region_adjustable(struct resource *parent,
> continue;
> }
>
> + /*
> + * All memory regions added from memory-hotplug path
> + * have the flag IORESOURCE_SYSTEM_RAM.
> + * If the resource does not have this flag, we know that
> + * we are dealing with a resource coming from HMM/devm.
> + * HMM/devm use another mechanism to add/release a resource.
> + * This goes via devm_request_mem_region and
> + * devm_release_mem_region.
> + * HMM/devm take care to release their resources when they want,
> + * so if we are dealing with them, let us just back off here.
> + */
> + if (!(res->flags & IORESOURCE_SYSRAM)) {
> + ret = 0;
> + break;
> + }
> +
> if (!(res->flags & IORESOURCE_MEM))
> break;
Reviewed-by: Pavel Tatashin <pasha.tatashin@soleen.com>
A couple nits, re-format above comment block to fill 80-char limit:
/*
* All memory regions added from memory-hotplug path have the
* flag IORESOURCE_SYSTEM_RAM. If the resource does not have
* this flag, we know that we are dealing with a resource coming
* from HMM/devm. HMM/devm use another mechanism to add/release
* a resource. This goes via devm_request_mem_region and
* devm_release_mem_region. HMM/devm take care to release their
* resources when they want, so if we are dealing with them, let
* us just back off here.
*/
I would set ret = 0, at the beginning instead of -EINVAL, and change
returns accordingly.
Thank you,
Pasha
next prev parent reply other threads:[~2018-11-12 19:27 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-15 15:30 [PATCH 0/5] Do not touch pages/zones during hot-remove path Oscar Salvador
2018-10-15 15:30 ` [PATCH 1/5] mm/memory_hotplug: Add nid parameter to arch_remove_memory Oscar Salvador
2018-11-12 18:52 ` Pavel Tatashin
2018-10-15 15:30 ` [PATCH 2/5] mm/memory_hotplug: Create add/del_device_memory functions Oscar Salvador
2018-10-16 8:55 ` David Hildenbrand
2018-10-17 9:33 ` Oscar Salvador
2018-10-17 9:45 ` David Hildenbrand
2018-10-18 6:57 ` Oscar Salvador
2018-11-12 19:14 ` Pavel Tatashin
2018-11-12 19:21 ` Dan Williams
2018-11-12 21:28 ` Pavel Tatashin
2018-11-16 13:06 ` osalvador
2018-11-16 13:03 ` osalvador
2018-10-15 15:30 ` [PATCH 3/5] mm/memory_hotplug: Check for IORESOURCE_SYSRAM in release_mem_region_adjustable Oscar Salvador
2018-10-16 9:54 ` David Hildenbrand
2018-11-12 19:27 ` Pavel Tatashin [this message]
2018-10-15 15:30 ` [PATCH 4/5] mm/memory_hotplug: Move zone/pages handling to offline stage Oscar Salvador
2018-10-15 15:30 ` [PATCH 5/5] mm/memory-hotplug: Rework unregister_mem_sect_under_nodes Oscar Salvador
2018-10-18 14:24 ` Jonathan Cameron
2018-10-18 15:02 ` Oscar Salvador
2018-10-18 15:38 ` Jonathan Cameron
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=20181112192738.n3cbsgtbjokikvco@soleen.tm1wkky2jk1uhgkn0ivaxijq1c.bx.internal.cloudapp.net \
--to=pasha.tatashin@soleen.com \
--cc=Jonathan.Cameron@huawei.com \
--cc=akpm@linux-foundation.org \
--cc=alexander.h.duyck@linux.intel.com \
--cc=dan.j.williams@intel.com \
--cc=dave.jiang@intel.com \
--cc=david@redhat.com \
--cc=jglisse@redhat.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=osalvador@techadventures.net \
--cc=pavel.tatashin@microsoft.com \
--cc=rafael@kernel.org \
--cc=rppt@linux.vnet.ibm.com \
--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).