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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 420C1C43334 for ; Thu, 7 Jul 2022 17:02:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A513D6B0072; Thu, 7 Jul 2022 13:02:47 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A020A6B0073; Thu, 7 Jul 2022 13:02:47 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8C92E6B0074; Thu, 7 Jul 2022 13:02:47 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 7F5486B0072 for ; Thu, 7 Jul 2022 13:02:47 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 51BFE60FDA for ; Thu, 7 Jul 2022 17:02:47 +0000 (UTC) X-FDA: 79660923174.21.B84BFF0 Received: from out30-57.freemail.mail.aliyun.com (out30-57.freemail.mail.aliyun.com [115.124.30.57]) by imf28.hostedemail.com (Postfix) with ESMTP id 5494CC0065 for ; Thu, 7 Jul 2022 17:02:44 +0000 (UTC) X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R201e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018045168;MF=guanghuifeng@linux.alibaba.com;NM=1;PH=DS;RN=21;SR=0;TI=SMTPD_---0VIefA1B_1657213358; Received: from 30.39.247.202(mailfrom:guanghuifeng@linux.alibaba.com fp:SMTPD_---0VIefA1B_1657213358) by smtp.aliyun-inc.com; Fri, 08 Jul 2022 01:02:40 +0800 Message-ID: Date: Fri, 8 Jul 2022 01:02:37 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: [PATCH v4] arm64: mm: fix linear mem mapping access performance degradation To: Catalin Marinas Cc: Mike Rapoport , Will Deacon , Ard Biesheuvel , baolin.wang@linux.alibaba.com, akpm@linux-foundation.org, david@redhat.com, jianyong.wu@arm.com, james.morse@arm.com, quic_qiancai@quicinc.com, christophe.leroy@csgroup.eu, jonathan@marek.ca, mark.rutland@arm.com, thunder.leizhen@huawei.com, anshuman.khandual@arm.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, geert+renesas@glider.be, linux-mm@kvack.org, yaohongbo@linux.alibaba.com, alikernel-developer@linux.alibaba.com References: <5d044fdd-a61a-d60f-d294-89e17de37712@linux.alibaba.com> <20220705121115.GB1012@willie-the-truck> <9974bea5-4db9-0104-c9c9-d9b49c390f1b@linux.alibaba.com> From: "guanghui.fgh" In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1657213366; a=rsa-sha256; cv=none; b=a/xP8QaVQDcOxdCnc8QWYTHUcEN1S1rrs6C3Ggv+d2COvhFagxRj8JgPfUNkTgAfFQeiGu 9UdBGxmeHVbd83mUpwjCj1ziZJnOZOwq9mx2dbxRefQ16NFQTdM8JNQhJsn/UpPXGrrqII G4G53NH+B3eFA5ZF9p0nap3SuXawHwk= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=alibaba.com; spf=pass (imf28.hostedemail.com: domain of guanghuifeng@linux.alibaba.com designates 115.124.30.57 as permitted sender) smtp.mailfrom=guanghuifeng@linux.alibaba.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1657213366; h=from:from:sender: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=Z8OVr/JxxLUaZ2Tom5aefgWydJ6CjhRuK2Jchos8OqA=; b=ASFlSETqetSQ7CKLroanfiG7FmQF1cSbCwQ7THvUOPvUr8lCfuKp8wVvCgSg1+wGwQmAm6 8GklGDmKgWh+OPIf8IWlZiRmY0qsxlQRUMKOg1ocIJbUcnzMozvPL66+SdOz8Ax+0iNfiH jLPKiew8KpIsLgUs3OwzwrikZEQIV/I= Authentication-Results: imf28.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=alibaba.com; spf=pass (imf28.hostedemail.com: domain of guanghuifeng@linux.alibaba.com designates 115.124.30.57 as permitted sender) smtp.mailfrom=guanghuifeng@linux.alibaba.com X-Stat-Signature: 43uu4j4g8kda4swr8u3kufn7sexj8i9w X-Rspamd-Queue-Id: 5494CC0065 X-Rspamd-Server: rspam05 X-Rspam-User: X-HE-Tag: 1657213364-960053 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: Thanks. 在 2022/7/6 23:40, Catalin Marinas 写道: > On Wed, Jul 06, 2022 at 11:18:22PM +0800, guanghui.fgh wrote: >> 在 2022/7/6 21:54, Mike Rapoport 写道: >>> One thing I can think of is to only remap the crash kernel memory if it is >>> a part of an allocation that exactly fits into one ore more PUDs. >>> >>> Say, in reserve_crashkernel() we try the memblock_phys_alloc() with >>> PUD_SIZE as alignment and size rounded up to PUD_SIZE. If this allocation >>> succeeds, we remap the entire area that now contains only memory allocated >>> in reserve_crashkernel() and free the extra memory after remapping is done. >>> If the large allocation fails, we fall back to the original size and >>> alignment and don't allow unmapping crash kernel memory in >>> arch_kexec_protect_crashkres(). >> >> There is a new method. >> I think we should use the patch v3(similar but need add some changes) >> >> 1.We can walk crashkernle block/section pagetable, >> [[[(keep the origin block/section mapping valid]]] >> rebuild the pte level page mapping for the crashkernel mem >> rebuild left & right margin mem(which is in same block/section mapping but >> out of crashkernel mem) with block/section mapping >> >> 2.'replace' the origin block/section mapping by new builded mapping >> iterately >> >> With this method, all the mem mapping keep valid all the time. > > As I already commented on one of your previous patches, this is not > allowed by the architecture. If FEAT_BBM is implemented (ARMv8.4 I > think), the worst that can happen is a TLB conflict abort and the > handler should invalidate the TLBs and restart the faulting instruction, > assuming the handler won't try to access the same conflicting virtual > address. Prior to FEAT_BBM, that's not possible as the architecture does > not describe a precise behaviour of conflicting TLB entries (you might > as well get the TLB output of multiple entries being or'ed together). > I think there is another way to handle it. 1.We can rebuild the crashkernel mem mapping firstly, but [[[don't change the origin linear mapping]]]. 2.Afterward, we can reuse the idmap_pg_dir and switch to it. We use idmap_pg_dir to change the linear mapping which complyes with the TLB BBM.