Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp797126imu; Fri, 25 Jan 2019 11:09:18 -0800 (PST) X-Google-Smtp-Source: ALg8bN75bjLnE7koOo+T36/HYbUFgfj3jxq1WoShZGB2aJvHBqWFHzVun7mKqaE6MTvCseMK+y8C X-Received: by 2002:a63:7044:: with SMTP id a4mr10814251pgn.359.1548443358304; Fri, 25 Jan 2019 11:09:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548443358; cv=none; d=google.com; s=arc-20160816; b=vfX86fbbDgBKG7vorDMrzgdDg3vEexjF3ULsY7e3cSePd8g/KqsLy42A8Vru/fjtQ9 4BNl/TCfKhFtmGOD66WHT5pAuqbChIU6GfAAuV0bUKhGOw1dYMYekxXvYcVnO8Fx7Ar6 rvdZFCgi/AWDRx1iEDyFwK6Q6K9QKq5LCEltm/o/U/EyDNamjUOy6Gy/5R0ccHePXwJi CgRb5+PsrZua2DRBvW91AQLtxrG8EIHFpPC11P78tdSjP2syaFYYECfgNoc6H7WqvUt7 lwWqneLx1ouQgcFTV6IonHT95c0pt/o8NRNYMzSc4l1MhYhN+2kFwV544mUvpS5z5q4b uJyw== 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; bh=tcciQ6O62Vgtg8PBWI3rNY/DSzOYYpxqLqX7+Abco3g=; b=iAXdy8zmyi26jhNIfn5c4w4J2ZA9hvlliz0bzBthn1GCXbQfHtxEzNvTOq3DHvcg9G gxLByNSJL6nEX8XOrDfSW/3cgAqV8nPVUteYWwlw+1UV1nTrGc+iqToN0la3dLvKrXkI KPEbl/4ba3fqv9428hXQq6znPdrhBSvr7P+cMnxNxP2gkGoRJTr6U9cROdaO+51niX0T RWbUhiOXGFime4Zh0dvj7audyTic6Jr5XSkIIGriEw59bm/scSBwS5QJs5I1rl5xxLT7 pNNaGwr3pD1pU2XnoevqUWhWusiHYw+U71uGaB8KFyvijarAmSl0iMz+m+fVFSUlE2Tg Ytqw== 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q10si4071068pll.221.2019.01.25.11.09.03; Fri, 25 Jan 2019 11:09:18 -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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727869AbfAYTHZ (ORCPT + 99 others); Fri, 25 Jan 2019 14:07:25 -0500 Received: from mx1.redhat.com ([209.132.183.28]:57012 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725976AbfAYTHV (ORCPT ); Fri, 25 Jan 2019 14:07:21 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6C8A91B98; Fri, 25 Jan 2019 19:07:21 +0000 (UTC) Received: from redhat.com (ovpn-122-28.rdu2.redhat.com [10.10.122.28]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6238F17D93; Fri, 25 Jan 2019 19:07:19 +0000 (UTC) Date: Fri, 25 Jan 2019 14:07:17 -0500 From: Jerome Glisse To: Dave Hansen Cc: linux-kernel@vger.kernel.org, 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 Subject: Re: [PATCH 2/5] mm/resource: move HMM pr_debug() deeper into resource code Message-ID: <20190125190716.GB3237@redhat.com> References: <20190124231441.37A4A305@viggo.jf.intel.com> <20190124231444.38182DD8@viggo.jf.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190124231444.38182DD8@viggo.jf.intel.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Fri, 25 Jan 2019 19:07:21 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jan 24, 2019 at 03:14:44PM -0800, Dave Hansen wrote: > > 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 > 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 Reviewed-by: Jerome Glisse > --- > > b/kernel/resource.c | 10 ++++++++++ > b/mm/memory_hotplug.c | 5 ----- > 2 files changed, 10 insertions(+), 5 deletions(-) > > diff -puN kernel/resource.c~move-request_region-check kernel/resource.c > --- a/kernel/resource.c~move-request_region-check 2019-01-24 15:13:14.453199539 -0800 > +++ b/kernel/resource.c 2019-01-24 15:13:14.458199539 -0800 > @@ -1123,6 +1123,16 @@ 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. Be verbose if one is encountered. > + */ > + if (conflict->desc == IORES_DESC_DEVICE_PRIVATE_MEMORY) { > + pr_debug("Resource conflict with unaddressable " > + "device memory at %#010llx !\n", > + (unsigned long long)start); > + } > 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-01-24 15:13:14.455199539 -0800 > +++ b/mm/memory_hotplug.c 2019-01-24 15:13:14.459199539 -0800 > @@ -109,11 +109,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); > _