From patchwork Mon Oct 15 15:30:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oscar Salvador X-Patchwork-Id: 10642055 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 B925B925 for ; Mon, 15 Oct 2018 15:31:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A6FDB29AF4 for ; Mon, 15 Oct 2018 15:31:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9AE0929B05; Mon, 15 Oct 2018 15:31:09 +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 38DE829AF4 for ; Mon, 15 Oct 2018 15:31:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CE4CB6B000E; Mon, 15 Oct 2018 11:30:57 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id C736E6B0010; Mon, 15 Oct 2018 11:30:57 -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 A51016B0266; Mon, 15 Oct 2018 11:30:57 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by kanga.kvack.org (Postfix) with ESMTP id 2EEEC6B0010 for ; Mon, 15 Oct 2018 11:30:57 -0400 (EDT) Received: by mail-wr1-f71.google.com with SMTP id f13-v6so16579304wrr.4 for ; Mon, 15 Oct 2018 08:30:57 -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=JKE318wIKCFxCuunfg2WJB1Hno/yv4pQr9QRB3MB9UE=; b=lH5PNMlUL7GlAK2c9TGJgVcuczTOsdGCQCzJOxykTI+cXeu3DJQtnP3v9eNT+pBjqY 5sOBUk+iyVfhRFSJrMXWlMFSOwOFdHBrQMmzZoo9r/jWry1K8MddjbEk5P9qrHkkPlgD i29ZZGZ0anqY5aJ4+JYMtPcWtx/X7mkSV5Ywfo53AX8pxNjdVt9db+hKi6VRHgUrBqpr bWLRo64sBAAJXFh01quBGorcp654ZnewBbEb2vfC1saMkK5IsSrnf2Rcb9+K26drRkjQ AHxWxtMaZrJxhIwocyVS6Jyk6JHvXfxWiQm/5riCNgioVpyml4p+OOdhyYyR+pWentKo bB3g== 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: ABuFfogwNsWLc/8z+92ktIwV8i9HswarvqjfI3MloxVeQLLHuGDWcshm RcSqKchd43kUwtZbBjPUbJ5rDIRAEvgKp125BKgwK5Xw0HTCd3+ThKPSn3PdLfpYVMt6gLwYUcj Rfqx/MEgLwV5oGWhO7hzWzxyKQc+dQu+6SinhA2YwMrChhg0YSbgmYUCoXH7Mqw6hUwRiMZqaFX zagH2kaDPtxnN43vdKgwlRCXCL+MmxrDzbDQeLUqE83fUB9ozGm0PZQofxn/cttHHg9OHYwHlYe VZDtw88wUn2X/gE9+AAq85CLBZSvM2WKak6svNtUbuoGgPLykCNsmO8o1rni+zHnA2qF3TxrJCq AdYHZ2u6tbzT7NNaCc3slduk8LU6iPOFKeYFRg4BW3cexD6vLh4WA8gP0GeCaoOfQ4DkHR5abg= = X-Received: by 2002:adf:84e6:: with SMTP id 93-v6mr16024148wrg.144.1539617456708; Mon, 15 Oct 2018 08:30:56 -0700 (PDT) X-Received: by 2002:adf:84e6:: with SMTP id 93-v6mr16024072wrg.144.1539617455452; Mon, 15 Oct 2018 08:30:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539617455; cv=none; d=google.com; s=arc-20160816; b=U5cWHd3l8Nxr/NwDB2krWyNlh6QG8MRW2+gEdghJrofmpsHZ2A7OFM1wtilss3gicn a1h+PjGvBdSZRET8ag9A4n1EklfgaQiP3PkPc68GEtsZa/O7zWaHn/mNGSj+FJuPa6/1 /1mBV4oTUJaHnaxme9BrBK7jgttPRdayQeEspcVvblTjK/1lTHUwPLJEgZmPJ+OPD3M6 +K2ranY5zUPli+sngvU+pL7hqmXBMQh7tpJXZhI5uYD/Bt87hebKSLgvTiiVQutCBSlX xjwjK3vfhpqcWlvCRstiLXMlN4aYk9kmZlNQA2Hf0qTQ9ZPll1TC1s1HFoMRYvylWCR8 dLTA== 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=JKE318wIKCFxCuunfg2WJB1Hno/yv4pQr9QRB3MB9UE=; b=IIzyIxCfdaWlVucv0AeYT9CMQpQ2xhkFadSXeejQkFrfv2D23oyhndOo7LhxSAJQHG jAribHlndkkhfh3ZndC9z7N04ZX3MRV2ngIRg6TfNkNJ2jRmiSQJ7C1fIb2pjJS84eGt +0Q4gZ+34jGXcPmLwMYvMEUrnvwSHRj5Rdg9LTTlg1Q9+vCC7kWP1Tfje2rGfPHKCnkf XsmM7Vt65gQ6NXuqmLoUa3/UrllAU/qOffvOgA5D3o3BkPakkSGWulqcgbZuE1vaUDGS LaCVeCHiXslEAIc2zKzPJS1G0pJCOifXWgFXUd3Oyv3S+304DeipB4hag84/UnG0ozAU golg== 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 k18-v6sor6205205wrv.2.2018.10.15.08.30.55 for (Google Transport Security); Mon, 15 Oct 2018 08:30:55 -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: ACcGV60wvEZ8JvfJapnVl+qBRKKwzhci+rtNmrhU40OZeeKHlRQJvUMi6foPtmo15PHXMVJtGnwGVw== X-Received: by 2002:adf:a352:: with SMTP id d18-v6mr14941988wrb.31.1539617455156; Mon, 15 Oct 2018 08:30:55 -0700 (PDT) Received: from techadventures.net (techadventures.net. [62.201.165.239]) by smtp.gmail.com with ESMTPSA id a1-v6sm8859580wrt.79.2018.10.15.08.30.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 15 Oct 2018 08:30:54 -0700 (PDT) Received: from d104.suse.de (charybdis-ext.suse.de [195.135.221.2]) by techadventures.net (Postfix) with ESMTPA id 4B1191259A8; Mon, 15 Oct 2018 17:30:52 +0200 (CEST) From: Oscar Salvador To: akpm@linux-foundation.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, linux-mm@kvack.org, alexander.h.duyck@linux.intel.com, Oscar Salvador Subject: [PATCH 3/5] mm/memory_hotplug: Check for IORESOURCE_SYSRAM in release_mem_region_adjustable Date: Mon, 15 Oct 2018 17:30:32 +0200 Message-Id: <20181015153034.32203-4-osalvador@techadventures.net> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20181015153034.32203-1-osalvador@techadventures.net> References: <20181015153034.32203-1-osalvador@techadventures.net> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, 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 Reviewed-by: David Hildenbrand Reviewed-by: Pavel Tatashin --- 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;