Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp314530ybv; Wed, 19 Feb 2020 22:15:32 -0800 (PST) X-Google-Smtp-Source: APXvYqxJvIrbNncPDmM5fnfrq09dxRugHClc+xjga1yv0HRmzh6LsyThth6U9roYThWZevb3NawY X-Received: by 2002:a9d:4c81:: with SMTP id m1mr22295531otf.5.1582179332120; Wed, 19 Feb 2020 22:15:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582179332; cv=none; d=google.com; s=arc-20160816; b=wHRnmar7d9b4VUIX8+EjhLpJ3n8gy1YqgHX6p7nsDdBBL7OgneA6q6ZkgsKdEIRvw5 mtix5qMPzWnLnHfNy2PBH91Q7NZcl3Dkw0zcQc+o6VDE0Ks5q0ZaylgYHnt2HzhgLs15 ZLlrHyWs1ivOws1I7aoiWhoo9S8lhJrgoSk5zOfGPMBYEW0qK1Qfa0nmrxM82WqyaIuf gucRg6PKRdM3Pce1ebpmZ/lKlRlR2KtxcpyDidUH2oi7mX32mQAPXIDPEyMYKW+sCUJX 1tPcVNROwbpbwN8fvZmkFsTEFyUoYmRM+rGnIELrLHhyYz0FIqe8SNe5Lkv/LlcM9oB1 bNfA== 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:reply-to:message-id :subject:cc:to:from:date; bh=FcdAeXc4TaMdcdDt7LKYX7EBjunkdIKnMg9OI5pCaLA=; b=SH7Lu4Mf2fceQcvLRZId62YtEElCsP9Ddp/DnjBi2Z4uwkC7w8Z1qRzBrz2HmS7Jnp UD7GMcV65PWzXJZJRQKfGWWDSmZu8Ce0IfZxByH2ZlXXwyzn3nrlQLO/Z51oSKzpF0NH N0rwcSX81sEUCYQf1LLp8lHm3xMjX/fo8UqqIdwTHYvAv6BP7Qs7/EdwAQ/Xx1D34y8Z bcjFN4PuJ622jQ7uhdG/pdfRHRb6W+fdV73frHsiY4TCrrcTZ8gJs1hfZpEKjg8FFy0F +2S3j/6rersIFlDI0gEl/gnb8bSIX+KFRJ/KJJp8tUSkWlwk/R1GewZYOfgeF6uLTUwZ sG0A== 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=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s128si9975784oig.204.2020.02.19.22.15.20; Wed, 19 Feb 2020 22:15:32 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726779AbgBTGOL (ORCPT + 99 others); Thu, 20 Feb 2020 01:14:11 -0500 Received: from mga09.intel.com ([134.134.136.24]:51786 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726150AbgBTGOL (ORCPT ); Thu, 20 Feb 2020 01:14:11 -0500 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Feb 2020 22:14:10 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,463,1574150400"; d="scan'208";a="436484554" Received: from richard.sh.intel.com (HELO localhost) ([10.239.159.54]) by fmsmga006.fm.intel.com with ESMTP; 19 Feb 2020 22:14:08 -0800 Date: Thu, 20 Feb 2020 14:14:27 +0800 From: Wei Yang To: Baoquan He Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, akpm@linux-foundation.org, richardw.yang@linux.intel.com, david@redhat.com, osalvador@suse.de, dan.j.williams@intel.com, mhocko@suse.com, rppt@linux.ibm.com, robin.murphy@arm.com Subject: Re: [PATCH v2 2/7] mm/sparse.c: introduce new function fill_subsection_map() Message-ID: <20200220061427.GB32521@richard> Reply-To: Wei Yang References: <20200220043316.19668-1-bhe@redhat.com> <20200220043316.19668-3-bhe@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200220043316.19668-3-bhe@redhat.com> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Feb 20, 2020 at 12:33:11PM +0800, Baoquan He wrote: >Wrap the codes filling subsection map from section_activate() into >fill_subsection_map(), this makes section_activate() cleaner and >easier to follow. > >Signed-off-by: Baoquan He Reviewed-by: Wei Yang >--- > mm/sparse.c | 45 ++++++++++++++++++++++++++++++++++----------- > 1 file changed, 34 insertions(+), 11 deletions(-) > >diff --git a/mm/sparse.c b/mm/sparse.c >index b8e52c8fed7f..977b47acd38d 100644 >--- a/mm/sparse.c >+++ b/mm/sparse.c >@@ -790,24 +790,28 @@ static void section_deactivate(unsigned long pfn, unsigned long nr_pages, > ms->section_mem_map = (unsigned long)NULL; > } > >-static struct page * __meminit section_activate(int nid, unsigned long pfn, >- unsigned long nr_pages, struct vmem_altmap *altmap) >+/** >+ * fill_subsection_map - fill subsection map of a memory region >+ * @pfn - start pfn of the memory range >+ * @nr_pages - number of pfns to add in the region >+ * >+ * This fills the related subsection map inside one section, and only >+ * intended for hotplug. >+ * >+ * Return: >+ * * 0 - On success. >+ * * -EINVAL - Invalid memory region. >+ * * -EEXIST - Subsection map has been set. >+ */ >+static int fill_subsection_map(unsigned long pfn, unsigned long nr_pages) > { >- DECLARE_BITMAP(map, SUBSECTIONS_PER_SECTION) = { 0 }; > struct mem_section *ms = __pfn_to_section(pfn); >- struct mem_section_usage *usage = NULL; >+ DECLARE_BITMAP(map, SUBSECTIONS_PER_SECTION) = { 0 }; > unsigned long *subsection_map; >- struct page *memmap; > int rc = 0; > > subsection_mask_set(map, pfn, nr_pages); > >- if (!ms->usage) { >- usage = kzalloc(mem_section_usage_size(), GFP_KERNEL); >- if (!usage) >- return ERR_PTR(-ENOMEM); >- ms->usage = usage; >- } > subsection_map = &ms->usage->subsection_map[0]; > > if (bitmap_empty(map, SUBSECTIONS_PER_SECTION)) >@@ -818,6 +822,25 @@ static struct page * __meminit section_activate(int nid, unsigned long pfn, > bitmap_or(subsection_map, map, subsection_map, > SUBSECTIONS_PER_SECTION); > >+ return rc; >+} >+ >+static struct page * __meminit section_activate(int nid, unsigned long pfn, >+ unsigned long nr_pages, struct vmem_altmap *altmap) >+{ >+ struct mem_section *ms = __pfn_to_section(pfn); >+ struct mem_section_usage *usage = NULL; >+ struct page *memmap; >+ int rc = 0; >+ >+ if (!ms->usage) { >+ usage = kzalloc(mem_section_usage_size(), GFP_KERNEL); >+ if (!usage) >+ return ERR_PTR(-ENOMEM); >+ ms->usage = usage; >+ } >+ >+ rc = fill_subsection_map(pfn, nr_pages); > if (rc) { > if (usage) > ms->usage = NULL; >-- >2.17.2 -- Wei Yang Help you, Help me