Received: by 2002:ac0:b08d:0:0:0:0:0 with SMTP id l13csp4790414imc; Mon, 25 Feb 2019 11:04:29 -0800 (PST) X-Google-Smtp-Source: AHgI3IaMw03WcqCRSFclcPnSjXgUecerUBk2h6cMx0rMJuAFZS1QY+faD1KISbTjrjI0XONcE9jS X-Received: by 2002:a17:902:3143:: with SMTP id w61mr22330761plb.253.1551121469595; Mon, 25 Feb 2019 11:04:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551121469; cv=none; d=google.com; s=arc-20160816; b=t8YrKxh2TQ++mg9MFhaHOZxIawGVqlJ2mbSyV6mRbhBDZvy0Nff87R3CymBM/Ty9eB ecB+ZdmDTmIsm1baC1Hcbw/31anII1o7dlzva84PxuTFt/6GtqbRQtdgVm2mhuA6I7oU ksRjbQl6e8SxhzvL2F12evs7pEQsGIvdGGEwUVtaudZnQ7SArFa1aTwogqtdPaBBeRUO zu0xWXaPX9Vz7xHtugExlUDc28/lqLKRgg7psT8pMMtg5Gyer05dq1+8Z0OZLgovhXTo T7DjP5Un0O1Tj4/ZpEpMthSkcW0y9TCrbVc32YqXY6awwlVBgbqhC+Tx5VT21Rr2TJuv kySw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:in-reply-to:references:date :from:cc:to:subject; bh=m3exMRICffW7oyoKK4pXkv1gy7VWxQjl4Jnx4soXu74=; b=ttjOi4zQK2/wlZcd+L/RZVlgW8TGPIHsSA8H8/uajCXNCDJsp1kziHDV6oy4OnSaFV oZr3cmCIc2JHZbaC6pgzp4XEMT8eiqz7I8YB3ESJjP6L1tAdgvWflUWsPThLs+r9zO7k 8Qi3ND88dE9wbTmaJ8NlSptuDSepii1e4vtWEsTI+zQR6fp1+ASTQ4nuAQWnVy1GIUy4 d1RXcg8obMI2U6tQdVDwD3aj11OQHIne6lZMsjoU3Ze09SDR4bAisU9b6G14uT/eqNFS Jnj1y45MTIL/xsher0C7+2+ixIj+864u4NCmi+LTyU35TZGXjl6JL/VrObT3tQZ68fjC Lmgg== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l8si9794687plt.88.2019.02.25.11.04.13; Mon, 25 Feb 2019 11:04:29 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727121AbfBYTDF (ORCPT + 99 others); Mon, 25 Feb 2019 14:03:05 -0500 Received: from mga14.intel.com ([192.55.52.115]:55332 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726737AbfBYTCi (ORCPT ); Mon, 25 Feb 2019 14:02:38 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 Feb 2019 11:02:38 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,412,1544515200"; d="scan'208";a="323272306" Received: from viggo.jf.intel.com (HELO localhost.localdomain) ([10.54.77.144]) by fmsmga005.fm.intel.com with ESMTP; 25 Feb 2019 11:02:37 -0800 Subject: [PATCH 2/5] mm/resource: move HMM pr_debug() deeper into resource code To: linux-kernel@vger.kernel.org Cc: Dave Hansen , jglisse@redhat.com, dan.j.williams@intel.com, dave.jiang@intel.com, zwisler@kernel.org, vishal.l.verma@intel.com, thomas.lendacky@amd.com, akpm@linux-foundation.org, mhocko@suse.com, linux-nvdimm@lists.01.org, linux-mm@kvack.org, ying.huang@intel.com, fengguang.wu@intel.com, keith.busch@intel.com From: Dave Hansen Date: Mon, 25 Feb 2019 10:57:33 -0800 References: <20190225185727.BCBD768C@viggo.jf.intel.com> In-Reply-To: <20190225185727.BCBD768C@viggo.jf.intel.com> Message-Id: <20190225185733.FB5686EB@viggo.jf.intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dave Hansen HMM consumes physical address space for its own use, even though nothing is mapped or accessible there. It uses a special resource description (IORES_DESC_DEVICE_PRIVATE_MEMORY) to uniquely identify these areas. When HMM consumes address space, it makes a best guess about what to consume. However, it is possible that a future memory or device hotplug can collide with the reserved area. In the case of these conflicts, there is an error message in register_memory_resource(). Later patches in this series move register_memory_resource() from using request_resource_conflict() to __request_region(). Unfortunately, __request_region() does not return the conflict like the previous function did, which makes it impossible to check for IORES_DESC_DEVICE_PRIVATE_MEMORY in a conflicting resource. Instead of warning in register_memory_resource(), move the check into the core resource code itself (__request_region()) where the conflicting resource _is_ available. This has the added bonus of producing a warning in case of HMM conflicts with devices *or* RAM address space, as opposed to the RAM- only warnings that were there previously. Signed-off-by: Dave Hansen Reviewed-by: Jerome Glisse Cc: Dan Williams Cc: Dave Jiang Cc: Ross Zwisler Cc: Vishal Verma Cc: Tom Lendacky Cc: Andrew Morton Cc: Michal Hocko Cc: linux-nvdimm@lists.01.org Cc: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org Cc: Huang Ying Cc: Fengguang Wu Cc: Keith Busch --- b/kernel/resource.c | 9 +++++++++ b/mm/memory_hotplug.c | 5 ----- 2 files changed, 9 insertions(+), 5 deletions(-) diff -puN kernel/resource.c~move-request_region-check kernel/resource.c --- a/kernel/resource.c~move-request_region-check 2019-02-25 10:56:48.581908031 -0800 +++ b/kernel/resource.c 2019-02-25 10:56:48.588908031 -0800 @@ -1132,6 +1132,15 @@ struct resource * __request_region(struc conflict = __request_resource(parent, res); if (!conflict) break; + /* + * mm/hmm.c reserves physical addresses which then + * become unavailable to other users. Conflicts are + * not expected. Warn to aid debugging if encountered. + */ + if (conflict->desc == IORES_DESC_DEVICE_PRIVATE_MEMORY) { + pr_warn("Unaddressable device %s %pR conflicts with %pR", + conflict->name, conflict, res); + } if (conflict != parent) { if (!(conflict->flags & IORESOURCE_BUSY)) { parent = conflict; diff -puN mm/memory_hotplug.c~move-request_region-check mm/memory_hotplug.c --- a/mm/memory_hotplug.c~move-request_region-check 2019-02-25 10:56:48.583908031 -0800 +++ b/mm/memory_hotplug.c 2019-02-25 10:56:48.588908031 -0800 @@ -111,11 +111,6 @@ static struct resource *register_memory_ res->flags = IORESOURCE_SYSTEM_RAM | IORESOURCE_BUSY; conflict = request_resource_conflict(&iomem_resource, res); if (conflict) { - if (conflict->desc == IORES_DESC_DEVICE_PRIVATE_MEMORY) { - pr_debug("Device unaddressable memory block " - "memory hotplug at %#010llx !\n", - (unsigned long long)start); - } pr_debug("System RAM resource %pR cannot be added\n", res); kfree(res); return ERR_PTR(-EEXIST); _