Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp314583ybv; Wed, 19 Feb 2020 22:15:35 -0800 (PST) X-Google-Smtp-Source: APXvYqyoNyrcNt5v2rZLbjRNVWf0Ksbizyy8Y6/7WOfBh4vV5mQCR0T1Lor2B12b0D8J82RKYQPp X-Received: by 2002:a9d:7586:: with SMTP id s6mr21938643otk.342.1582179335313; Wed, 19 Feb 2020 22:15:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582179335; cv=none; d=google.com; s=arc-20160816; b=eGxgJg6/Nvy8cUqJAaED/l5DcDZ2DYGLsb1vC46pJzfdrFGqqIkgLrt33ZnzHc1yuz /ZLptEEbg0+Eo6rNR27RJkXHFuuwWYUDpKKR3RWmTvh8fJ6XnJtbsZ3kwauAL7xR8kao J2PCbpWrBzmJaIbVeGwkmLz/WQDJiQubrHWwlBCl03/kxoGyk90NSK7EcoFWpw8didv2 fIBYut+vBkqfP94FXMbC9thVJFmEYByWo4a+T7JBQ9KUuCOh5M2KGWRIf+KVgPhywUJF fvNoqNdm6GDHxYfUuVizP2TMZQoDMv6sriqOMu5EL0C0G209hUHcD2aE76eLxFxGKIAu wxZA== 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=4SDGhXSYnz2IJIWlma3VGWI1RA+63GX9mkpdmErFubg=; b=EDz2scevzIT9VtF4ccpCKfQtCvvyTPG2OFZV3LEGdOuj1AZsBv+63lwLNCQozfFMwb mQUfzPxH13Cc5XjDkJoVpnwyYbrkeKIcWa+YCALMPxj/5PQdbIL7EAOraxu0QqdFV9TW 5ge5CLMtwq/yJPz9laozEUfNsFiXPp9GsIkaX0pf3DkQU3do2CNvmQOn0KCYYilFHV9J gsSk6c7L8s9WzLFzOD+GwxmlyG5ti/BxOVuFKmoxHteZ7YOipg+4YZZIXF5eDNbWE7EH Ir6M56L2cOO9LVX6HLr76A8+TxX5USJE10GKmkhlJJVO/gNdd27pGrkMRrdrwmytKMMX N+tA== 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 v9si10161297oie.22.2020.02.19.22.15.23; Wed, 19 Feb 2020 22:15:35 -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 S1726733AbgBTGPS (ORCPT + 99 others); Thu, 20 Feb 2020 01:15:18 -0500 Received: from mga02.intel.com ([134.134.136.20]:51493 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725962AbgBTGPS (ORCPT ); Thu, 20 Feb 2020 01:15:18 -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 orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Feb 2020 22:15:17 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,463,1574150400"; d="scan'208";a="436484740" Received: from richard.sh.intel.com (HELO localhost) ([10.239.159.54]) by fmsmga006.fm.intel.com with ESMTP; 19 Feb 2020 22:15:14 -0800 Date: Thu, 20 Feb 2020 14:15:34 +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 3/7] mm/sparse.c: introduce a new function clear_subsection_map() Message-ID: <20200220061534.GC32521@richard> Reply-To: Wei Yang References: <20200220043316.19668-1-bhe@redhat.com> <20200220043316.19668-4-bhe@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200220043316.19668-4-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:12PM +0800, Baoquan He wrote: >Wrap the codes which clear subsection map of one memory region from >section_deactivate() into clear_subsection_map(). > >Signed-off-by: Baoquan He Reviewed-by: Wei Yang >--- > mm/sparse.c | 46 ++++++++++++++++++++++++++++++++++++++-------- > 1 file changed, 38 insertions(+), 8 deletions(-) > >diff --git a/mm/sparse.c b/mm/sparse.c >index 977b47acd38d..df857ee9330c 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); > > /* >@@ -786,7 +816,7 @@ static void section_deactivate(unsigned long pfn, unsigned long nr_pages, > else > depopulate_section_memmap(pfn, nr_pages, altmap); > >- if (bitmap_empty(subsection_map, SUBSECTIONS_PER_SECTION)) >+ if (!rc) > ms->section_mem_map = (unsigned long)NULL; > } > >-- >2.17.2 -- Wei Yang Help you, Help me