Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp4466145imu; Mon, 12 Nov 2018 11:29:36 -0800 (PST) X-Google-Smtp-Source: AJdET5eTpa9sksukANcHdQzpHKf64hYSt/jipumnDMu0zftpzPwkLEULLAy2MC+0dPMGLErjqoyQ X-Received: by 2002:a63:c00b:: with SMTP id h11mr1925484pgg.429.1542050976074; Mon, 12 Nov 2018 11:29:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542050976; cv=none; d=google.com; s=arc-20160816; b=NggakF5toy6bGGxBTYiXyNwIeNcXLoydAwktPWnp+n7pPJYpv7Xi5fAhmnFyRhbK7F o3Oxl1Lydo/EN0GCNQANccHlieN897jb4ZY2VA7DVE+egLFUZksYnzTF9LaLdE4Bo0tW ZnK9bCXf00UIwp0J5RVgB9n9uV9NxqYs34qhGAFoIUhHmvGpeNKMckFBe3dJTfSI2/UJ Y/im7OByOPEjr7BUZQTb6P11SvZHZWtazxXD4jfuthh56NXaBO/xjbKzNgDkyE6i0z0A XvXrokRg2eBMN3zrGInDMAuyHIKV/NHI4riYheVzzWzVQJiI8MImrrTwzIUde0gOpdhr xBhQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=9bK+gzQLuKY79RPbvo3kKmdJhCipAQkgVnNU9Jm1Kn8=; b=H8x+VaX18SuCFhKm89y3i+qnPpPr3fWSgjBbZJ5ZUXCmH1YA+Shrlpf1K8vqtk2C/I 3usYd8FrUA1ex5GsOwPBtb9YQyjxVyaSt1XtG0/+1zIVSsqW+6n09EQRQHMFZWndR/j9 Mp0EGa3/wJ8TNruLemt5WlMyfzenTMqHgQoQVSQIZvsSXZ3bQjZXTUOiTr9ZEzk2otBw Z6a6LjG6iiHyguqCr6ghXv/9u99glX6fuSjsrTu+48ILIpXeSGocyJT1SUdsIt4MciUt LwO0HwiKgGqA11p48sH6R4Un/NhbOYV6mUBr6mG02rxl/Z0W+sOOsRb9nipzD3UdaHIH rrYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=temperror (no key for signature) header.i=@soleen.com header.s=google header.b=jRLM9XR8; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b6si11288877pgg.2.2018.11.12.11.29.19; Mon, 12 Nov 2018 11:29:36 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=temperror (no key for signature) header.i=@soleen.com header.s=google header.b=jRLM9XR8; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726391AbeKMFWT (ORCPT + 99 others); Tue, 13 Nov 2018 00:22:19 -0500 Received: from mail-qk1-f195.google.com ([209.85.222.195]:42315 "EHLO mail-qk1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725790AbeKMFWT (ORCPT ); Tue, 13 Nov 2018 00:22:19 -0500 Received: by mail-qk1-f195.google.com with SMTP id m5so15384422qka.9 for ; Mon, 12 Nov 2018 11:27:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=9bK+gzQLuKY79RPbvo3kKmdJhCipAQkgVnNU9Jm1Kn8=; b=jRLM9XR8onQUSbnerEGcxqGmWdALddDoA16gmxoEE4pu/yjB4jUxSlq5pfa4kC6unW wj82NAy+oPRvLXwjy0yjzy0DbftczMB1iZ7/orzO4CPsFyP54bcmyp3pOSh0gZROml+f XL49Gk4u8TFuO2a6zIrgJ9Bu+W+BHRRD2CZwptu0zRl580k5XI+Qp4bUxfOXRRF4rnml EEYfATltzvKt5DjnN8B2F+soMy+9e9xFxZ35ORP8RlDu5sw0Gh8l/EU+6h7a1s8drwGW mWV52xHoFGLDtNBZbKEXPE2UfkA21a5mlVsk1HZO1JVj1qyJhxg7cWk0b+/RtC/9ZkDC 8Ufw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=9bK+gzQLuKY79RPbvo3kKmdJhCipAQkgVnNU9Jm1Kn8=; b=gOuM1hGqHXwqb/g3PllnDha9NjyhUUzWRucHftBgmLaOUc5n6qee2khVrUZOjqvCTT ZXb4igrkfTP3Xbbsw75FFyCbHBVZQHKml9LptWuBUND3X6mUqQkWdU25PAacDX0klETD acqhZHbqGCLfIWqR9unzIzuqksroMCQ0N+EPREZJ3QSMI6NCLEv6Gwi+XqR7JZagLOC/ q37uCYA3LpdjEPtFShYnR9ZSjh3nMIuofw0xyYRmYvvP0YgAcEB0jkLFy08lNLcSWiIp rpgniSlnOCp1Wjs1cR8pLKVj6PV3My9aAxejy9qJ2/1W07M1g2pXgwcD5jnN6pxVRRgX 1qYw== X-Gm-Message-State: AGRZ1gIWF4KEeMGBuSHKmgUbmr00mCJCnoBbQwNrB61wo/aUd+M1sIrl fmtW2e9PA/QwRj40keEvimdtgQ== X-Received: by 2002:ac8:36d9:: with SMTP id b25mr2229258qtc.49.1542050861754; Mon, 12 Nov 2018 11:27:41 -0800 (PST) Received: from soleen.tm1wkky2jk1uhgkn0ivaxijq1c.bx.internal.cloudapp.net ([40.117.208.181]) by smtp.gmail.com with ESMTPSA id b17sm9486891qkj.69.2018.11.12.11.27.39 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 12 Nov 2018 11:27:40 -0800 (PST) Date: Mon, 12 Nov 2018 19:27:38 +0000 From: Pavel Tatashin To: Oscar Salvador 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 Subject: Re: [PATCH 3/5] mm/memory_hotplug: Check for IORESOURCE_SYSRAM in release_mem_region_adjustable Message-ID: <20181112192738.n3cbsgtbjokikvco@soleen.tm1wkky2jk1uhgkn0ivaxijq1c.bx.internal.cloudapp.net> References: <20181015153034.32203-1-osalvador@techadventures.net> <20181015153034.32203-4-osalvador@techadventures.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181015153034.32203-4-osalvador@techadventures.net> User-Agent: NeoMutt/20180716 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 18-10-15 17:30:32, Oscar Salvador wrote: > From: Oscar Salvador > > 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 > --- > 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 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