Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp508122pxb; Wed, 27 Jan 2021 13:21:15 -0800 (PST) X-Google-Smtp-Source: ABdhPJwNqiH13bODDsSSWmkpAZr+rFU0p9KHWmZQ7sWfpdEAQkIsAL4Ol84B9VtZVcLmgkrO0b9J X-Received: by 2002:a50:9f65:: with SMTP id b92mr10744025edf.74.1611782474822; Wed, 27 Jan 2021 13:21:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611782474; cv=none; d=google.com; s=arc-20160816; b=aOz/JvoDcqBmNCemIxq80C6Gff8Kym0RjvtlrBZelE3bUyU/9RqcXoeFyQfE+GGmR9 /HquorW9hO7iZxgBUxMEvpF1IBb0D0yv1IfSCavf0h9pOgveiwU6Cw6wCMzqJTkOjPsj aSBYpK2nJ1AoHqLLEjmvco6s/QGTiBxG/aCTh4eOKRahEctauazR+gML7ypa4SaLZjM6 H7vfNsqSWAYqC/LKjB5Jz6ARkTSIL4GFZCfYfCwFKzh9lZfjfm8mB/PJMDKS7f2XHta5 FcGGillfq55QEGILjfT5I8vV2xp+bHoNCl/QHkGeGpwK9ttlw5rZVlQkqD3b03SCL7UL C9qQ== 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:from:references :cc:to:subject; bh=DGOOiRPFYIUnZtqLJ3gMUQZ5RSFNqcoLhDvAwkwh/QE=; b=GmVHeNB0sxxeKUPxBcXzDlY9P6fi2lF+s0VTQy6TnT4n0WcrMYfeMIjWpSgQoDOIlS kTki4hxpJ5M+UAdOMcLJL6ZNJXp+KVuOS/b78eM/bkIHQYw+Wqz9yKjPnhDLXrrQXPne 7xw4C1Bykymm1WIevUJ5KaXgsiSWAR5NGyFS0nYldwfp3iXZfAL3El88YUUyoOKc9IM4 80P8bnOdUZIVNX19g/ArnLPULnOhrYf29sRBxXG36hrk641um0BWLYhnUGm50+1BX/Km Nw0f0MsWHtviSGy0RNTfCHY2KdA5OPDIfVNdoYJDU67t3Nr7HBlrIM1u78fxkgPPJcn0 A8mA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a20si1404451ejv.169.2021.01.27.13.20.49; Wed, 27 Jan 2021 13:21:14 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234908AbhA0GDQ (ORCPT + 99 others); Wed, 27 Jan 2021 01:03:16 -0500 Received: from foss.arm.com ([217.140.110.172]:46828 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237105AbhA0DrR (ORCPT ); Tue, 26 Jan 2021 22:47:17 -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 32EF0139F; Tue, 26 Jan 2021 19:46:26 -0800 (PST) Received: from [192.168.0.130] (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 3105B3F66B; Tue, 26 Jan 2021 19:46:21 -0800 (PST) Subject: Re: [RFC 1/2] arm64/mm: Fix pfn_valid() for ZONE_DEVICE based memory To: Mike Rapoport Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, catalin.marinas@arm.com, will@kernel.org, ardb@kernel.org, Mark Rutland , James Morse , Robin Murphy , =?UTF-8?B?SsOpcsO0bWUgR2xpc3Nl?= , Dan Williams , David Hildenbrand References: <1608621144-4001-1-git-send-email-anshuman.khandual@arm.com> <1608621144-4001-2-git-send-email-anshuman.khandual@arm.com> <20210125073102.GF7648@linux.ibm.com> From: Anshuman Khandual Message-ID: <42e9d8cc-ea8a-7a95-c3d4-232cd362547b@arm.com> Date: Wed, 27 Jan 2021 09:16:42 +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: <20210125073102.GF7648@linux.ibm.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 1/25/21 1:01 PM, Mike Rapoport wrote: > On Mon, Jan 25, 2021 at 11:52:32AM +0530, Anshuman Khandual wrote: >> >> 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. > > I didn't object to these patches, I think they are fine. > I agree that we can look into update of arm64's pfn_valid(), maybe right > after decrease of section size lands in. Sure, will drop the RFC tag and prepare these patches.