Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1360566ybv; Thu, 6 Feb 2020 02:46:06 -0800 (PST) X-Google-Smtp-Source: APXvYqy3oDTNwJFcW8X5P0T9zVnYNByj1YocCFF2jddyMa66K23moa56pS3MjyOFjIVlvv7hiWGI X-Received: by 2002:a54:440e:: with SMTP id k14mr6229544oiw.160.1580985966324; Thu, 06 Feb 2020 02:46:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580985966; cv=none; d=google.com; s=arc-20160816; b=HJRsvN7C4tQWWxzycmZ+eLqK1sEV3Eo9Nf1GOsQacoL37L+FT2OA5179yzERcUy/YZ wc/JjUYzqqrToi5EAXuSo17PqBgdBQ6iIym1xh9REmubfK3EDNLMZo+MxGSTWQgzh+LW 4sj3M+IouhPLNfn6Ubf1oKbfOusHUOQxuQHo3WOTXWIyxp54C+uvI06c6qQb6PsaHWz7 LyH+xG0Tyakt/jjeFrpmN+CXPMJB/5lfpUbiHXAsQKDXDHnJQjjg4agtsb2wKwo4NKdl /cl2bSVp+RkMJrVDDUV0AUh9TDCYSB7s4P21ILK5AaaJOaSAcZ/EnvvTDnWJxw/lEdUA 7E8Q== 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=GQ1cUTREQNuJAu5bUl8Fv+OR09amMOpiErx1l97ZOCA=; b=wBMSGvUsmRcsfIDa9JhdIOM/XU2mrGUl54xPQbMgigYc4mzWUFP5KC420Kv3UO1P5w C+3KnDZ6JB595AWtmLTi7lRRCk7+eG0pDpOJ60h9HCS7GWLsKLmfXvurdqPtVauVW6TR 3SaywYOoZE6+rmS1/FmZWRkwx1ppEZXhVXYk0bzd9wPM4V58ooCZafwhB4N/68VXiG1R eDClrFzZe1hcWshiO2qj/sQg9Pq+nItwu8qVdF8T96HfibuAjWiSPONpdgDpbumUreda r3s5NGkv6+0gcPcdUVAeslo7u3VPcp6I7wv0L6IChmnGvhMUw7Tpjj084KvdJW3tHX/T I7tQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=R2LQcvcf; 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 h9si1645302oti.155.2020.02.06.02.45.53; Thu, 06 Feb 2020 02:46:06 -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=R2LQcvcf; 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 S1728232AbgBFJfn (ORCPT + 99 others); Thu, 6 Feb 2020 04:35:43 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:46079 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727398AbgBFJfn (ORCPT ); Thu, 6 Feb 2020 04:35:43 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580981742; 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=GQ1cUTREQNuJAu5bUl8Fv+OR09amMOpiErx1l97ZOCA=; b=R2LQcvcffXcLT5VQX76lNJAOPL1NvOLawRezzeWqgpd1bwIWRQ+o95SjKTTPVCtYAbY/pH QIzU2oRCs1/DoVBG7TjJQWE+GA0GGVTti+tFPVu5IC08plq4uTVGGzn4HpskY8Efg3PZki B4ibNmUgb1crXrwVy4CXsnU5FAlX+6U= 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-113-GWDkqie6OSu9-T2rBII9QA-1; Thu, 06 Feb 2020 04:35:38 -0500 X-MC-Unique: GWDkqie6OSu9-T2rBII9QA-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 B918418A6EC0; Thu, 6 Feb 2020 09:35:36 +0000 (UTC) Received: from localhost (ovpn-12-19.pek2.redhat.com [10.72.12.19]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2089D1A8E4; Thu, 6 Feb 2020 09:35:33 +0000 (UTC) Date: Thu, 6 Feb 2020 17:35:30 +0800 From: Baoquan He To: David Hildenbrand Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, akpm@linux-foundation.org, richardw.yang@linux.intel.com, mhocko@suse.com, osalvador@suse.de Subject: Re: [PATCH] mm/hotplug: Adjust shrink_zone_span() to keep the old logic Message-ID: <20200206093530.GO8965@MiWiFi-R3L-srv> References: <20200206053912.1211-1-bhe@redhat.com> <7ecaf36f-9f70-05bd-05fc-6dec82b7d559@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <7ecaf36f-9f70-05bd-05fc-6dec82b7d559@redhat.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 02/06/20 at 09:50am, David Hildenbrand wrote: > On 06.02.20 06:39, Baoquan He wrote: > > In commit 950b68d9178b ("mm/memory_hotplug: don't check for "all holes" > > in shrink_zone_span()"), the zone->zone_start_pfn/->spanned_pages > > resetting is moved into the if()/else if() branches, if the zone becomes > > empty. However the 2nd resetting code block may cause misunderstanding. > > > > So take the resetting codes out of the conditional checking and handling > > branches just as the old code does, the find_smallest_section_pfn()and > > find_biggest_section_pfn() searching have done the the same thing as > > the old for loop did, the logic is kept the same as the old code. This > > can remove the possible confusion. > > > > Signed-off-by: Baoquan He > > --- > > mm/memory_hotplug.c | 14 ++++++-------- > > 1 file changed, 6 insertions(+), 8 deletions(-) > > > > diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c > > index 089b6c826a9e..475d0d68a32c 100644 > > --- a/mm/memory_hotplug.c > > +++ b/mm/memory_hotplug.c > > @@ -398,7 +398,7 @@ static unsigned long find_biggest_section_pfn(int nid, struct zone *zone, > > static void shrink_zone_span(struct zone *zone, unsigned long start_pfn, > > unsigned long end_pfn) > > { > > - unsigned long pfn; > > + unsigned long pfn = zone->zone_start_pfn; > > int nid = zone_to_nid(zone); > > > > zone_span_writelock(zone); > > @@ -414,9 +414,6 @@ static void shrink_zone_span(struct zone *zone, unsigned long start_pfn, > > if (pfn) { > > zone->spanned_pages = zone_end_pfn(zone) - pfn; > > zone->zone_start_pfn = pfn; > > - } else { > > - zone->zone_start_pfn = 0; > > - zone->spanned_pages = 0; > > } > > } else if (zone_end_pfn(zone) == end_pfn) { > > /* > > @@ -429,10 +426,11 @@ static void shrink_zone_span(struct zone *zone, unsigned long start_pfn, > > start_pfn); > > if (pfn) > > zone->spanned_pages = pfn - zone->zone_start_pfn + 1; > > - else { > > - zone->zone_start_pfn = 0; > > - zone->spanned_pages = 0; > > - } > > + } > > + > > + if (!pfn) { > > + zone->zone_start_pfn = 0; > > + zone->spanned_pages = 0; > > } > > zone_span_writeunlock(zone); > > } > > > > So, what if your zone starts at pfn 0? Unlikely that we can actually > offline that, but still it is more confusing than the old code IMHO. > Then I prefer to drop the second else case as discussed instead. Hmm, pfn is initialized as zone->zone_start_pfn, does it matter? The impossible empty zone won't go wrong if it really happen.