Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp4028085ybl; Mon, 13 Jan 2020 06:42:12 -0800 (PST) X-Google-Smtp-Source: APXvYqw9HGbwbD9RIkHQaHN01EnHtk+nOf2jeVgWQgbRd7u0AWe/i1SHic/YJ4lpNvXfkdl90Hbm X-Received: by 2002:a9d:6849:: with SMTP id c9mr13875064oto.206.1578926532905; Mon, 13 Jan 2020 06:42:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578926532; cv=none; d=google.com; s=arc-20160816; b=h/DTiTBZuWHL7MAGdusvHVtT2wZmNGVlkGplLa0FiVYR0cnqvB/BLkThTETyqNxE5m VhkQBh/6yIdD7OEXd1NkqXZGzpzOsIiNM1GhE3ByPCTEyxW7zaNT7TZciqB3+BKzb6TF ymMUyulXLrWUOuos0x72yWkBtk68rQ0lb3CyHkPAjAWBkCqpwAU+KO45Nms5tbozpj+c MJf5X8pb74ki2JHDTnkpW9dMHKV68afovFZLMG1S/t9xNTHHwShoOqYwCzN9+TzMGRlH wQs5vLyNTcYcrIBCnm3sBfiNNDfFujSf8zfeuFPHGJ6259gjXI9hImjgxMjbgDjsHG+9 r71g== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=XbGm8Hi3zlVTxr/j632O0PSIM+6guj6wM2pmWx8G2xc=; b=VS+a1rXEGlba0KCKg6bRKLAD3YS0Ba+tpCkaPjUETe1tUMFLcANWArEVPUWIaO12cQ 2VI997F/ggT1Ohv37wkvw0NcT2Cdi0Mywe35PKQwruS4TdEg2C2nDW3nUQ4WHf9qYJJ9 fIe7efZ93En94ywB0a4jhsK3OqDGt7Bt+st51gb0guqKvn/PMPWz+QuWKGmYoJYcvGhi 0Sz2/A+ZOns5Gwmmt4BtB8S/GA4pEY9aOzhbxStSgRjQuIrP67lEPENcJksOHb77pk+e IklCX4q+0mu7YMCulaLx4QW6AjcaybVkrfteEhz5ONBF75BK2HlEs2dCa4PDQXYDQ+l/ +aow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=iPWpv7lZ; 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 11si7265216otu.301.2020.01.13.06.42.01; Mon, 13 Jan 2020 06:42:12 -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=iPWpv7lZ; 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 S1728920AbgAMOkt (ORCPT + 99 others); Mon, 13 Jan 2020 09:40:49 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:38107 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728643AbgAMOks (ORCPT ); Mon, 13 Jan 2020 09:40:48 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578926447; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XbGm8Hi3zlVTxr/j632O0PSIM+6guj6wM2pmWx8G2xc=; b=iPWpv7lZgTrnTkzAhqzvXiK/ksY/HiBle0x4u/L1fr3O2XQ1eGbqJjV6NCnKi+cF8IOO+N qduf0U16uPWUoP31ToZPpprpBCJu0/L2HQmHYOlvTqcQoCh22GnlkZW1qKRzlrm+k0aYPF Wxs0mqLH8+8EjzEjQqPjHwEiYjm56Wc= 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-364-bv2mHPcxMliAo2mltf5viQ-1; Mon, 13 Jan 2020 09:40:44 -0500 X-MC-Unique: bv2mHPcxMliAo2mltf5viQ-1 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 B74B8107ACC7; Mon, 13 Jan 2020 14:40:42 +0000 (UTC) Received: from t480s.redhat.com (ovpn-117-201.ams2.redhat.com [10.36.117.201]) by smtp.corp.redhat.com (Postfix) with ESMTP id 14E2919C6A; Mon, 13 Jan 2020 14:40:40 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, David Hildenbrand , Pavel Tatashin , Andrew Morton , Michal Hocko , Oscar Salvador , "Kirill A . Shutemov" Subject: [PATCH v1 1/2] mm/page_alloc: fix and rework pfn handling in memmap_init_zone() Date: Mon, 13 Jan 2020 15:40:34 +0100 Message-Id: <20200113144035.10848-2-david@redhat.com> In-Reply-To: <20200113144035.10848-1-david@redhat.com> References: <20200113144035.10848-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Let's update the pfn manually whenever we continue the loop. This makes the code easier to read but also less error prone (and we can directly fix one issue). When overlap_memmap_init() returns true, pfn is updated to "memblock_region_memory_end_pfn(r)". So it already points at the *next* pfn to process. Incrementing the pfn another time is wrong, we might leave one uninitialized. I spotted this by inspecting the code, so I have no idea if this is relevant in practise (with kernelcore=3Dmirror). Fixes: a9a9e77fbf27 ("mm: move mirrored memory specific code outside of m= emmap_init_zone") Cc: Pavel Tatashin Cc: Andrew Morton Cc: Michal Hocko Cc: Oscar Salvador Cc: Kirill A. Shutemov Signed-off-by: David Hildenbrand --- mm/page_alloc.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index a41bd7341de1..a92791512077 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -5905,18 +5905,20 @@ void __meminit memmap_init_zone(unsigned long siz= e, int nid, unsigned long zone, } #endif =20 - for (pfn =3D start_pfn; pfn < end_pfn; pfn++) { + for (pfn =3D start_pfn; pfn < end_pfn; ) { /* * There can be holes in boot-time mem_map[]s handed to this * function. They do not exist on hotplugged memory. */ if (context =3D=3D MEMMAP_EARLY) { if (!early_pfn_valid(pfn)) { - pfn =3D next_pfn(pfn) - 1; + pfn =3D next_pfn(pfn); continue; } - if (!early_pfn_in_nid(pfn, nid)) + if (!early_pfn_in_nid(pfn, nid)) { + pfn++; continue; + } if (overlap_memmap_init(zone, &pfn)) continue; if (defer_init(nid, pfn, end_pfn)) @@ -5944,6 +5946,7 @@ void __meminit memmap_init_zone(unsigned long size,= int nid, unsigned long zone, set_pageblock_migratetype(page, MIGRATE_MOVABLE); cond_resched(); } + pfn++; } } =20 --=20 2.24.1