Received: by 2002:a17:90a:88:0:0:0:0 with SMTP id a8csp40944pja; Fri, 22 Nov 2019 03:11:34 -0800 (PST) X-Google-Smtp-Source: APXvYqyZVuMj7mM1HVJXg9V2QMQiNgcONeWIVAefZk1TVT8rOdUKq//3P//EGsJ1ilcn+oHwMg8q X-Received: by 2002:a50:d756:: with SMTP id i22mr347355edj.24.1574421094533; Fri, 22 Nov 2019 03:11:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574421094; cv=none; d=google.com; s=arc-20160816; b=IzPn9obKsH3HW6zBmJU3A0XxIjDzq2Ry4sh6VlHo0g+HudsRWQAKLXK6gSsHbTn9BL hQx++0gaTRIF5o9+8hbforiCn3ieM5piTgXOawqtFYf1Zaq5G2JC1y4fJ+VU164eS8EP vROWm450sWi5H0TdlEN8YlafsLWumts+LzK1NXgV3318sDi3RUl9UuTtQ02gjWmpvkSK uq7hbm9jihd90e8JuSAdjGnyD0sX/zGTOSquyWj+PYR816T6v91SzIRcTVrGP+sZWf3w TUl0M3KT4wyca/gPmPiku5EGSM1hwaGAJ6S66qwlqeKoqy61mPXNr2EZbPW24NSdbnC0 yitA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=nTnLXCMCdYpH0QZ7KaT0JM/PNWA7gEfc6CNRJGtqnW4=; b=KOBk57G6Z7LSDO35kpK0jQWPPaIKa7Apw7h0hiTfhG4VnIpstlmmnALOAC7K5T1Oqt mh5GtYLW8fc1TXV9NN9d9kqTyJwFiwPQ8iywZD/H8T/Gi5JinJxV+B1s2Cr4tGusJnsL gHBLlnz2z5qZeaphDUAlRcpKBx0o29akNPsULIbG/FjE6gFmPm+56tozM3OVFWKVRG/L MDvTcgGa7xACbwS9Jk9YVgdVrQxcDb3+FjkmXAPkVE+DtbtJ+I5gtLtkcJe/x+ldNupG E30OP2worhUg8ASZN9CSCuuU7L4uqlM0YHxeQbY5HevsOH35GuHtMmqheSBLr80RrDoT DoqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=r+ANl7ZS; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u4si3777165ejx.3.2019.11.22.03.11.10; Fri, 22 Nov 2019 03:11:34 -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=@kernel.org header.s=default header.b=r+ANl7ZS; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730660AbfKVLGy (ORCPT + 99 others); Fri, 22 Nov 2019 06:06:54 -0500 Received: from mail.kernel.org ([198.145.29.99]:35350 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731154AbfKVLGq (ORCPT ); Fri, 22 Nov 2019 06:06:46 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id AA1F22084F; Fri, 22 Nov 2019 11:06:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574420806; bh=mRKZx/dtkkwJ3Waki57KbIjqXykXG+/ubnEk0vOs8iM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=r+ANl7ZSMLjHk4vh7zrgLMV7Fmw7QJ3oVtLSu1FXBd2K/S5pNsHiHAbAjQCHd46KF XxW+WPnDc6fYxcFHgw2hwTURGUxoDljqQiJKC8c+20a/29GFPBVy/NHo98n+o+ju4/ KVAyrBWOJtIPJvgfbGsh/QqHV9vz+DtQwTz8GIDY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, David Hildenbrand , Michal Hocko , Oscar Salvador , Stephen Rothwell , Dan Williams , Pavel Tatashin , Andrew Morton , Linus Torvalds Subject: [PATCH 5.3 4/6] mm/memory_hotplug: fix updating the node span Date: Fri, 22 Nov 2019 11:30:06 +0100 Message-Id: <20191122100326.607203017@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191122100320.878809004@linuxfoundation.org> References: <20191122100320.878809004@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: David Hildenbrand commit 656d571193262a11c2daa4012e53e4d645bbce56 upstream. We recently started updating the node span based on the zone span to avoid touching uninitialized memmaps. Currently, we will always detect the node span to start at 0, meaning a node can easily span too many pages. pgdat_is_empty() will still work correctly if all zones span no pages. We should skip over all zones without spanned pages and properly handle the first detected zone that spans pages. Unfortunately, in contrast to the zone span (/proc/zoneinfo), the node span cannot easily be inspected and tested. The node span gives no real guarantees when an architecture supports memory hotplug, meaning it can easily contain holes or span pages of different nodes. The node span is not really used after init on architectures that support memory hotplug. E.g., we use it in mm/memory_hotplug.c:try_offline_node() and in mm/kmemleak.c:kmemleak_scan(). These users seem to be fine. Link: http://lkml.kernel.org/r/20191027222714.5313-1-david@redhat.com Fixes: 00d6c019b5bc ("mm/memory_hotplug: don't access uninitialized memmaps in shrink_pgdat_span()") Signed-off-by: David Hildenbrand Cc: Michal Hocko Cc: Oscar Salvador Cc: Stephen Rothwell Cc: Dan Williams Cc: Pavel Tatashin Cc: Greg Kroah-Hartman Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- mm/memory_hotplug.c | 8 ++++++++ 1 file changed, 8 insertions(+) --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -447,6 +447,14 @@ static void update_pgdat_span(struct pgl zone->spanned_pages; /* No need to lock the zones, they can't change. */ + if (!zone->spanned_pages) + continue; + if (!node_end_pfn) { + node_start_pfn = zone->zone_start_pfn; + node_end_pfn = zone_end_pfn; + continue; + } + if (zone_end_pfn > node_end_pfn) node_end_pfn = zone_end_pfn; if (zone->zone_start_pfn < node_start_pfn)