Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752235AbdFOIYP (ORCPT ); Thu, 15 Jun 2017 04:24:15 -0400 Received: from mx2.suse.de ([195.135.220.15]:45599 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750774AbdFOIYO (ORCPT ); Thu, 15 Jun 2017 04:24:14 -0400 Date: Thu, 15 Jun 2017 10:24:10 +0200 From: Michal Hocko To: Wei Yang Cc: Andrew Morton , linux-mm@kvack.org, Mel Gorman , Vlastimil Babka , Andrea Arcangeli , Reza Arbab , Yasuaki Ishimatsu , qiuxishi@huawei.com, Kani Toshimitsu , slaoub@gmail.com, Joonsoo Kim , Andi Kleen , David Rientjes , Daniel Kiper , Igor Mammedov , Vitaly Kuznetsov , LKML Subject: Re: [PATCH] mm, memory_hotplug: support movable_node for hotplugable nodes Message-ID: <20170615082410.GE1486@dhcp22.suse.cz> References: <20170608122318.31598-1-mhocko@kernel.org> <20170615032927.GA17971@WeideMacBook-Pro.local> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170615032927.GA17971@WeideMacBook-Pro.local> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2566 Lines: 70 On Thu 15-06-17 11:29:27, Wei Yang wrote: [...] > >+static inline bool movable_pfn_range(int nid, struct zone *default_zone, > >+ unsigned long start_pfn, unsigned long nr_pages) > >+{ > >+ if (!allow_online_pfn_range(nid, start_pfn, nr_pages, > >+ MMOP_ONLINE_KERNEL)) > >+ return true; > >+ > >+ if (!movable_node_is_enabled()) > >+ return false; > >+ > >+ return !zone_intersects(default_zone, start_pfn, nr_pages); > >+} > >+ > > To be honest, I don't understand this clearly. > > move_pfn_range() will choose and move the range to a zone based on the > online_type, where we have two cases: > 1. ONLINE_MOVABLE -> ZONE_MOVABLE will be chosen > 2. ONLINE_KEEP -> ZONE_NORMAL is the default while ZONE_MOVABLE will be > chosen in case movable_pfn_range() returns true. > > There are three conditions in movable_pfn_range(): > 1. Not allowed in kernel_zone, returns true > 2. Movable_node not enabled, return false > 3. Range [start_pfn, start_pfn + nr_pages) doesn't intersect with > default_zone, return true > > The first one is inherited from original code, so lets look at the other two. > > Number 3 is easy to understand, if the hot-added range is already part of > ZONE_NORMAL, use it. > > Number 2 makes me confused. If movable_node is not enabled, ZONE_NORMAL will > be chosen. If movable_node is enabled, it still depends on other two > condition. So how a memory_block is onlined to ZONE_MOVABLE because > movable_node is enabled? This is simple. If the movable_node is set then ONLINE_KEEP defaults to the movable zone unless the range is already covered by a kernel zone (read Normal zone most of the time). > What I see is you would forbid a memory_block to be > onlined to ZONE_MOVABLE when movable_node is not enabled. Please note that this is ONLINE_KEEP not ONLINE_MOVABLE and as such the movable zone is used only if we are withing the movable zone range already (test 1). > Instead of you would > online a memory_block to ZONE_MOVABLE when movable_node is enabled, which is > implied in your change log. > > BTW, would you mind giving me these two information? > 1. Which branch your code is based on? I have cloned your > git(//git.kernel.org/pub/scm/linux/kernel/git/mhocko/mm.git), while still see > some difference. yes this is based on the mmotm tree (use since-4.11 or auto-latest branch) > 2. Any example or test case I could try your patch and see the difference? It > would be better if it could run in qemu+kvm. See http://lkml.kernel.org/r/20170421120512.23960-1-mhocko@kernel.org -- Michal Hocko SUSE Labs