Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3562765imu; Mon, 14 Jan 2019 05:19:56 -0800 (PST) X-Google-Smtp-Source: ALg8bN6Q6pccrCW9tiwYhCLnKSqv6CyrprL709KK96sMVtLj2CoxP1jN2JrNSeNnVmsNrC3TYM1C X-Received: by 2002:a63:9402:: with SMTP id m2mr21995329pge.93.1547471996181; Mon, 14 Jan 2019 05:19:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547471996; cv=none; d=google.com; s=arc-20160816; b=gwAJiDS4Tkrx/9y1dXBgfVWR977DHMZObZ9u/IINS1WcWQQdcRgH/RrGBtLagLMGd5 aLruvqgzRZn7+uSXUMjBjWV3lUVPc989vr5gx1ZE96aIBb55r3for7AHOypd5V9U9rak fYQGOeLzXhqmOy4ZL5QDic1xd8GT4FidLr2D/KNz0Tbn4aWwTKHA3JM7iIIPlSiu5UHZ scsPtwtVXJIE+e32AwLDvK9mDj3P1o9s7BPKeQwEziuha8am0GC9M0nxrLLE3TI6CVjv JpkNSi9WvY9BIsPWqpPrEQgsSP0VXxtKU1L9S491f39tRW+sCh1ronjwIwR8S3q8LGqY eGEA== 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=onSL7YyP7wOdoapkNPz/VWZPG+ZsgZ+IrAp+lXXjPF8=; b=ZfNw/6eCFzgVgO/0JroirGszSVVAbMx5QLoDul2h4cew6VlXEunoO574Fw9mHXCawM ++k8rJLM0X5k62CGEpM8bxqNCbWb/ctZixlyildBWuHz2Zs8/4fqxFvRW7y8QN94hyOk eOFOxK7EgYfOz6/3hi5WfdAHoAh9wmbYudQlBLsAsBJVU1ibz2EhA07MRQq+W/sesW3z 6spwitxGQCWdofxgCEKeTpq/ReEFezCozsleivtBi8//P1VUrOn843US9JZCKF64UQ7K c9jFm4oG30ViXY2xWmI4ebiaLy4IdDyS5Z5ZyU+uUrBnVVmrNacjuhzyAJdpM3O/AQzG tsNQ== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f13si308602pln.368.2019.01.14.05.19.40; Mon, 14 Jan 2019 05:19:56 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726579AbfANNR6 (ORCPT + 99 others); Mon, 14 Jan 2019 08:17:58 -0500 Received: from nat.nue.novell.com ([195.135.221.2]:33129 "EHLO suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726449AbfANNR5 (ORCPT ); Mon, 14 Jan 2019 08:17:57 -0500 Received: by suse.de (Postfix, from userid 1000) id 51C423F27; Mon, 14 Jan 2019 14:17:56 +0100 (CET) Date: Mon, 14 Jan 2019 14:17:56 +0100 From: Oscar Salvador To: Michal Hocko Cc: Oscar Salvador , linux-mm@kvack.org, david@redhat.com, rppt@linux.vnet.ibm.com, akpm@linux-foundation.org, arunks@codeaurora.org, bhe@redhat.com, dan.j.williams@intel.com, Pavel.Tatashin@microsoft.com, Jonathan.Cameron@huawei.com, jglisse@redhat.com, linux-kernel@vger.kernel.org, Alexander Duyck Subject: Re: [RFC PATCH 2/4] mm, memory_hotplug: provide a more generic restrictions for memory hotplug Message-ID: <20190114131742.neivbac3lmsszkzc@d104.suse.de> References: <20181116101222.16581-1-osalvador@suse.com> <20181116101222.16581-3-osalvador@suse.com> <20181123130043.GM8625@dhcp22.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181123130043.GM8625@dhcp22.suse.cz> User-Agent: NeoMutt/20170421 (1.8.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Nov 23, 2018 at 02:00:43PM +0100, Michal Hocko wrote: > One note here as well. In the retrospect the API I have come up > with here is quite hackish. Considering the recent discussion about > special needs ZONE_DEVICE has for both initialization and struct page > allocations with Alexander Duyck I believe we wanted a more abstracted > API with allocator and constructor callbacks. This would allow different > usecases to fine tune their needs without specialcasing deep in the core > hotplug code paths. Hi all, so, now that vacation is gone, I wanted to come back to this. I kind of get what you mean with this more abstacted API, but I am not really sure how we could benefit from it (or maybe I am just short-sighted here). Right now, struct mhp_restrictions would look like: struct mhp_restrictions { unsigned long flags; struct vmem_altmap *altmap; }; where flags tell us whether we want a memblock device and whether we should allocate the memmap array from the hot-added range. And altmap is the altmap we would use for it. Indeed, we could add two callbacks, set_up() and construct() (random naming). When talking about memmap-from-hot_added-range, set_up() could be called to construct the altmap, i.e: <-- struct vmem_altmap __memblk_altmap; __memblk_altmap.base_pfn = phys_start_pfn; __memblk_altmap.alloc = 0; __memblk_altmap.align = 0; __memblk_altmap.free = nr_pages; --> and construct() would be called at the very end of __add_pages(), which basically would be mark_vmemmap_pages(). Now, looking at devm_memremap_pages(ZONE_DEVICE stuff), it does: hotplug_lock(); arch_add_memory add_pages move_pfn_range_to_zone hotplug_lock(); memmap_init_zone_device For the ZONE_DEVICE case, move_pfn_range_to_zone() only initializes the pages containing the memory mapping, while all the remaining pages all initialized later on in memmap_init_zone_device(). Besides initializing pages, memmap_init_zone_device() also sets page->pgmap field. So you could say that memmap_init_zone_device would be the construct part. Anyway, I am currently working on the patch3 of this series to improve it and make it less complex, but it would be great to sort out this API thing. Maybe Alexander or you, can provide some suggestions/ideas here. Thanks Oscar Salvador -- Oscar Salvador SUSE L3