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=-6.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 A4E67C47E49 for ; Sun, 27 Oct 2019 22:27:29 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 392072067B for ; Sun, 27 Oct 2019 22:27:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="A61E7LDk" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 392072067B 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 A8B4E6B0003; Sun, 27 Oct 2019 18:27:28 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A3ADD6B0006; Sun, 27 Oct 2019 18:27:28 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9529B6B0007; Sun, 27 Oct 2019 18:27:28 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 72C906B0003 for ; Sun, 27 Oct 2019 18:27:28 -0400 (EDT) Received: from smtpin01.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with SMTP id 110E76D9D for ; Sun, 27 Oct 2019 22:27:28 +0000 (UTC) X-FDA: 76091002176.01.voice73_23ee3a921c557 X-HE-Tag: voice73_23ee3a921c557 X-Filterd-Recvd-Size: 4820 Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by imf45.hostedemail.com (Postfix) with ESMTP for ; Sun, 27 Oct 2019 22:27:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1572215246; 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: content-transfer-encoding:content-transfer-encoding; bh=wRHG8SDGIYgraIGReOni3E60U4X7OoMWr6f5ZsbvZJU=; b=A61E7LDky5LozS2T248aVDpYauGsh09IaPeBDbRdWETm2mK3KG7boUYFykMCbYC4uieOMz PUcOPVA5Dtzc+kZvRL11md0B9wPOthNBQX93QST6M1MX2vbbMTVmi3dHSjxdWMVNi/jrDt PZFu2Pm71UcceNcLfbDhSW/hoHHFY2c= 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-59-N3mIgUl8NmS54_KnDVdKfQ-1; Sun, 27 Oct 2019 18:27:22 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B7617476; Sun, 27 Oct 2019 22:27:20 +0000 (UTC) Received: from t460s.redhat.com (ovpn-116-60.ams2.redhat.com [10.36.116.60]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8D93519C68; Sun, 27 Oct 2019 22:27:15 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, David Hildenbrand , Andrew Morton , Michal Hocko , Oscar Salvador , Stephen Rothwell , Dan Williams , Pavel Tatashin , Greg Kroah-Hartman Subject: [PATCH v1] mm/memory_hotplug: Fix updating the node span Date: Sun, 27 Oct 2019 23:27:14 +0100 Message-Id: <20191027222714.5313-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: N3mIgUl8NmS54_KnDVdKfQ-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset=WINDOWS-1252 Content-Transfer-Encoding: quoted-printable 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: 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. Fixes: 00d6c019b5bc ("mm/memory_hotplug: don't access uninitialized memmaps= in shrink_pgdat_span()") Cc: Andrew Morton Cc: Michal Hocko Cc: Oscar Salvador Cc: Stephen Rothwell Cc: Dan Williams Cc: Pavel Tatashin Cc: Greg Kroah-Hartman Signed-off-by: David Hildenbrand --- Luckily, this patch made me realize that try_offline_node() is completely broken: - We easily touch the (garbage) memmap of offline sections - We will not properly handle the case where we have different NIDs within a single section This needs proper fixing. We will have to look at the memory block nid of offline memory blocks and scan all pages (or rather pageblocks) of online memory blocks. --- mm/memory_hotplug.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 561371ead39a..0140c20837b6 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -442,6 +442,14 @@ static void update_pgdat_span(struct pglist_data *pgda= t) =09=09=09=09=09 zone->spanned_pages; =20 =09=09/* No need to lock the zones, they can't change. */ +=09=09if (!zone->spanned_pages) +=09=09=09continue; +=09=09if (!node_end_pfn) { +=09=09=09node_start_pfn =3D zone->zone_start_pfn; +=09=09=09node_end_pfn =3D zone_end_pfn; +=09=09=09continue; +=09=09} + =09=09if (zone_end_pfn > node_end_pfn) =09=09=09node_end_pfn =3D zone_end_pfn; =09=09if (zone->zone_start_pfn < node_start_pfn) --=20 2.21.0