Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp8435167ybi; Thu, 6 Jun 2019 12:14:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqzbWDOhEuDKYlO4l8dMt4BYIqdTkAjijkdLeVoOk4inSg/scyyoTJctfvqErgCTHJVUI2LP X-Received: by 2002:a62:1707:: with SMTP id 7mr39363549pfx.26.1559848498116; Thu, 06 Jun 2019 12:14:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559848498; cv=none; d=google.com; s=arc-20160816; b=ws1KTKq3QDLAsj2idhmSMy1YbZ/kSepDbNivHOKMgK2GCVXLT6U8FiAFkzW4Wyms3+ EezMMwiqrwXEIo5LDYWdSSJGy1N1JmBGBJznzzJ3BXQZTfVnToJ/YFIqv3m/cWizqTV+ FUTrCELgv1m0WO3n1soKt9zi7PGm6HrDfndNSJtHFpyXHbXoA954F+soA2JyRyb3jbqE xQM7dhReyRYq+/jHE+z6kiY8bs98orj4TPG8Ioe7vaRE+yB7bbZCTOmN5u2w+48Ir9UV lXRpaLve9WzIez8HrZkfu4FLMZTWoFzFZemyD4CMVPlKmdYlfizMZM0KJGS9vWjQ6V93 JsTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=IFTusPVhpfiYDlM0cF7USTGMzoOymuyGD1PoRmf3vY4=; b=VCIkoPJwyMHV80V5VCVeNOfefLQj/2QvQ4prp22ipzBS5IUQmllb3PpIoxh8JsJ86q vgfgogjL1qLTJSvCVrNOvqrp0UHUtQr3jOcP2GEUr2og02SlWIOj83yoF+21Kne5mEVi sh8SA5Bw3xgTgqjs0R52CyNBMpjmQtG4uqShQrG1C4qPp2teKOymZcAjjU/P/s2fRA+T NdOtOvSy1uwKoR6JaW6UnTCwWHu2Tz2DR5kpSy8N0E7EbW3GFkEbsqFCpqr05EAAaxqX URylERsm2fmnomErwwXJUpg+5vw0ApY+fizFPNJQvS8kMndfsufsUNkjnjLbzk/NV14E AX+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel-com.20150623.gappssmtp.com header.s=20150623 header.b=Gz7G1JiJ; 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=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w185si2691596pfb.170.2019.06.06.12.14.41; Thu, 06 Jun 2019 12:14:58 -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; dkim=pass header.i=@intel-com.20150623.gappssmtp.com header.s=20150623 header.b=Gz7G1JiJ; 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730452AbfFFSQo (ORCPT + 99 others); Thu, 6 Jun 2019 14:16:44 -0400 Received: from mail-ot1-f65.google.com ([209.85.210.65]:44628 "EHLO mail-ot1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727559AbfFFSQo (ORCPT ); Thu, 6 Jun 2019 14:16:44 -0400 Received: by mail-ot1-f65.google.com with SMTP id b7so2831948otl.11 for ; Thu, 06 Jun 2019 11:16:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=IFTusPVhpfiYDlM0cF7USTGMzoOymuyGD1PoRmf3vY4=; b=Gz7G1JiJnLX/6xII/oyzd8Mk94n6nVLGrgbdbhDqr4Dis4ST4qcabAQL+i/iKj5gyq ErzL+a3p6d1VkNlfwAuwWnGsTu2M/ET/by+e8dWL05Gt4vg3jMlOAufnxyapEzib6TlN hLONYh8TIEvqZ+KQGcAQXHcbapftgGvXItMjTZMux1pD5Ov1cFWfZ63uGBq4Tyd4+ZmC HQPYUSTgJUBHOcDcyazfWZv0D5dVEFX5zu5JI8Z1d4Ho3rsHvETHnmo5LcaG4TYaaIkq xFz16zm3QydA/VBCMGuYmQZkMstuNeFMgfwP+tPC8uUdiMD+iSJdw1LZm/ClHFq0HxDe fNgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=IFTusPVhpfiYDlM0cF7USTGMzoOymuyGD1PoRmf3vY4=; b=FcIIbaq/zObxVnmVcY9n8i7rDCWueMSYHPWpVk4dYRhz17PaSA0rLaRz5TR1n7qaRn fwiYhdmERwyaniUa57HKUmphStCpVkaUjybcoLbiXotPj57pZ7qoh7s9hUAFf6LeEJfJ LpeB3NaQrPm6ag+Q0JEUr79+RErLrb0+glmIdEbA2Q/2DaxM4UVtmSy6kZm9zb6ikYSQ ciDRhEMsCJ54nmQMYoskNVQB9s7jZqqSyiY1rehdx8VHMhyQNiznkP16ndWPt/ntY+ye 7+gX036hn+sSiejVf2kv8KmAN3vVCL11dwXoWC4iV4tr8t3HblCr8z9u0xpQAd15gPZE asew== X-Gm-Message-State: APjAAAUvzfJckwMRkgCo/QZuAMMGfS9Jv0MfEUPR6Rha0RnwS1/aSRmM smyuieK1NR5pLiN1fh7NJsfOmx5o9mO4Tc3bO5gr+g== X-Received: by 2002:a9d:6e96:: with SMTP id a22mr15628006otr.207.1559845003058; Thu, 06 Jun 2019 11:16:43 -0700 (PDT) MIME-Version: 1.0 References: <155977186863.2443951.9036044808311959913.stgit@dwillia2-desk3.amr.corp.intel.com> <155977191770.2443951.1506588644989416699.stgit@dwillia2-desk3.amr.corp.intel.com> <20190606172110.GC31194@linux> In-Reply-To: <20190606172110.GC31194@linux> From: Dan Williams Date: Thu, 6 Jun 2019 11:16:31 -0700 Message-ID: Subject: Re: [PATCH v9 07/12] mm/sparsemem: Prepare for sub-section ranges To: Oscar Salvador Cc: Andrew Morton , Michal Hocko , Vlastimil Babka , Logan Gunthorpe , Pavel Tatashin , Linux MM , linux-nvdimm , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jun 6, 2019 at 10:21 AM Oscar Salvador wrote: > > 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()? Yes, good catch, I can kill those extra checks in favor of this one. > Besides that, it looks good to me: Thanks Oscar! > > Reviewed-by: Oscar Salvador > > -- > Oscar Salvador > SUSE L3