Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp813182ybv; Wed, 5 Feb 2020 15:11:40 -0800 (PST) X-Google-Smtp-Source: APXvYqz07ZvPZhYepN00bJZMETNIBAXfGMSoxUTH9pp4Vzldm6vjFIpxzr/v09hpklo8R659t7lR X-Received: by 2002:a05:6808:b18:: with SMTP id s24mr4717207oij.31.1580944300066; Wed, 05 Feb 2020 15:11:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580944300; cv=none; d=google.com; s=arc-20160816; b=CXPrbdNamOXM9BSHG3NOM3fW73Tx8e+gvQZx3qJfSpxxLKqWCJcHJOjk2g/SMTGyZD w7F8+nqvptvUWQ2alCAbAgqqYe/yaONSGQSAVgutqo3qqfM2lfcKGq09Yv6sK9Aj8EFP 2rI435j0gfi4qsXpTxeFy0H7OI5kWNUCSqaYwIu3N+BEG8pSTYR6ZUFFY5VpegieZUUs 0zxtKlxyZFVRbaLfIL7tRJefzZzvZaattLmZxETfR2eCwdp78QQ6oD3fopU98pDkDxp1 dy1K0ALjY0QvUpDn1canKKFPApeI60AVLFrCH/S1ujL+kQ2Cuqg2k8SozziE8whoBdaW D9Lw== 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:message-id:subject:cc :to:from:date:dkim-signature; bh=29ZTjJBKR+L3bx4WS0f/voo5oahzOM1U9ASFLBeMp4o=; b=xhPcJrhEMqgt9+lVNimbmIUSGeMWLnNnfJIHONorA+EjfQ4FrQ7u+sexvOu6FLy2WH Cile0q6lPIVZY4xv/ajDW4qSgUCtIYFZXRyjwqyy10+jB1T+5lyzZJy+3ZDPWWPnK7OF Crt13lW6F2jmL0JwwsgHaF8q9SK/QLhuUwV8FC1T8RBmaSkMPWF+cgsBI2mJETnnAoAR Qhy0E2f72+KlbX0BtLB35c4NIxfpXUYw5XCl9YPzetlxFXFsLNuoN14GbQiis2chiyMZ 3o0OA+3BMlnrKrr7BvefGazuyb+jStEtU22qCF3nYIfz3GrYjR14NHrOSKqnQHDjxu79 74XA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Pl0KRFDS; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o7si674654otk.185.2020.02.05.15.11.28; Wed, 05 Feb 2020 15:11:40 -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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Pl0KRFDS; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727563AbgBEXIl (ORCPT + 99 others); Wed, 5 Feb 2020 18:08:41 -0500 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:50628 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727307AbgBEXIl (ORCPT ); Wed, 5 Feb 2020 18:08:41 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580944119; 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=29ZTjJBKR+L3bx4WS0f/voo5oahzOM1U9ASFLBeMp4o=; b=Pl0KRFDSx1dq1MP/a+/jSZatwh26VOo2MB3Mxqb/OuWkthSMm1qe06pj/nYQF8FhcrWa5I Jvil4MojRAcYbBa7zapCWp36wClx0FDseA3Z4hFXJULpetvpJi2rrUXfGpzgq9U/qvMZV3 X6UoRSMQNP8OgZQdnJjy08ScYEj5LvQ= 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-127-aW0bz0YAODSSJOPBtHmibQ-1; Wed, 05 Feb 2020 18:08:35 -0500 X-MC-Unique: aW0bz0YAODSSJOPBtHmibQ-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 44D17800D54; Wed, 5 Feb 2020 23:08:33 +0000 (UTC) Received: from localhost (ovpn-12-19.pek2.redhat.com [10.72.12.19]) by smtp.corp.redhat.com (Postfix) with ESMTPS id ABEAA8DC12; Wed, 5 Feb 2020 23:08:29 +0000 (UTC) Date: Thu, 6 Feb 2020 07:08:26 +0800 From: Baoquan He To: Wei Yang Cc: David Hildenbrand , linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org, linux-ia64@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, x86@kernel.org, Andrew Morton , Oscar Salvador , Michal Hocko , Pavel Tatashin , Dan Williams Subject: Re: [PATCH v6 08/10] mm/memory_hotplug: Don't check for "all holes" in shrink_zone_span() Message-ID: <20200205230826.GF8965@MiWiFi-R3L-srv> References: <20191006085646.5768-1-david@redhat.com> <20191006085646.5768-9-david@redhat.com> <20200205095924.GC24162@richard> <20200205144811.GF26758@MiWiFi-R3L-srv> <20200205225633.GA28446@richard> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200205225633.GA28446@richard> User-Agent: Mutt/1.10.1 (2018-07-13) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 02/06/20 at 06:56am, Wei Yang wrote: > On Wed, Feb 05, 2020 at 10:48:11PM +0800, Baoquan He wrote: > >Hi Wei Yang, > > > >On 02/05/20 at 05:59pm, Wei Yang wrote: > >> >diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c > >> >index f294918f7211..8dafa1ba8d9f 100644 > >> >--- a/mm/memory_hotplug.c > >> >+++ b/mm/memory_hotplug.c > >> >@@ -393,6 +393,9 @@ static void shrink_zone_span(struct zone *zone, unsigned long start_pfn, > >> > if (pfn) { > >> > zone->zone_start_pfn = pfn; > >> > zone->spanned_pages = zone_end_pfn - pfn; > >> >+ } else { > >> >+ zone->zone_start_pfn = 0; > >> >+ zone->spanned_pages = 0; > >> > } > >> > } else if (zone_end_pfn == end_pfn) { > >> > /* > >> >@@ -405,34 +408,11 @@ static void shrink_zone_span(struct zone *zone, unsigned long start_pfn, > >> > start_pfn); > >> > if (pfn) > >> > zone->spanned_pages = pfn - zone_start_pfn + 1; > >> >+ else { > >> >+ zone->zone_start_pfn = 0; > >> >+ zone->spanned_pages = 0; > >> >+ } > >> > } > >> > >> If it is me, I would like to take out these two similar logic out. > > > >I also like this style. > >> > >> For example: > >> > >> if () { > >> } else if () { > >> } else { > >> goto out; > >Here the last else is unnecessary, right? > > > > I am afraid not. > > If the range is not the first or last, we would leave pfn not initialized. Ah, you are right. I forgot that one. Then pfn can be assigned the zone_start_pfn as the old code. Then the following logic is the same as the original code, find_smallest_section_pfn()/find_biggest_section_pfn() have done the iteration the old for loop was doing. unsigned long pfn = zone_start_pfn; if () { } else if () { } /* The zone has no valid section */ if (!pfn) { zone->zone_start_pfn = 0; zone->spanned_pages = 0; }