Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp3086901ybv; Sun, 9 Feb 2020 15:07:25 -0800 (PST) X-Google-Smtp-Source: APXvYqxQjCXV236cxBWIB5I+doYtaWZRv/cGAR06pCqUAQQcdkQw51gmQ+BQoLq/rhouc9wkiwPo X-Received: by 2002:aca:db41:: with SMTP id s62mr8757175oig.87.1581289644937; Sun, 09 Feb 2020 15:07:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581289644; cv=none; d=google.com; s=arc-20160816; b=Ywya8s3qtuF9yS6KAtMWF8P7aj9+3aXumSuNHp41XhvRT9c0cGpx3gGyvP5BjnAP9r +QJZ8ADtGzT6NIT/OJrXgHYNtU+eONBlde3bm+UxVrm4df5aPonNJM+juPyeEDQa12gv p8gPusrJ8lxoz8aUnlSfFfrZa1HpN62Gh1KTrjrrfbrPV+e5Xexj+Rm/7E9ylKMWuItD xdC5qdoaZObqJ/BjApLpcdXmHeF5JgYRSiWkE9i1QuTQTQBr9YxeN2Y5GG0DJKKQHIVK FDnF1OodMul2mTHkmnsYFHPjVwqYse6BfGgzzEF/Z1D9of0onHpiut2J41Y6ZVeuqi72 lthA== 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=Dk+MH6+b9SHmHidBrIo3yuVV0ycdgVP+cLAqgy07Xms=; b=dn6NvPeCq0VvePsS4Ix9CaXXv5IHTnEDlFgQwfGZJTg5J6QelPoJ58pq/9FVmYOwc5 NI8sxUUpW3U5gcq+yWuGX+R22AdAQC+Z2221pvbVbw8ANxDCjZO5H3YfxfQFswY+VTYS idISQhm4B5eDS+0D5Jn/5kXj5/ElVaQTfQuUf7ZycQMphKnag1eAAkQ3F2hx8uT3SymD oKaU2Q/LFRw875YEhy+TNlwbVT/E8QBmvV3rePOFcNzfjUX7zu3eLGw1d5WlJjsp6xQx nItvnu8qhUWrZYkUu6+i5xM/VmwmmsMJY+qpJlXuRPHX2Po6+8wsjsJOyyFRn6Rh5ck4 eegA== 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 j25si7326702oij.242.2020.02.09.15.07.12; Sun, 09 Feb 2020 15:07:24 -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 S1727856AbgBIXG6 (ORCPT + 99 others); Sun, 9 Feb 2020 18:06:58 -0500 Received: from mga12.intel.com ([192.55.52.136]:58109 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726798AbgBIXG6 (ORCPT ); Sun, 9 Feb 2020 18:06:58 -0500 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 Feb 2020 15:06:57 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,423,1574150400"; d="scan'208";a="265664145" Received: from richard.sh.intel.com (HELO localhost) ([10.239.159.54]) by fmsmga002.fm.intel.com with ESMTP; 09 Feb 2020 15:06:56 -0800 Date: Mon, 10 Feb 2020 07:07:14 +0800 From: Wei Yang To: Baoquan He Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, akpm@linux-foundation.org, dan.j.williams@intel.com, richardw.yang@linux.intel.com, david@redhat.com Subject: Re: [PATCH 2/7] mm/sparse.c: Introduce a new function clear_subsection_map() Message-ID: <20200209230713.GB7326@richard> Reply-To: Wei Yang References: <20200209104826.3385-1-bhe@redhat.com> <20200209104826.3385-3-bhe@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200209104826.3385-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 Sun, Feb 09, 2020 at 06:48:21PM +0800, Baoquan He wrote: >Wrap the codes clearing subsection map of one memory region in >section_deactivate() into clear_subsection_map(). > Patch 1 and 2 server the same purpose -- to #ifdef the VMEMMAP. I suggest to merge these two. >Signed-off-by: Baoquan He >--- > mm/sparse.c | 44 +++++++++++++++++++++++++++++++++++++------- > 1 file changed, 37 insertions(+), 7 deletions(-) > >diff --git a/mm/sparse.c b/mm/sparse.c >index 9ad741ccbeb6..696f6b9f706e 100644 >--- a/mm/sparse.c >+++ b/mm/sparse.c >@@ -726,14 +726,25 @@ static void free_map_bootmem(struct page *memmap) > } > #endif /* CONFIG_SPARSEMEM_VMEMMAP */ > >-static void section_deactivate(unsigned long pfn, unsigned long nr_pages, >- struct vmem_altmap *altmap) >+/** >+ * clear_subsection_map - Clear subsection map of one memory region >+ * >+ * @pfn - start pfn of the memory range >+ * @nr_pages - number of pfns to add in the region >+ * >+ * This is only intended for hotplug, and clear the related subsection >+ * map inside one section. >+ * >+ * Return: >+ * * -EINVAL - Section already deactived. >+ * * 0 - Subsection map is emptied. >+ * * 1 - Subsection map is not empty. >+ */ >+static int clear_subsection_map(unsigned long pfn, unsigned long nr_pages) > { > DECLARE_BITMAP(map, SUBSECTIONS_PER_SECTION) = { 0 }; > DECLARE_BITMAP(tmp, SUBSECTIONS_PER_SECTION) = { 0 }; > struct mem_section *ms = __pfn_to_section(pfn); >- bool section_is_early = early_section(ms); >- struct page *memmap = NULL; > unsigned long *subsection_map = ms->usage > ? &ms->usage->subsection_map[0] : NULL; > >@@ -744,8 +755,28 @@ static void section_deactivate(unsigned long pfn, unsigned long nr_pages, > if (WARN(!subsection_map || !bitmap_equal(tmp, map, SUBSECTIONS_PER_SECTION), > "section already deactivated (%#lx + %ld)\n", > pfn, nr_pages)) >- return; >+ return -EINVAL; >+ >+ bitmap_xor(subsection_map, map, subsection_map, SUBSECTIONS_PER_SECTION); > >+ if (bitmap_empty(subsection_map, SUBSECTIONS_PER_SECTION)) >+ return 0; >+ >+ return 1; >+} >+ >+static void section_deactivate(unsigned long pfn, unsigned long nr_pages, >+ struct vmem_altmap *altmap) >+{ >+ struct mem_section *ms = __pfn_to_section(pfn); >+ bool section_is_early = early_section(ms); >+ struct page *memmap = NULL; >+ int rc; >+ >+ >+ rc = clear_subsection_map(pfn, nr_pages); >+ if(IS_ERR_VALUE((unsigned long)rc)) >+ return; > /* > * There are 3 cases to handle across two configurations > * (SPARSEMEM_VMEMMAP={y,n}): >@@ -763,8 +794,7 @@ static void section_deactivate(unsigned long pfn, unsigned long nr_pages, > * > * For 2/ and 3/ the SPARSEMEM_VMEMMAP={y,n} cases are unified > */ >- bitmap_xor(subsection_map, map, subsection_map, SUBSECTIONS_PER_SECTION); >- if (bitmap_empty(subsection_map, SUBSECTIONS_PER_SECTION)) { >+ if (!rc) { > unsigned long section_nr = pfn_to_section_nr(pfn); > > /* >-- >2.17.2 -- Wei Yang Help you, Help me