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=-3.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no 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 CD0AEC433B4 for ; Thu, 22 Apr 2021 07:30:11 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 32315613DE for ; Thu, 22 Apr 2021 07:30:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 32315613DE Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 84A9A6B006C; Thu, 22 Apr 2021 03:30:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7FB2E6B006E; Thu, 22 Apr 2021 03:30:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 674E46B0070; Thu, 22 Apr 2021 03:30:10 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0085.hostedemail.com [216.40.44.85]) by kanga.kvack.org (Postfix) with ESMTP id 479D46B006C for ; Thu, 22 Apr 2021 03:30:10 -0400 (EDT) Received: from smtpin23.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id EA1A13CF6 for ; Thu, 22 Apr 2021 07:30:09 +0000 (UTC) X-FDA: 78059179338.23.6077A75 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf25.hostedemail.com (Postfix) with ESMTP id 17F8B6000128 for ; Thu, 22 Apr 2021 07:30:05 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id 997EC6145E; Thu, 22 Apr 2021 07:29:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1619076603; bh=GvHLrkjv+8OSfv0DFhto7kn97jmH4HlTtc9KLl6FFu4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=EEdSmllRyEg3GlL6fG+QQxGmjjh8mn5FNwFOz2dK6HPHJ1DKQtONjppKpwZX6WwKm zTUBFONStme9eAX5Yp/tucFTyfUDifV52Jvk8/tweFJz5h0Tkur33U7zK+IqoecPxG AfclCDbDXzUtfM6wF4InX3oVYpnK3IIedrZy4BeCuEOvfnQaXLluNnvDW/cOCMdHUN 4Du5U0a0uJxKBTiXnTTi1OhiOY2WwDNVY3ruGLAnY3bsSS+D0zn0jgIrIGIWA+2518 UgTkkoL86MmFKi0SjMPoGNYnwfLu3Ag78kGee/2AQLjNwy7ccbIGvoODA1pjeLgfdb KGl0OzJVIPfZA== Date: Thu, 22 Apr 2021 10:29:53 +0300 From: Mike Rapoport To: Kefeng Wang Cc: linux-arm-kernel@lists.infradead.org, Andrew Morton , Anshuman Khandual , Ard Biesheuvel , Catalin Marinas , David Hildenbrand , Marc Zyngier , Mark Rutland , Mike Rapoport , Will Deacon , kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH v2 0/4] arm64: drop pfn_valid_within() and simplify pfn_valid() Message-ID: References: <20210421065108.1987-1-rppt@kernel.org> <9aa68d26-d736-3b75-4828-f148964eb7f0@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <9aa68d26-d736-3b75-4828-f148964eb7f0@huawei.com> X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 17F8B6000128 X-Stat-Signature: ozxujaua4fjwn5m51ok6msz55ity53m9 Received-SPF: none (kernel.org>: No applicable sender policy available) receiver=imf25; identity=mailfrom; envelope-from=""; helo=mail.kernel.org; client-ip=198.145.29.99 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1619076605-417238 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: On Thu, Apr 22, 2021 at 03:00:20PM +0800, Kefeng Wang wrote: >=20 > On 2021/4/21 14:51, Mike Rapoport wrote: > > From: Mike Rapoport > >=20 > > Hi, > >=20 > > These patches aim to remove CONFIG_HOLES_IN_ZONE and essentially hard= wire > > pfn_valid_within() to 1. > >=20 > > The idea is to mark NOMAP pages as reserved in the memory map and res= tore > > the intended semantics of pfn_valid() to designate availability of st= ruct > > page for a pfn. > >=20 > > With this the core mm will be able to cope with the fact that it cann= ot use > > NOMAP pages and the holes created by NOMAP ranges within MAX_ORDER bl= ocks > > will be treated correctly even without the need for pfn_valid_within. > >=20 > > The patches are only boot tested on qemu-system-aarch64 so I'd really > > appreciate memory stress tests on real hardware. > >=20 > > If this actually works we'll be one step closer to drop custom pfn_va= lid() > > on arm64 altogether. >=20 > Hi Mike=EF=BC=8CI have a question, without HOLES_IN_ZONE, the pfn_valid= _within() in > move_freepages_block()->move_freepages() > will be optimized, if there are holes in zone, the 'struce page'(memory= map) > for pfn range of hole will be free by > free_memmap(), and then the page traverse in the zone(with holes) from > move_freepages() will meet the wrong page=EF=BC=8C > then it could panic at PageLRU(page) test, check link[1], First, HOLES_IN_ZONE name us hugely misleading, this configuration option has nothing to to with memory holes, but rather it is there to deal with holes or undefined struct pages in the memory map, when these holes can b= e inside a MAX_ORDER_NR_PAGES region. In general pfn walkers use pfn_valid() and pfn_valid_within() to avoid accessing *missing* struct pages, like those that are freed at free_memmap(). But on arm64 these tests also filter out the nomap entries because their struct pages are not initialized. The panic you refer to happened because there was an uninitialized struct page in the middle of MAX_ORDER_NR_PAGES region because it corresponded t= o nomap memory. With these changes I make sure that such pages will be properly initializ= ed as PageReserved and the pfn walkers will be able to rely on the memory ma= p. Note also, that free_memmap() aligns the parts being freed on MAX_ORDER boundaries, so there will be no missing parts in the memory map within a MAX_ORDER_NR_PAGES region. =20 > "The idea is to mark NOMAP pages as reserved in the memory map", I see = the > patch2 check memblock_is_nomap() in memory region > of memblock, but it seems that memblock_mark_nomap() is not called(mayb= e I > missed), then memmap_init_reserved_pages() won't > work, so should the HOLES_IN_ZONE still be needed for generic mm code? >=20 > [1] https://lore.kernel.org/linux-arm-kernel/541193a6-2bce-f042-5bb2-88= 913d5f1047@arm.com/ >=20 --=20 Sincerely yours, Mike.