lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20181112192738.n3cbsgtbjokikvco@soleen.tm1wkky2jk1uhgkn0ivaxijq1c.bx.internal.cloudapp.net>
Date:   Mon, 12 Nov 2018 19:27:38 +0000
From:   Pavel Tatashin <pasha.tatashin@...een.com>
To:     Oscar Salvador <osalvador@...hadventures.net>
Cc:     akpm@...ux-foundation.org, mhocko@...e.com,
        dan.j.williams@...el.com, yasu.isimatu@...il.com,
        rppt@...ux.vnet.ibm.com, malat@...ian.org,
        linux-kernel@...r.kernel.org, pavel.tatashin@...rosoft.com,
        jglisse@...hat.com, Jonathan.Cameron@...wei.com, rafael@...nel.org,
        david@...hat.com, dave.jiang@...el.com, linux-mm@...ck.org,
        alexander.h.duyck@...ux.intel.com,
        Oscar Salvador <osalvador@...e.de>
Subject: Re: [PATCH 3/5] mm/memory_hotplug: Check for IORESOURCE_SYSRAM in
 release_mem_region_adjustable

On 18-10-15 17:30:32, Oscar Salvador wrote:
> From: Oscar Salvador <osalvador@...e.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@...e.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@...een.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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ