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=-10.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,MAILING_LIST_MULTI, NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=unavailable 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 058B9C433DB for ; Mon, 25 Jan 2021 06:45:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C041B224DE for ; Mon, 25 Jan 2021 06:44:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727165AbhAYGol (ORCPT ); Mon, 25 Jan 2021 01:44:41 -0500 Received: from foss.arm.com ([217.140.110.172]:42790 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726371AbhAYGW6 (ORCPT ); Mon, 25 Jan 2021 01:22:58 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 1ED921FB; Sun, 24 Jan 2021 22:22:12 -0800 (PST) Received: from [10.163.91.197] (unknown [10.163.91.197]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 2CBBC3F66B; Sun, 24 Jan 2021 22:22:07 -0800 (PST) Subject: Re: [RFC 1/2] arm64/mm: Fix pfn_valid() for ZONE_DEVICE based memory To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: catalin.marinas@arm.com, will@kernel.org, ardb@kernel.org, Mark Rutland , James Morse , Robin Murphy , =?UTF-8?B?SsOpcsO0bWUgR2xpc3Nl?= , Dan Williams , David Hildenbrand , Mike Rapoport References: <1608621144-4001-1-git-send-email-anshuman.khandual@arm.com> <1608621144-4001-2-git-send-email-anshuman.khandual@arm.com> From: Anshuman Khandual Message-ID: Date: Mon, 25 Jan 2021 11:52:32 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <1608621144-4001-2-git-send-email-anshuman.khandual@arm.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 12/22/20 12:42 PM, Anshuman Khandual wrote: > pfn_valid() asserts that there is a memblock entry for a given pfn without > MEMBLOCK_NOMAP flag being set. The problem with ZONE_DEVICE based memory is > that they do not have memblock entries. Hence memblock_is_map_memory() will > invariably fail via memblock_search() for a ZONE_DEVICE based address. This > eventually fails pfn_valid() which is wrong. memblock_is_map_memory() needs > to be skipped for such memory ranges. As ZONE_DEVICE memory gets hotplugged > into the system via memremap_pages() called from a driver, their respective > memory sections will not have SECTION_IS_EARLY set. > > Normal hotplug memory will never have MEMBLOCK_NOMAP set in their memblock > regions. Because the flag MEMBLOCK_NOMAP was specifically designed and set > for firmware reserved memory regions. memblock_is_map_memory() can just be > skipped as its always going to be positive and that will be an optimization > for the normal hotplug memory. Like ZONE_DEVIE based memory, all hotplugged > normal memory too will not have SECTION_IS_EARLY set for their sections. > > Skipping memblock_is_map_memory() for all non early memory sections would > fix pfn_valid() problem for ZONE_DEVICE based memory and also improve its > performance for normal hotplug memory as well. > > Cc: Catalin Marinas > Cc: Will Deacon > Cc: Ard Biesheuvel > Cc: Robin Murphy > Cc: linux-arm-kernel@lists.infradead.org > Cc: linux-kernel@vger.kernel.org > Fixes: 73b20c84d42d ("arm64: mm: implement pte_devmap support") > Signed-off-by: Anshuman Khandual Hello David/Mike, Given that we would need to rework early sections, memblock semantics via a new config i.e EARLY_SECTION_MEMMAP_HOLES and also some possible changes to ARCH_KEEP_MEMBLOCK and HAVE_ARCH_PFN_VALID, wondering if these patches here which fixes a problem (and improves performance) can be merged first. After that, I could start working on the proposed rework. Could you please let me know your thoughts on this. Thank you. - Anshuman