Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp100276ybv; Wed, 5 Feb 2020 02:00:48 -0800 (PST) X-Google-Smtp-Source: APXvYqyncq5ot4rL4KivkkIZw7OfZ9K9LK1QQuYBRrZRvN9ahWARxnqAK/BoWPLtm6FptR2Y89uv X-Received: by 2002:a05:6830:1251:: with SMTP id s17mr25235855otp.108.1580896848284; Wed, 05 Feb 2020 02:00:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580896848; cv=none; d=google.com; s=arc-20160816; b=zr5WmF30BV+eSnN0PDDSjGGfyuALl800qZtP7IyAa+7w1MFaw816PBv8H19z3NPHly FZhCOWSL1CE+BxcesNORawEyCf7//fCuWPrCBbcTrZIOqrbDef3VY6FBYVMEDbdm7O0L WKjVBIqxansvTCTKUGSipobQcGatkBt+GhosZF/gsdW/ayiauK7T9DRvDbO3JnUPIbVG mFgb1jBkusZ+oFkfbqmqVJ4oFDfsHMagCXp//D7fqubdfcSWw8qetDAfoFalN7vXe06k zg964aJNhMyBk5ztKu1+3s5TXUZy5vCaLABQ+ltPyYfpIOdvaP5Myz/ewMJ5nvz1Mrya 2ecw== 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=T47dOYuTvqh/UDNCrwWh5c1NUPLINLwhHRm4vIxOXPU=; b=eBfXwIpnpQqxlYAEqwJTjSwHzu1hPWnTwpzlm2t3M1+AQDyNbJya3lTLEVOdY2SUlI U0J1A1m+CrY64EkJXUImb025E8XznFPH2aR9p7hfcym68AEuKgO7wq3vge6tYkD6w8Pd xUcUr1xMwswOLVO8Lv2+1kfOECyAcDIxRizipgvlTk6omc5QRZ0oguo+vHSuFS7WpS6d beuo2lKf81E+m9jsRBz3lZcJWHZAItRtbJWCWbfmK6XGa6sFTfXr0PSKJW1WFwVsObXM S29EdjdTBYKqhVVq9Tf8LUu1x013GNrmvEXA/YJSSZLkZbGH1ApHnY9tQjlxOGzaZ+rv m38A== 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 k2si11197479oij.97.2020.02.05.02.00.09; Wed, 05 Feb 2020 02:00:48 -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 S1727381AbgBEJ7M (ORCPT + 99 others); Wed, 5 Feb 2020 04:59:12 -0500 Received: from mga02.intel.com ([134.134.136.20]:6920 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727068AbgBEJ7L (ORCPT ); Wed, 5 Feb 2020 04:59:11 -0500 X-Amp-Result: UNSCANNABLE X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 Feb 2020 01:59:10 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,405,1574150400"; d="scan'208";a="343395725" Received: from richard.sh.intel.com (HELO localhost) ([10.239.159.54]) by fmsmga001.fm.intel.com with ESMTP; 05 Feb 2020 01:59:07 -0800 Date: Wed, 5 Feb 2020 17:59:24 +0800 From: Wei Yang To: David Hildenbrand Cc: 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 , Wei Yang Subject: Re: [PATCH v6 08/10] mm/memory_hotplug: Don't check for "all holes" in shrink_zone_span() Message-ID: <20200205095924.GC24162@richard> Reply-To: Wei Yang References: <20191006085646.5768-1-david@redhat.com> <20191006085646.5768-9-david@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191006085646.5768-9-david@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, Oct 06, 2019 at 10:56:44AM +0200, David Hildenbrand wrote: >If we have holes, the holes will automatically get detected and removed >once we remove the next bigger/smaller section. The extra checks can >go. > >Cc: Andrew Morton >Cc: Oscar Salvador >Cc: Michal Hocko >Cc: David Hildenbrand >Cc: Pavel Tatashin >Cc: Dan Williams >Cc: Wei Yang >Signed-off-by: David Hildenbrand >--- > mm/memory_hotplug.c | 34 +++++++--------------------------- > 1 file changed, 7 insertions(+), 27 deletions(-) > >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. For example: if () { } else if () { } else { goto out; } /* The zone has no valid section */ if (!pfn) { zone->zone_start_pfn = 0; zone->spanned_pages = 0; } out: zone_span_writeunlock(zone); Well, this is just my personal taste :-) >- >- /* >- * The section is not biggest or smallest mem_section in the zone, it >- * only creates a hole in the zone. So in this case, we need not >- * change the zone. But perhaps, the zone has only hole data. Thus >- * it check the zone has only hole or not. >- */ >- pfn = zone_start_pfn; >- for (; pfn < zone_end_pfn; pfn += PAGES_PER_SUBSECTION) { >- if (unlikely(!pfn_to_online_page(pfn))) >- continue; >- >- if (page_zone(pfn_to_page(pfn)) != zone) >- continue; >- >- /* Skip range to be removed */ >- if (pfn >= start_pfn && pfn < end_pfn) >- continue; >- >- /* If we find valid section, we have nothing to do */ >- zone_span_writeunlock(zone); >- return; >- } >- >- /* The zone has no valid section */ >- zone->zone_start_pfn = 0; >- zone->spanned_pages = 0; > zone_span_writeunlock(zone); > } > >-- >2.21.0 -- Wei Yang Help you, Help me