Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2189093pxb; Tue, 23 Feb 2021 00:12:21 -0800 (PST) X-Google-Smtp-Source: ABdhPJwZ26T1H3wQUmupB3o+sYYpfsFIeTmweTsxmKfQ1b6/+fkXtQKyZQ9/wwQJEzn9POi1Hp9H X-Received: by 2002:a05:6402:4d3:: with SMTP id n19mr26668258edw.2.1614067941356; Tue, 23 Feb 2021 00:12:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614067941; cv=none; d=google.com; s=arc-20160816; b=sXIEG1gyODI1UY3umu35VvJeT+dWrsOSmO5Gsuz/rTTR4BNtAYlatS5pjDAZMgVTJT fU5R+WIunjfzND7Iz1iA0+3S49v9w/Tc+nMDka95bqjIxRtZzsTVi7bBy0sCsunw5Bdk gi5TT7675q7c9IaYOpbOJ3etVP6YyBEdXdpWv/8g3RfE+9uSUQgv7jCYld27Wa05E8Kz PmAtu3MpAzsOwOgi3czAcGb/yFeUht4dphbpjeRNQkTlv2ELgIaL1foYux7i7MMwm+yG 6Btbhe+daaWGJuo8uZmjYS6y7ddaXMpGtvrzwCNqoyE2CKPE/RQmdJdmQll26Bc5KQw2 T68g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:organization :from:references:cc:to:subject:dkim-signature; bh=TvIJWNY4/1GkazmbPNAwia/J/m5uVDdO8zNLf6UfHyc=; b=Z4sH3iGwHyyDeKdvaVyDLXvGD7hetKShOzwJ+qgFjp8r+akFgIKGJYFRCqb/hli693 /NZ7Fs0ZdswiWeeeiBS/Uk2j8/rQbnkbRsUOymvhSpCK4KRvgfoSbubpaer5VQluh5bp WLaYAy+TWKqd/I6Bz73L7PKZpl/Ip/lc4OIedvAgPvX/1sm6EOTPgEqRug4bZrLAh2N/ veI5ldABnvjT5uk5ZI+N/XUMWfd42Cdtpu42P+FYfS9tBl5Cz410RI0pfbPkVAemlBVv 5G+d/+i0YFuZZMRq8km/v0bPqMGhEWm5iP0CuOPKeqfWkCn5eLKptVMmz/mE/upfPFhR Md0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=PghX9Cno; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id jz9si12988835ejb.510.2021.02.23.00.11.51; Tue, 23 Feb 2021 00:12:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=PghX9Cno; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S231971AbhBWIGv (ORCPT + 99 others); Tue, 23 Feb 2021 03:06:51 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:20800 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231960AbhBWIGR (ORCPT ); Tue, 23 Feb 2021 03:06:17 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614067489; 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=TvIJWNY4/1GkazmbPNAwia/J/m5uVDdO8zNLf6UfHyc=; b=PghX9CnoOxvbWUo4w9lr4hKJrzriHfT8Bks71Zf8rMRRJoBc8i05xpHpoAPMuRuPy+8lE5 zvNI2VUfp1hps+SdYq2TItPGIw5NOl28MPIO4/Jcb2hn2y5nQDa349e1GGKW9HURZ7OEwt 7/pH/JryIBjClET/6O67FhsDXeaeahk= 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-415-RMz4k9mhMuqSZi37eipL3A-1; Tue, 23 Feb 2021 03:04:45 -0500 X-MC-Unique: RMz4k9mhMuqSZi37eipL3A-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 AA3B780197A; Tue, 23 Feb 2021 08:04:27 +0000 (UTC) Received: from [10.36.114.0] (ovpn-114-0.ams2.redhat.com [10.36.114.0]) by smtp.corp.redhat.com (Postfix) with ESMTP id ABF4719725; Tue, 23 Feb 2021 08:04:20 +0000 (UTC) Subject: Re: [PATCH v6 1/1] mm/page_alloc.c: refactor initialization of struct page for holes in memory layout To: Mike Rapoport , Andrew Morton Cc: Andrea Arcangeli , Baoquan He , Borislav Petkov , Chris Wilson , "H. Peter Anvin" , Ingo Molnar , Linus Torvalds , =?UTF-8?Q?=c5=81ukasz_Majczak?= , Mel Gorman , Michal Hocko , Mike Rapoport , Qian Cai , "Sarvela, Tomi P" , Thomas Gleixner , Vlastimil Babka , linux-kernel@vger.kernel.org, linux-mm@kvack.org, stable@vger.kernel.org, x86@kernel.org References: <20210222105728.28636-1-rppt@kernel.org> From: David Hildenbrand Organization: Red Hat GmbH Message-ID: Date: Tue, 23 Feb 2021 09:04:19 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.0 MIME-Version: 1.0 In-Reply-To: <20210222105728.28636-1-rppt@kernel.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 22.02.21 11:57, Mike Rapoport wrote: > From: Mike Rapoport > > There could be struct pages that are not backed by actual physical memory. > This can happen when the actual memory bank is not a multiple of > SECTION_SIZE or when an architecture does not register memory holes > reserved by the firmware as memblock.memory. > > Such pages are currently initialized using init_unavailable_mem() function > that iterates through PFNs in holes in memblock.memory and if there is a > struct page corresponding to a PFN, the fields of this page are set to > default values and it is marked as Reserved. > > init_unavailable_mem() does not take into account zone and node the page > belongs to and sets both zone and node links in struct page to zero. > > Before commit 73a6e474cb37 ("mm: memmap_init: iterate over memblock regions > rather that check each PFN") the holes inside a zone were re-initialized > during memmap_init() and got their zone/node links right. However, after > that commit nothing updates the struct pages representing such holes. > > On a system that has firmware reserved holes in a zone above ZONE_DMA, for > instance in a configuration below: > > # grep -A1 E820 /proc/iomem > 7a17b000-7a216fff : Unknown E820 type > 7a217000-7bffffff : System RAM > > unset zone link in struct page will trigger > > VM_BUG_ON_PAGE(!zone_spans_pfn(page_zone(page), pfn), page); > > because there are pages in both ZONE_DMA32 and ZONE_DMA (unset zone link > in struct page) in the same pageblock. > > Interleave initialization of the unavailable pages with the normal > initialization of memory map, so that zone and node information will be > properly set on struct pages that are not backed by the actual memory. > > With this change the pages for holes inside a zone will get proper > zone/node links and the pages that are not spanned by any node will get > links to the adjacent zone/node. Does this include pages in the last section has handled by ... ... > - /* > - * Early sections always have a fully populated memmap for the whole > - * section - see pfn_valid(). If the last section has holes at the > - * end and that section is marked "online", the memmap will be > - * considered initialized. Make sure that memmap has a well defined > - * state. > - */ > - pgcnt += init_unavailable_range(PFN_DOWN(next), > - round_up(max_pfn, PAGES_PER_SECTION)); > - ^ this code? Or how is that case handled now? -- Thanks, David / dhildenb