From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.4 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A2ED2C10F27 for ; Mon, 9 Mar 2020 13:32:30 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 62CA020727 for ; Mon, 9 Mar 2020 13:32:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="RNVeqVnz" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 62CA020727 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id EBC286B0003; Mon, 9 Mar 2020 09:32:29 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E45036B0006; Mon, 9 Mar 2020 09:32:29 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D0D1D6B0007; Mon, 9 Mar 2020 09:32:29 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0071.hostedemail.com [216.40.44.71]) by kanga.kvack.org (Postfix) with ESMTP id B3F9B6B0003 for ; Mon, 9 Mar 2020 09:32:29 -0400 (EDT) Received: from smtpin07.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 5359C181AEF09 for ; Mon, 9 Mar 2020 13:32:29 +0000 (UTC) X-FDA: 76575913218.07.rest04_6cfd6a90b8143 X-HE-Tag: rest04_6cfd6a90b8143 X-Filterd-Recvd-Size: 5682 Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) by imf14.hostedemail.com (Postfix) with ESMTP for ; Mon, 9 Mar 2020 13:32:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583760748; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=+lf2F/Ud1PCpWWqigKJxrL+KrTYso3PbvC0kuJMa80U=; b=RNVeqVnz5vwCZeE+cEWl//VN0fsvvDj2XZPyQeVbP1xieJb5aGEN2Pk6ibDYwebzyI6MIU 4+6+bdQQ9XlLjfViislqm/KoHD8zZEp16RbQcA9dAWt0rUyiGw3CxgwQAKb+k3VXWLg+Uh y1uruVPvtjAYkqbU9Ab1vVYN0LGNEyY= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-299-npKZDscDPJu8v1gCTt2ZQw-1; Mon, 09 Mar 2020 09:32:26 -0400 X-MC-Unique: npKZDscDPJu8v1gCTt2ZQw-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0D96D184C808; Mon, 9 Mar 2020 13:32:25 +0000 (UTC) Received: from localhost (ovpn-12-179.pek2.redhat.com [10.72.12.179]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 49427272AF; Mon, 9 Mar 2020 13:32:21 +0000 (UTC) Date: Mon, 9 Mar 2020 21:32:18 +0800 From: Baoquan He To: David Hildenbrand Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, akpm@linux-foundation.org, mhocko@suse.com, richardw.yang@linux.intel.com, dan.j.williams@intel.com, osalvador@suse.de, rppt@linux.ibm.com Subject: Re: [PATCH v3 3/7] mm/sparse.c: introduce a new function clear_subsection_map() Message-ID: <20200309133218.GD27711@MiWiFi-R3L-srv> References: <20200307084229.28251-1-bhe@redhat.com> <20200307084229.28251-4-bhe@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On 03/09/20 at 09:59am, David Hildenbrand wrote: > On 07.03.20 09:42, Baoquan He wrote: > > Factor out the code which clear subsection map of one memory region from > > section_deactivate() into clear_subsection_map(). > > > > Signed-off-by: Baoquan He > > --- > > mm/sparse.c | 31 ++++++++++++++++++++++++------- > > 1 file changed, 24 insertions(+), 7 deletions(-) > > > > diff --git a/mm/sparse.c b/mm/sparse.c > > index e37c0abcdc89..d9dcd58d5c1d 100644 > > --- a/mm/sparse.c > > +++ b/mm/sparse.c > > @@ -726,15 +726,11 @@ 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) > > +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; > > - bool empty = false; > > unsigned long *subsection_map = ms->usage > > ? &ms->usage->subsection_map[0] : NULL; > > > > @@ -745,8 +741,31 @@ 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 -EINVAL; > > + > > + bitmap_xor(subsection_map, map, subsection_map, SUBSECTIONS_PER_SECTION); > > + > > Nit: I'd drop this line. It's fine to me. I usually keep one line for the returning. I will remove it when update. > > > + return 0; > > +} > > + > > +static bool is_subsection_map_empty(struct mem_section *ms) > > +{ > > + return bitmap_empty(&ms->usage->subsection_map[0], > > + SUBSECTIONS_PER_SECTION); > > +} > > + > > +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; > > + bool empty = false; > > Nit: No need to initialize empty. This is inherited from patch 1. > > > + > > + if (clear_subsection_map(pfn, nr_pages)) > > return; > > > > Nit: I'd drop this empty line. > > > + empty = is_subsection_map_empty(ms); > > /* > > * There are 3 cases to handle across two configurations > > * (SPARSEMEM_VMEMMAP={y,n}): > > @@ -764,8 +783,6 @@ 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); > > - empty = bitmap_empty(subsection_map, SUBSECTIONS_PER_SECTION); > > I do wonder why you moved this up the comment? Since this empty will cover two places of handling, so moved it up, seems this is what I was thinking. Can move it back here. > > > if (empty) { > > unsigned long section_nr = pfn_to_section_nr(pfn); > > > > > > Reviewed-by: David Hildenbrand > > -- > Thanks, > > David / dhildenb