Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1335991ybv; Thu, 6 Feb 2020 02:14:55 -0800 (PST) X-Google-Smtp-Source: APXvYqx80QX0nqvd+04MTu+pwBVE26QKTeLenRVN/mpXz4QEt8LQSLaGKU/TjWBnZRpUG/asWe62 X-Received: by 2002:a05:6808:2d9:: with SMTP id a25mr6620345oid.172.1580984094989; Thu, 06 Feb 2020 02:14:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580984094; cv=none; d=google.com; s=arc-20160816; b=br+X3cvCME5zdhi+qV09PCGjrkF7PQd2q+0Ta3OZ71UA+dj29TUzUo2abWm87LrYFn jTH/4jRl62NyGpi6AvkZo9WMFpXO4JIjVxP/IRhBO1VC2xOrl5PLOeFRfNr9JawpeAQm CWjStgyE9BtxlKJe+55Lo35jpL9skapLCV7QBNtesTUbC3Qo7OCNbi1WVDpLLSAmEPLd OSsPQOsCod4st4NP7LExde4hj+f2sDv1fZitxvdXxZ467Jus+D4yRljl2ITye4ujGdgr jK+nGGjgceDgai0hN/V021iugupt+A7Mkq0KOpdHO48cZctku2+/TVqrXP5Wvk9gmDnT Z2cA== 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=unxSq/DSKQjm74AUc62BAlZa/L3rRgvt3QzEBYnlLMA=; b=LOnjTpMi1c9GCRsuZ25xHf9ByP5APo7UefoA7LFl4emwhsc/zGFeO92keXLHaZaHfx bPc01b+xvYMQ/Tc53ETwkBEyfIRT/8+CNkvipp5AoH2eS5fBii2Rfg9fS2b7WLRY6b1P ocjUUwQjcHrZL/3qAQiq3QtBo4/KTscD0ke1z15g3ye8xjOE0Dx8KCiO3Prv4L9Ue3Hq 30FaWh9/cOqhczNUdXvEBHzPBVXVzevn4E2Ge9G1BJ2zfFYDHgTz509bMR6memDL7Xj8 iw5iWhclU/MMA1H4WL+XdPBbzMK1nY4HFWMuB+EqpcxJsoAbz3Vl52ActJk/jwwUKJN2 ZaRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=OQU6oPPM; 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 p5si1686689oto.116.2020.02.06.02.14.42; Thu, 06 Feb 2020 02:14:54 -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=OQU6oPPM; 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 S1728303AbgBFKMS (ORCPT + 99 others); Thu, 6 Feb 2020 05:12:18 -0500 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:59362 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727864AbgBFKMS (ORCPT ); Thu, 6 Feb 2020 05:12:18 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580983937; 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=OQU6oPPMNDBECYvWaxSxT1svmupgMgX6S6rcNx9ze5rgr3KslXzaHkmPzulzu1qDo5Hb0D LUR35gqowMdDEPElpVOF5B3F/Kdk1QjgfNCaejPuhFAR2sseYtKruOU0vHh8ogAPUy7vJC fydojpNrJ6IiGn/tktO2P5zypHmB1Uo= 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 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.