Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp122501imm; Tue, 7 Aug 2018 15:14:56 -0700 (PDT) X-Google-Smtp-Source: AA+uWPxnK/pR9eaIM4Rn9aoXMN1VTCzTGILwtcZ0w9T0kjgPn/XJJgAlk5G8JqUr5tu5ouMpWSea X-Received: by 2002:a17:902:3a2:: with SMTP id d31-v6mr164655pld.287.1533680096674; Tue, 07 Aug 2018 15:14:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533680096; cv=none; d=google.com; s=arc-20160816; b=OCWZXLgOAcl4CiEqWChEMlLr5dKz7SFF00xBX6uCZQTtU3POu+XeR5zSVBG/8Qf/R2 9KHaB9SHno4PrQHpA5Lb6xLkdqqa/wDMP47QQA7/ITDR6XMPbeYegIy+oMvd9KJ7iUPv H/BNpzRsIA/ME1AxsUwy18KoOeNn9tTH18H3kmdmG4pjXsIeb9UgXZtnIGFmWc0wPP1Z BGWQIYg6Oz29zaFtnqmrbx3d7c9UM1lJJF9Dvbk683nMJE3PulPNZeX4OD4xTR9j9acx uYb5HJ+uGqfZcfb7ZrmyPETd7KO3A69Nksv3+6MBXA0eblvkBhifDJxbuHyPsOLwys4t PRNQ== 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-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date :arc-authentication-results; bh=rZdQr7fpdVLmPcc5/B0FmO7XZRYJTTHut5B+eBEi7qQ=; b=pwVr10iKxYvwY0gPMl7s26ITsbCxZIHoRhJcgIzHSYOlj1xCWMEQTfEypVTV/c4WAK 9uLJQYBvWi+ueowgdSk0/p6kjwHVyy0fMT5Bsgp+pN8Y9O7ephZ61X32z70M067esGdd ee7XVdZ2gjrZnY4zaaU9wxlwR0eYH6YXjK27Mk5lCt+MKkOdfiLP6VHBt+r3v82kVxBB X+SSxLuKUOv3fYCIKR3qf054HS1qVbFzKf3Y7gIiK7tEwwiMRCEZurZSxBNnvWCtbFKX BTbtuE5EYI1pP+X9syVoLuahnx4vBlCqTTwytD97/6s3FKegR7jO6htykRaO4pyr8N3d TrKw== 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 n24-v6si2564231pgb.665.2018.08.07.15.14.39; Tue, 07 Aug 2018 15:14:56 -0700 (PDT) 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 S1726726AbeHHAaR (ORCPT + 99 others); Tue, 7 Aug 2018 20:30:17 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:50232 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726502AbeHHAaR (ORCPT ); Tue, 7 Aug 2018 20:30:17 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 624F1402345E; Tue, 7 Aug 2018 22:13:47 +0000 (UTC) Received: from redhat.com (unknown [10.20.6.215]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A52AD2023415; Tue, 7 Aug 2018 22:13:46 +0000 (UTC) Date: Tue, 7 Aug 2018 18:13:45 -0400 From: Jerome Glisse To: Oscar Salvador Cc: David Hildenbrand , akpm@linux-foundation.org, mhocko@suse.com, dan.j.williams@intel.com, pasha.tatashin@oracle.com, yasu.isimatu@gmail.com, logang@deltatee.com, dave.jiang@intel.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Oscar Salvador Subject: Re: [RFC PATCH 2/3] mm/memory_hotplug: Create __shrink_pages and move it to offline_pages Message-ID: <20180807221345.GD3301@redhat.com> References: <20180807133757.18352-1-osalvador@techadventures.net> <20180807133757.18352-3-osalvador@techadventures.net> <20180807135221.GA3301@redhat.com> <20180807204834.GA6844@techadventures.net> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20180807204834.GA6844@techadventures.net> User-Agent: Mutt/1.10.0 (2018-05-17) X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Tue, 07 Aug 2018 22:13:47 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Tue, 07 Aug 2018 22:13:47 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'jglisse@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Aug 07, 2018 at 10:48:34PM +0200, Oscar Salvador wrote: > On Tue, Aug 07, 2018 at 04:54:57PM +0200, David Hildenbrand wrote: > > I wonder if we could instead forward from the callers whether we are > > dealing with ZONE_DEVICE memory (is_device ...), at least that seems > > feasible in hmm code. Not having looked at details yet. > > Yes, this looks like the most straightforward way right now. > We would have to pass it from arch_remove_memory to __remove_pages though. > > It is not the most elegant way, but looking at the code of devm_memremap_pages_release > and hmm_devmem_release I cannot really think of anything better. > > In hmm_devmem_release is should be easy because AFAIK (unless I am missing something), hmm always works > with ZONE_DEVICE. > At least hmm_devmem_pages_create() moves the range to ZONE_DEVICE. > > After looking at devm_memremap_pages(), I think it does the same: > > ... > move_pfn_range_to_zone(&NODE_DATA(nid)->node_zones[ZONE_DEVICE], > align_start >> PAGE_SHIFT, > align_size >> PAGE_SHIFT, altmap); > ... > > So I guess it is safe to assume that arch_remove_memory/__remove_pages are called > from those functions while zone being ZONE_DEVICE. > > Is that right, Jerome? Correct, both HMM and devm always deal with ZONE_DEVICE page. So any call to arch_remove_memory/__remove_pages in those context can assume ZONE_DEVICE. > > And since we know for sure that memhotplug-code cannot call it with ZONE_DEVICE, > I think this can be done easily. This might change down road but for now this is correct. They are talks to enumerate device memory through standard platform mechanisms and thus the kernel might see new types of resources down the road and maybe we will want to hotplug them directly from regular hotplug path as ZONE_DEVICE (lot of hypothetical at this point ;)). Cheers, J?r?me