Received: by 2002:a17:90a:88:0:0:0:0 with SMTP id a8csp24316pja; Fri, 22 Nov 2019 02:59:18 -0800 (PST) X-Google-Smtp-Source: APXvYqxGj1/IGjRv5oSjrPbpepGCw18xYYupN3oaKfnhyPof4R+O/De6HMVWzSM5JXKNYKIhz5PC X-Received: by 2002:a17:906:b310:: with SMTP id n16mr21221015ejz.129.1574420358310; Fri, 22 Nov 2019 02:59:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574420358; cv=none; d=google.com; s=arc-20160816; b=UnRKbA+ATn12M6uov7TzOZycw1nzt6MMXcu9TDUXqFiC8G1bFqtzdxnJVBnRArnTcY cKqk8cNjwiQGjMgZw4Cm/ltnZZ+lnPS8swXpPOHPY9hhVi5LGOABNSnRrdUHqfDccc0z xo1wkjofu4oL4BE9U3+HHdIRB9Dtdm9I6vmepZlO+23OVsFz9BhwToyu1sq7DooBLw58 kkNlbOW4TG7MMoPv7ZlJWFIUeQfhFAFp9DDBdmwyMg3QtZV/BYsUAcn+7hjVkEADWaPH yvgMmoOX7GyZka2TNZoQpFaBuRJuQOg0Duji+rl7OJnp6vAPw2VVGNXd4BSNUihPizYw wPbg== 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=gC5UVRN021ecLV9YwnzE24KUD/UdGv8qaqw56Q6+DhU=; b=LM2PnnVWnuKMP5O9spOcx3sbrmWbMzLKZlvDXekbk++cFsVNZ9uNR1N5MBkueAkcgx ilvE7lj9ukA6lXpGILw9U9YJTp9y8yvpmgERTAKCa4Fbwe3bltS4LCan0loArdmIKAtP Zjc9+kdIMxeHzVyEiOoNn8fltffCqInCGlJZYxFcahUfqJcgwryTxOwmuQ7MB47F3ttK ZE5vAwDaGQVIkrBK5YFARD/VHeNly0BVkY3n4oolXUSGpZsZqz9mXBmoxvgrus4j0dMe p1TRd721E/rpbu+04PHM8OzmUVMoYNt4AbIzHrDNl0DLgbvDkyq7IyURr73KHQexmSMI EwpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Ys6Flyhi; 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 h17si3712328ejy.239.2019.11.22.02.58.55; Fri, 22 Nov 2019 02:59:18 -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=Ys6Flyhi; 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 S1730359AbfKVK4z (ORCPT + 99 others); Fri, 22 Nov 2019 05:56:55 -0500 Received: from mail.kernel.org ([198.145.29.99]:45328 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727351AbfKVK4z (ORCPT ); Fri, 22 Nov 2019 05:56:55 -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 C9D9D20706; Fri, 22 Nov 2019 10:56:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574420214; bh=aLdsMS44mtvfFUpk9IaOS9bUrH3ckHFcvqYdJecOUb8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ys6FlyhiPkik2d28NS5PEXxIYgPGUeQnhOi1cBlawDtIq2RnPXLCJRT2vX05lY1XF gCiVno3FtXT82Ieq15s7KaGdHF7IcYUKiM23t3ViFA6nu5GQGAKeJn9ZqahnpTRlbx C7rCXCR9I/ZDhkSKXT5+uHqwbJ6lVPXoVTvnUYBQ= 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 4.19 008/220] mm/memory_hotplug: fix updating the node span Date: Fri, 22 Nov 2019 11:26:13 +0100 Message-Id: <20191122100913.264411908@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191122100912.732983531@linuxfoundation.org> References: <20191122100912.732983531@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 @@ -448,6 +448,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)