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 16903C2D0B1 for ; Thu, 6 Feb 2020 10:12:19 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id C10A020658 for ; Thu, 6 Feb 2020 10:12:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="YaKXRXKg" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C10A020658 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 695B76B0003; Thu, 6 Feb 2020 05:12:18 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 647496B0006; Thu, 6 Feb 2020 05:12:18 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 55C196B0007; Thu, 6 Feb 2020 05:12:18 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0088.hostedemail.com [216.40.44.88]) by kanga.kvack.org (Postfix) with ESMTP id 3C9866B0003 for ; Thu, 6 Feb 2020 05:12:18 -0500 (EST) Received: from smtpin30.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id DEC632DFD for ; Thu, 6 Feb 2020 10:12:17 +0000 (UTC) X-FDA: 76459287114.30.money15_886aeb24ce24a X-HE-Tag: money15_886aeb24ce24a X-Filterd-Recvd-Size: 6542 Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by imf13.hostedemail.com (Postfix) with ESMTP for ; Thu, 6 Feb 2020 10:12:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580983936; 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=unxSq/DSKQjm74AUc62BAlZa/L3rRgvt3QzEBYnlLMA=; b=YaKXRXKg3lRt7TlYTZDC57BIb72kUxRM3OXjWtowr291BmWdsTN4RLesGu4O8U9EmXMZOo v3i5cM41XD7geRq183Y+8yBYu1mckcjwBnZp4P2hlMbj/d8FCl/sleVdO0NMg4jEdEtQ4F Oh8xOtsiIo4K+Aqq5O5IRa3l6CWbM5g= 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-58-qoAW3UfVPyCfK8TDjy4J9A-1; Thu, 06 Feb 2020 05:12:13 -0500 X-MC-Unique: qoAW3UfVPyCfK8TDjy4J9A-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BE4341007275; Thu, 6 Feb 2020 10:12:11 +0000 (UTC) Received: from localhost (ovpn-12-19.pek2.redhat.com [10.72.12.19]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0F9E15C1D8; Thu, 6 Feb 2020 10:12:08 +0000 (UTC) Date: Thu, 6 Feb 2020 18:12:05 +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: <20200206101205.GQ8965@MiWiFi-R3L-srv> References: <20200206053912.1211-1-bhe@redhat.com> <7ecaf36f-9f70-05bd-05fc-6dec82b7d559@redhat.com> <20200206093530.GO8965@MiWiFi-R3L-srv> <20200206100029.GP8965@MiWiFi-R3L-srv> <9e5ccff5-faa4-837d-7cdb-d94b8b5870a8@redhat.com> <1f63318c-2200-cad9-559e-b1074c011392@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1f63318c-2200-cad9-559e-b1074c011392@redhat.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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 02/06/20 at 11:05am, David Hildenbrand wrote: > On 06.02.20 11:02, David Hildenbrand wrote: > > On 06.02.20 11:00, Baoquan He wrote: > >> On 02/06/20 at 10:48am, David Hildenbrand wrote: > >>> On 06.02.20 10:35, Baoquan He wrote: > >>>> 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. > >>>> > >>> > >>> If you offline any memory block that belongs to the lowest zone > >>> (zone->zone_start_pfn == 0) but does not fall on a boundary (so that you > >>> can actually shrink), you would mark the whole zone offline. That's > >>> broken unless I am missing something. > >> > >> AFAIK, the page 0 is reserved. No valid zone can start at 0, only empty > >> zone is. Please correct me if I am wrong. > > > > At least on x86 it indeed is :) So if this holds true for all archs > > > > Acked-by: David Hildenbrand > > > > Thanks! > > > > > > Correction > > Nacked-by: David Hildenbrand > > s390x: > [linux1@rhkvm01 ~]$ cat /proc/zoneinfo > Node 0, zone DMA > per-node stats > [...] > node_unreclaimable: 0 > start_pfn: 0 OK, it's very interesting, and good to know. This should be discarded.