Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp8414451ybi; Thu, 6 Jun 2019 11:56:18 -0700 (PDT) X-Google-Smtp-Source: APXvYqyPwMSY7UKTnNFjsMLjqVx3pyVDMeC+gy+TXRG8LhMuZksIYKPmCqtv5mVr9IuzaFlb6c2j X-Received: by 2002:a63:6445:: with SMTP id y66mr19453pgb.23.1559847378258; Thu, 06 Jun 2019 11:56:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559847378; cv=none; d=google.com; s=arc-20160816; b=yN0nXkQ7t6KGHdd/3yPeqYTkcLLgSkcGRefbAABsCEkedd7lfZOUx/Tm2XBHZTfRdh hMXZZ+kU5pkZso2ZJBWOmwst+7qiaR5IfU2nR7Vh6gFaVdNO4rfwvSgCLy9h+IIvbJhF gC6BIiFvajTVjLHspNGao3P0uQBKSLGfAsuTqWb8OY/OfmLDMzk+1ZP5/kqgUhV5Cmlv ojousYRxKwCGhCVGg64KzILQ2OfK1M8d6NrWMno6PDUQ31n68xKZzWuMM6an1kUZy0Uv 42VUwRw2cHC9Bw26w5AUa0D9vHU8xP1j9JwecPYW/7BU4+8esU233uUtdWmftW+jzLJR cf7A== 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=ydmW5jso3JZuPsN2nZdjLKJumvT7JMEr3UYP5iIq71c=; b=kXDTwX8QT4GagD59x5fTUd1am45Hmq2sPZQ6EmWhzGViRLnvx26aPQsLnrx2OXBASw lTyvTpJLaF0ckdINA5bLMezMcCxobEgdb5+XhLbtRA2KG1Es5rXVKjdxPbqzQxsJ7qaB f8anNXwMNk7wu/y7b2JUfw7F9vtRNOrTx83HzOuciN10Q4DHsgtrKXCtVe3HmvySNoFi uDSlHn9EDEPZ6UHL1cc8k2oS27UdmbQfo1d1ifobRa4v/oq3is6ikk+eU6rxbvdT9mlN qLqUR8ZsWqJS+ZRPUXwV+/KVTauPIvW8xGQs+g9OQuj4m46b2XhVZWjEnjf49x01Wb0q p/+A== 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 c9si2613822pgp.39.2019.06.06.11.56.02; Thu, 06 Jun 2019 11:56:18 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730095AbfFFRVO (ORCPT + 99 others); Thu, 6 Jun 2019 13:21:14 -0400 Received: from mx2.suse.de ([195.135.220.15]:60334 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725782AbfFFRVO (ORCPT ); Thu, 6 Jun 2019 13:21:14 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id ADFCEABD0; Thu, 6 Jun 2019 17:21:12 +0000 (UTC) Date: Thu, 6 Jun 2019 19:21:10 +0200 From: Oscar Salvador To: Dan Williams Cc: akpm@linux-foundation.org, Michal Hocko , Vlastimil Babka , Logan Gunthorpe , Pavel Tatashin , linux-mm@kvack.org, linux-nvdimm@lists.01.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v9 07/12] mm/sparsemem: Prepare for sub-section ranges Message-ID: <20190606172110.GC31194@linux> References: <155977186863.2443951.9036044808311959913.stgit@dwillia2-desk3.amr.corp.intel.com> <155977191770.2443951.1506588644989416699.stgit@dwillia2-desk3.amr.corp.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <155977191770.2443951.1506588644989416699.stgit@dwillia2-desk3.amr.corp.intel.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jun 05, 2019 at 02:58:37PM -0700, Dan Williams wrote: > Prepare the memory hot-{add,remove} paths for handling sub-section > ranges by plumbing the starting page frame and number of pages being > handled through arch_{add,remove}_memory() to > sparse_{add,remove}_one_section(). > > This is simply plumbing, small cleanups, and some identifier renames. No > intended functional changes. > > Cc: Michal Hocko > Cc: Vlastimil Babka > Cc: Logan Gunthorpe > Cc: Oscar Salvador > Reviewed-by: Pavel Tatashin > Signed-off-by: Dan Williams > --- > include/linux/memory_hotplug.h | 5 +- > mm/memory_hotplug.c | 114 +++++++++++++++++++++++++--------------- > mm/sparse.c | 15 ++--- > 3 files changed, 81 insertions(+), 53 deletions(-) > > diff --git a/include/linux/memory_hotplug.h b/include/linux/memory_hotplug.h > index 79e0add6a597..3ab0282b4fe5 100644 > --- a/include/linux/memory_hotplug.h > +++ b/include/linux/memory_hotplug.h > @@ -348,9 +348,10 @@ extern int add_memory_resource(int nid, struct resource *resource); > extern void move_pfn_range_to_zone(struct zone *zone, unsigned long start_pfn, > unsigned long nr_pages, struct vmem_altmap *altmap); > extern bool is_memblock_offlined(struct memory_block *mem); > -extern int sparse_add_one_section(int nid, unsigned long start_pfn, > - struct vmem_altmap *altmap); > +extern int sparse_add_section(int nid, unsigned long pfn, > + unsigned long nr_pages, struct vmem_altmap *altmap); > extern void sparse_remove_one_section(struct mem_section *ms, > + unsigned long pfn, unsigned long nr_pages, > unsigned long map_offset, struct vmem_altmap *altmap); > extern struct page *sparse_decode_mem_map(unsigned long coded_mem_map, > unsigned long pnum); > diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c > index 4b882c57781a..399bf78bccc5 100644 > --- a/mm/memory_hotplug.c > +++ b/mm/memory_hotplug.c > @@ -252,51 +252,84 @@ void __init register_page_bootmem_info_node(struct pglist_data *pgdat) > } > #endif /* CONFIG_HAVE_BOOTMEM_INFO_NODE */ > > -static int __meminit __add_section(int nid, unsigned long phys_start_pfn, > - struct vmem_altmap *altmap) > +static int __meminit __add_section(int nid, unsigned long pfn, > + unsigned long nr_pages, struct vmem_altmap *altmap) > { > int ret; > > - if (pfn_valid(phys_start_pfn)) > + if (pfn_valid(pfn)) > return -EEXIST; > > - ret = sparse_add_one_section(nid, phys_start_pfn, altmap); > + ret = sparse_add_section(nid, pfn, nr_pages, altmap); > return ret < 0 ? ret : 0; > } > > +static int check_pfn_span(unsigned long pfn, unsigned long nr_pages, > + const char *reason) > +{ > + /* > + * Disallow all operations smaller than a sub-section and only > + * allow operations smaller than a section for > + * SPARSEMEM_VMEMMAP. Note that check_hotplug_memory_range() > + * enforces a larger memory_block_size_bytes() granularity for > + * memory that will be marked online, so this check should only > + * fire for direct arch_{add,remove}_memory() users outside of > + * add_memory_resource(). > + */ > + unsigned long min_align; > + > + if (IS_ENABLED(CONFIG_SPARSEMEM_VMEMMAP)) > + min_align = PAGES_PER_SUBSECTION; > + else > + min_align = PAGES_PER_SECTION; > + if (!IS_ALIGNED(pfn, min_align) > + || !IS_ALIGNED(nr_pages, min_align)) { > + WARN(1, "Misaligned __%s_pages start: %#lx end: #%lx\n", > + reason, pfn, pfn + nr_pages - 1); > + return -EINVAL; > + } > + return 0; > +} This caught my eye. Back in patch#4 "Convert kmalloc_section_memmap() to populate_section_memmap()", you placed a mis-usage check for !CONFIG_SPARSEMEM_VMEMMAP in populate_section_memmap(). populate_section_memmap() gets called from sparse_add_one_section(), which means that we should have passed this check, otherwise we cannot go further and call __add_section(). So, unless I am missing something it seems to me that the check from patch#4 could go? And I think the same applies to depopulate_section_memmap()? Besides that, it looks good to me: Reviewed-by: Oscar Salvador -- Oscar Salvador SUSE L3