Received: by 2002:a17:90a:88:0:0:0:0 with SMTP id a8csp50440pja; Fri, 22 Nov 2019 03:18:58 -0800 (PST) X-Google-Smtp-Source: APXvYqxshUZfEhkjFY8ZsMbnuNiNHK31EwG032YFXIX9DXjGWSre15QSjqQY9IHY2kNUfJ9gEqDb X-Received: by 2002:a17:906:b30c:: with SMTP id n12mr21220326ejz.96.1574421538213; Fri, 22 Nov 2019 03:18:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574421538; cv=none; d=google.com; s=arc-20160816; b=u209Ku0A306a0YAGUNLRrtysThf1mDfER4uWOgUlM+twlWSoRjuNCZN34Msbf1SWRh qFIUFjH4unbgQeBeEw67cRW+BvXDssHXC9fHfexJ50Mbn4dIRJldEE3WNAZxdhpnOTtd FhonCJK1+/pUMR+TGj5Y1RfriEIYVNg4Blldnsm0XbPLbnJZ2b214T9womsXwD/f3Nqg KFQAtHBJBJxeoVtmBOBzHuh5wD61RmHG9/Tz82gX1jnBF+zXWyVsdYMVXwfpO2t1Mq5C CW8YxHEMEpDNmFakJG8vVkKW/rKwicX84MIbmfTS6JVwLCc9LEZKX9m0wukmdJl95ZNy 4WtA== 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=SKjeTsM3H4iiOwc0KOwZNHzxZo2jjUnIZcc8o7vJMcE=; b=vUJ6d2KvuV+oMUltLx6q1N5m4dLGAwwoqJVYH9RrZellUnvBD7tRfmzcn4PijhJinp UzF7X8u1P+ft0Rw2iyL0uhqhhjQ4T+c9HxJ+RqimDE3jRyCwR/iAJJyr8UiUbofK6imV rhxduAIzxAOXndpcuJXjN6qD6iDrhaB1xYe/zKGwMltnWwILM6BbvEJSI7Fdc+49eu7b dekNwXvk5D/FBRno/osEUWGdrwj7IwGs/TaZCKAEgqxRdh2DTc1vnJR209BZpsG8a+Pq TOvRvRBWxTrz+ozaywR3ol+Y+MfOMNs/GwBhivzwJRzmYyNCoYdWWVr8fydPrzi7e4Ml Cptw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=EJYt+kXD; 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 m14si2104248ejr.395.2019.11.22.03.18.33; Fri, 22 Nov 2019 03:18:58 -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=EJYt+kXD; 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 S1728006AbfKVKuz (ORCPT + 99 others); Fri, 22 Nov 2019 05:50:55 -0500 Received: from mail.kernel.org ([198.145.29.99]:33032 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728482AbfKVKuy (ORCPT ); Fri, 22 Nov 2019 05:50:54 -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 5A02520656; Fri, 22 Nov 2019 10:50:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574419853; bh=/O8vgSfJmlffn4M56jr8hXU25VCaMFhRBL/Sk4VvUmI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EJYt+kXDEZhpGhc4AuL6UErOz5VbM8jocW14qxZcjZ8KVHN5JEUFhfXQBtd30NjTa W+01+qp9/0ZPAkbFFnZ0BPQmyQEaWCe+ttAZNCqKGhWcbut0Iqh2AkUwrNENI3GEr7 sly7CoAoBXLWOXpX2MFLl6hZF4A8QNZgc9oe0bfk= 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.14 007/122] mm/memory_hotplug: fix updating the node span Date: Fri, 22 Nov 2019 11:27:40 +0100 Message-Id: <20191122100727.359872325@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191122100722.177052205@linuxfoundation.org> References: <20191122100722.177052205@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 @@ -470,6 +470,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)