From patchwork Mon Jan 13 14:40:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 11330351 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CE24192A for ; Mon, 13 Jan 2020 14:40:50 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 9B79C207FD for ; Mon, 13 Jan 2020 14:40:50 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="iPWpv7lZ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9B79C207FD 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 481948E0006; Mon, 13 Jan 2020 09:40:49 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 4314E8E0003; Mon, 13 Jan 2020 09:40:49 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 31EE88E0006; Mon, 13 Jan 2020 09:40:49 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0214.hostedemail.com [216.40.44.214]) by kanga.kvack.org (Postfix) with ESMTP id 1B1478E0003 for ; Mon, 13 Jan 2020 09:40:49 -0500 (EST) Received: from smtpin04.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with SMTP id A0A83440B for ; Mon, 13 Jan 2020 14:40:48 +0000 (UTC) X-FDA: 76372872576.04.anger41_4133ed4e74c08 X-Spam-Summary: 1,0,0,,d41d8cd98f00b204,david@redhat.com,:linux-kernel@vger.kernel.org::david@redhat.com:pasha.tatashin@oracle.com:akpm@linux-foundation.org:mhocko@kernel.org:osalvador@suse.de:kirill@shutemov.name,RULES_HIT:30012:30054:30064:30070,0,RBL:205.139.110.61:@redhat.com:.lbl8.mailshell.net-62.18.0.100 66.10.201.10,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:ft,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:24,LUA_SUMMARY:none X-HE-Tag: anger41_4133ed4e74c08 X-Filterd-Recvd-Size: 4320 Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by imf46.hostedemail.com (Postfix) with ESMTP for ; Mon, 13 Jan 2020 14:40:47 +0000 (UTC) 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 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: 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=mirror). Fixes: a9a9e77fbf27 ("mm: move mirrored memory specific code outside of memmap_init_zone") Cc: Pavel Tatashin Cc: Andrew Morton Cc: Michal Hocko Cc: Oscar Salvador Cc: Kirill A. Shutemov Signed-off-by: David Hildenbrand Reviewed-by: Alexander Duyck --- 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 size, int nid, unsigned long zone, } #endif - for (pfn = start_pfn; pfn < end_pfn; pfn++) { + for (pfn = 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 == MEMMAP_EARLY) { if (!early_pfn_valid(pfn)) { - pfn = next_pfn(pfn) - 1; + pfn = 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++; } }