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.9 required=3.0 tests=DKIMWL_WL_HIGH,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 31762C3524D for ; Mon, 3 Feb 2020 21:44:55 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id DB1C42086A for ; Mon, 3 Feb 2020 21:44:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="UJEQwBBk" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DB1C42086A 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 8AA9C6B0003; Mon, 3 Feb 2020 16:44:54 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 8599C6B0005; Mon, 3 Feb 2020 16:44:54 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 748CE6B0006; Mon, 3 Feb 2020 16:44:54 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0111.hostedemail.com [216.40.44.111]) by kanga.kvack.org (Postfix) with ESMTP id 5C33C6B0003 for ; Mon, 3 Feb 2020 16:44:54 -0500 (EST) Received: from smtpin18.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id F0509180AD804 for ; Mon, 3 Feb 2020 21:44:53 +0000 (UTC) X-FDA: 76450146066.18.sense41_2aaa765985a1f X-HE-Tag: sense41_2aaa765985a1f X-Filterd-Recvd-Size: 6677 Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by imf17.hostedemail.com (Postfix) with ESMTP for ; Mon, 3 Feb 2020 21:44:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580766292; 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: in-reply-to:in-reply-to:references:references; bh=/WQO8MbdfMJxADhnl7L892fLZrx+qWKtI0GdGiu2eug=; b=UJEQwBBkPfpAMSPrsB4lxCwaBfSO89qr+qTzV5Bjw9D8G9J40h6BpmfCsXHX/AZ68X15pT L0BZfO0OA/Uzv+1Hph8i3+4CCVlabOH3/aRSSX/+lYaCSXZwpWKw7txDSTYHjL/xGWoo9X v79EDxBMeomHSfEUI6YaIFhWPBOVemY= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-292-htHshNYYP46u0zogQF5wug-1; Mon, 03 Feb 2020 16:44:48 -0500 Received: by mail-wr1-f72.google.com with SMTP id l1so3895391wrt.4 for ; Mon, 03 Feb 2020 13:44:47 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:content-transfer-encoding:from:mime-version :subject:date:message-id:references:cc:in-reply-to:to; bh=APvzKJbOVU63A3dxA5kI8kBeWOZPD++mpXTHMc1xuKc=; b=j+86xRUWcf6iHstNY/xc9EQXeJ4u1q4jJDe50NFoN4JcwGvlRexF6RQYXmUFsRTDy5 BC/6NLybM8e5F7EAJZZUOPPyzScGfP2aeytPWWTovQKlRf3H9wX77fiAjSFfk2A5eA8I r5eZhmXjSbXcEJFuOWXGxx59zMnRanJCyRqrn5BeNG5ejCD487lp1OViGgKjYWeK28MC 8H+NWQ7HiHv7fkmzxOvzzzy5j4YCmj8hDVYQJJKAZ+tl10smSR11Z1p739CT46phTG41 Wkm8M+l22yGa583pVJz+o5a4gVmoqKyN0GKZbMG8MFuYjZVe1Rb0sp1w6KOJLmDMe8g6 neqQ== X-Gm-Message-State: APjAAAUf7vy/UUreTIe/30zvU3J91sHk2zixAfTWZcMT7h0orDKOEMhN wIDpMwcKWdsrl1TQjN54yMwy6XjMefz/48ynGrNNFtDdhY1NW4cmeBb7QQdpIZ5yBJldOI0ZR93 MUDOAC8ors88= X-Received: by 2002:adf:ec83:: with SMTP id z3mr16898618wrn.133.1580766286883; Mon, 03 Feb 2020 13:44:46 -0800 (PST) X-Google-Smtp-Source: APXvYqyrsyYng4IR6o6G/LYaVafSTJOiC/W7rP+gXYQ+Gl4WeTH94Pt4DFpOc0g+rN+cc4LgnOQtXQ== X-Received: by 2002:adf:ec83:: with SMTP id z3mr16898607wrn.133.1580766286715; Mon, 03 Feb 2020 13:44:46 -0800 (PST) Received: from [192.168.3.122] (p5B0C6AA7.dip0.t-ipconnect.de. [91.12.106.167]) by smtp.gmail.com with ESMTPSA id e17sm14180838wrn.62.2020.02.03.13.44.46 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 03 Feb 2020 13:44:46 -0800 (PST) From: David Hildenbrand Mime-Version: 1.0 (1.0) Subject: Re: [PATCH v1 1/2] mm/page_alloc: fix and rework pfn handling in memmap_init_zone() Date: Mon, 3 Feb 2020 22:44:45 +0100 Message-Id: <1583F4CF-6CD8-4AB6-A2F6-60E6AEE5D5B2@redhat.com> References: Cc: David Hildenbrand , LKML , linux-mm , Pavel Tatashin , Andrew Morton , Michal Hocko , Oscar Salvador , "Kirill A . Shutemov" In-Reply-To: To: Alexander Duyck X-Mailer: iPhone Mail (17C54) X-MC-Unique: htHshNYYP46u0zogQF5wug-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 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: > Am 03.02.2020 um 22:35 schrieb Alexander Duyck : >=20 > =EF=BB=BFOn Mon, Jan 13, 2020 at 6:40 AM David Hildenbrand wrote: >>=20 >> 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). >>=20 >> 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 hav= e >> no idea if this is relevant in practise (with kernelcore=3Dmirror). >>=20 >> 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 >> --- >> mm/page_alloc.c | 9 ++++++--- >> 1 file changed, 6 insertions(+), 3 deletions(-) >>=20 >> 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 si= ze, 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 t= his >> * 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)) >=20 > I'm pretty sure this is a bit broken. The overlap_memmap_init is going > to return memblock_region_memory_end_pfn instead of the start of the > next region. I think that is going to stick you in a mirrored region > without advancing in that case. You would also need to have that case > do a pfn++ before the continue; Thanks for having a look. Did you read the description regarding this change?