From patchwork Tue Oct 2 15:00:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oscar Salvador X-Patchwork-Id: 10623817 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A659415A7 for ; Tue, 2 Oct 2018 15:00:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 96DBA20683 for ; Tue, 2 Oct 2018 15:00:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9400621BED; Tue, 2 Oct 2018 15:00:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2C0C3212BE for ; Tue, 2 Oct 2018 15:00:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 34A646B0008; Tue, 2 Oct 2018 11:00:53 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 2F8E96B000D; Tue, 2 Oct 2018 11:00:53 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1BF6C6B000E; Tue, 2 Oct 2018 11:00:53 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by kanga.kvack.org (Postfix) with ESMTP id B1D816B0008 for ; Tue, 2 Oct 2018 11:00:52 -0400 (EDT) Received: by mail-wr1-f70.google.com with SMTP id v33-v6so1873700wrc.13 for ; Tue, 02 Oct 2018 08:00:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=Lwbd+UcWSdJD5I10DIEnUzZN/CNn2JSB+Sr2UG85mb8=; b=OYnLmYxBQgaXRVs+UUby5z8GMu7MFpQXXpNfRZVr1NJW3MUfQrm2r9V7wGj7/0bYxl U8Gm8TGZ2eChik5a8kvEFMUDuaYN5zWrVYf7NRqJqu+QiCxLuBnbZTfBIWiSFoTL3QAZ Eaj+ycWY3875r2/4GczeU1p0DnHuStm105lxkdNpwVCsoIgJAFenUBh8l4rLU0UDAwmr 3WM82NYekPWBL75EIgysJBwigL6inxCRWbVtyt8m3dXtLFTJyI7D5kWV5DDbZbVoEAZ2 E1RYc/WKPpORu27hVvfm8n/NmSL48onbjLSkLcJQC+AOIhWQPOltrmcVzNq5po+ucl2s oMbg== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of osalvador.vilardaga@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=osalvador.vilardaga@gmail.com X-Gm-Message-State: ABuFfoicru9mYxJynYeMYLnkNSMurxtdpBqMCHhA8JgyHalW99XMHQHo b8p+FhRC3sPWyTvR4r/s3NLJVaYLFI++MVnVGjHvteq8csFh+JkOZKNbf/OiCQaV6d68IJv8y63 4fZS8ykAuRYihaisOQ1qH1AZozqXSc3kkCgwBQ6jZk1TzjNYVRNJciw6QDhpjCBKB+VRLcNRyz3 2lcPTRx6n/1HPzhhLWZnHQrgzQtSPuVk6qWVHPofwZHLHrty31TNDxmDxqP3nUX97G47xodYJpt wJe4M6S2F1d6k3xe+1MxFZEaw9oXnuFYamsaBb9gc5intBOZYRfL36SdDrKCpk+5tI5A5ysYYxv eFtDorXeWQtY0cX5NyRdEmMAmupk/cWsrujeT+skW6ljoOxi+InIay6gA07yb0up6pBX2eYZrA= = X-Received: by 2002:a1c:2052:: with SMTP id g79-v6mr2246628wmg.42.1538492451960; Tue, 02 Oct 2018 08:00:51 -0700 (PDT) X-Received: by 2002:a1c:2052:: with SMTP id g79-v6mr2246510wmg.42.1538492450082; Tue, 02 Oct 2018 08:00:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538492450; cv=none; d=google.com; s=arc-20160816; b=CMDB0B9WMoakokxbFK6fgLoEhDNUtWJGbZzS8D92xYhycoHqc2uLTBIVEQq9vLYpeX 5JxnT3naW5BXpWmXgf2+iB5Eqird6qNXT50kTW8aCPyn5V42MxQ3N7Z4yYTTOJToot5u lJn1yoDx113ndgfEVwEkDxDK1/Qmb4c81SHJBiyO/u+dt7qlJlBYJLGhDvo72u59oyiR s7iXzw04KJKeM/ZQmnAYODrH39LaC/nuACxPXvYbTbpCMoNnKTSyGdR0wN44X3oleWJ7 +PpLmnT5sE6pb4wc8C5LhZKjRsli5lF9z6aKhjgQlkwkS2GUQiYeO+oEDy1ccMtGc/XT vKqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from; bh=Lwbd+UcWSdJD5I10DIEnUzZN/CNn2JSB+Sr2UG85mb8=; b=MrWloqFpGpA4WNJE2ti2IDc3zRJQrjhrDd9u0eI0G3E66Ahf24s3BDP5IzSradoG2V pBUnrhEqAlgZ63PLEwNknb/YMzzXIxSfjisEhTrc2FCFbiSBxvccOzL0mmyK+k1hmLic iGmwId56OD/ZoVGWKwcQahOy1INvp1Rd1QEKiVoR/A9Jb1bJtnd2pNEwieU15y80gZ8b Vz9koYWhAgCEHQSYI2gHjEejwBp9z914UT4v8XRCyZkN4uvEfJeiNhdmg4KAOEB+j23g K5qi1cttlM2yCoH1vCpw1OMzjBQl1DLKysoIMCcv1GDOqF3k37VzSeNCrTZF7QfQXGnt TKMg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of osalvador.vilardaga@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=osalvador.vilardaga@gmail.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id a12-v6sor8251259wrc.42.2018.10.02.08.00.49 for (Google Transport Security); Tue, 02 Oct 2018 08:00:50 -0700 (PDT) Received-SPF: pass (google.com: domain of osalvador.vilardaga@gmail.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; spf=pass (google.com: domain of osalvador.vilardaga@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=osalvador.vilardaga@gmail.com X-Google-Smtp-Source: ACcGV612eFxvdBhOaQBF5tFOJo32uiL1RlMkLE+CfelcEbtS8cxLLU0cgvxMMiBOfvjwD0RCQXjugg== X-Received: by 2002:adf:eec4:: with SMTP id a4-v6mr11645875wrp.242.1538492449727; Tue, 02 Oct 2018 08:00:49 -0700 (PDT) Received: from techadventures.net (techadventures.net. [62.201.165.239]) by smtp.gmail.com with ESMTPSA id z89-v6sm37733989wrb.3.2018.10.02.08.00.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 02 Oct 2018 08:00:48 -0700 (PDT) Received: from d104.suse.de (charybdis-ext.suse.de [195.135.221.2]) by techadventures.net (Postfix) with ESMTPA id A677612572A; Tue, 2 Oct 2018 17:00:47 +0200 (CEST) From: Oscar Salvador To: linux-mm@kvack.org Cc: 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, Oscar Salvador Subject: [RFC PATCH v3 3/5] mm/memory_hotplug: Check for IORESOURCE_SYSRAM in release_mem_region_adjustable Date: Tue, 2 Oct 2018 17:00:27 +0200 Message-Id: <20181002150029.23461-4-osalvador@techadventures.net> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20181002150029.23461-1-osalvador@techadventures.net> References: <20181002150029.23461-1-osalvador@techadventures.net> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000008, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP 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 | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/kernel/resource.c b/kernel/resource.c index 81937830a42f..6956ce3a4730 100644 --- a/kernel/resource.c +++ b/kernel/resource.c @@ -1272,6 +1272,21 @@ 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/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;