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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 614ABC43334 for ; Wed, 6 Jul 2022 15:42:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=0AmPt9jQirELZZCEyTlxgYcdDEfuF572V3flVueDIPo=; b=YEuJk2G1Y++S/Y KM+N+LkMbK51EblYUyakBaZXlPeM7mbZYvTUSMvBR9QRYpgGWMe/gdSmlJ+K+S0jouoeAPalQHfu1 dvkA3mgyArIDh/MTNaDwcg179MdF+4Vr1/gw4TMJ5BKh27+b3euLhtmbt6ttcQeK7v3nQWKKUW6J4 Sb6vI3uVtCx3U7T10ELUYOliUFNCtIXLH72o7phCN/Hc+8mRhiA7iiqT8RSTvDDr6kr3kUIQz5C9C 1Uo5chjS/2kPq6bVX71lzDGNmFF+Y6VODju2XRzJ9hfmbb85FnB2yKQawr1tvJ2oChEx4hotsJFzM S1brWGCP6GJMl6ZyOn0w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1o979K-00B6pj-Q6; Wed, 06 Jul 2022 15:41:10 +0000 Received: from ams.source.kernel.org ([2604:1380:4601:e00::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1o979H-00B6ni-1L for linux-arm-kernel@lists.infradead.org; Wed, 06 Jul 2022 15:41:08 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id D4D3CB81AF1; Wed, 6 Jul 2022 15:41:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E284AC3411C; Wed, 6 Jul 2022 15:40:59 +0000 (UTC) Date: Wed, 6 Jul 2022 16:40:56 +0100 From: Catalin Marinas To: "guanghui.fgh" 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 Subject: Re: [PATCH v4] arm64: mm: fix linear mem mapping access performance degradation Message-ID: References: <5d044fdd-a61a-d60f-d294-89e17de37712@linux.alibaba.com> <20220705121115.GB1012@willie-the-truck> <9974bea5-4db9-0104-c9c9-d9b49c390f1b@linux.alibaba.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <9974bea5-4db9-0104-c9c9-d9b49c390f1b@linux.alibaba.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220706_084107_260072_85091040 X-CRM114-Status: GOOD ( 22.47 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: base64 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org T24gV2VkLCBKdWwgMDYsIDIwMjIgYXQgMTE6MTg6MjJQTSArMDgwMCwgZ3VhbmdodWkuZmdoIHdy b3RlOgo+IOWcqCAyMDIyLzcvNiAyMTo1NCwgTWlrZSBSYXBvcG9ydCDlhpnpgZM6Cj4gPiBPbmUg dGhpbmcgSSBjYW4gdGhpbmsgb2YgaXMgdG8gb25seSByZW1hcCB0aGUgY3Jhc2gga2VybmVsIG1l bW9yeSBpZiBpdCBpcwo+ID4gYSBwYXJ0IG9mIGFuIGFsbG9jYXRpb24gdGhhdCBleGFjdGx5IGZp dHMgaW50byBvbmUgb3JlIG1vcmUgUFVEcy4KPiA+IAo+ID4gU2F5LCBpbiByZXNlcnZlX2NyYXNo a2VybmVsKCkgd2UgdHJ5IHRoZSBtZW1ibG9ja19waHlzX2FsbG9jKCkgd2l0aAo+ID4gUFVEX1NJ WkUgYXMgYWxpZ25tZW50IGFuZCBzaXplIHJvdW5kZWQgdXAgdG8gUFVEX1NJWkUuIElmIHRoaXMg YWxsb2NhdGlvbgo+ID4gc3VjY2VlZHMsIHdlIHJlbWFwIHRoZSBlbnRpcmUgYXJlYSB0aGF0IG5v dyBjb250YWlucyBvbmx5IG1lbW9yeSBhbGxvY2F0ZWQKPiA+IGluIHJlc2VydmVfY3Jhc2hrZXJu ZWwoKSBhbmQgZnJlZSB0aGUgZXh0cmEgbWVtb3J5IGFmdGVyIHJlbWFwcGluZyBpcyBkb25lLgo+ ID4gSWYgdGhlIGxhcmdlIGFsbG9jYXRpb24gZmFpbHMsIHdlIGZhbGwgYmFjayB0byB0aGUgb3Jp Z2luYWwgc2l6ZSBhbmQKPiA+IGFsaWdubWVudCBhbmQgZG9uJ3QgYWxsb3cgdW5tYXBwaW5nIGNy YXNoIGtlcm5lbCBtZW1vcnkgaW4KPiA+IGFyY2h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poYW5kbGVyIHNob3VsZCBpbnZhbGlkYXRlIHRoZSBUTEJzIGFuZCByZXN0 YXJ0IHRoZSBmYXVsdGluZyBpbnN0cnVjdGlvbiwKYXNzdW1pbmcgdGhlIGhhbmRsZXIgd29uJ3Qg dHJ5IHRvIGFjY2VzcyB0aGUgc2FtZSBjb25mbGljdGluZyB2aXJ0dWFsCmFkZHJlc3MuIFByaW9y IHRvIEZFQVRfQkJNLCB0aGF0J3Mgbm90IHBvc3NpYmxlIGFzIHRoZSBhcmNoaXRlY3R1cmUgZG9l cwpub3QgZGVzY3JpYmUgYSBwcmVjaXNlIGJlaGF2aW91ciBvZiBjb25mbGljdGluZyBUTEIgZW50 cmllcyAoeW91IG1pZ2h0CmFzIHdlbGwgZ2V0IHRoZSBUTEIgb3V0cHV0IG9mIG11bHRpcGxlIGVu dHJpZXMgYmVpbmcgb3InZWQgdG9nZXRoZXIpLgoKLS0gCkNhdGFsaW4KCl9fX19fX19fX19fX19f X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fCmxpbnV4LWFybS1rZXJuZWwgbWFpbGlu ZyBsaXN0CmxpbnV4LWFybS1rZXJuZWxAbGlzdHMuaW5mcmFkZWFkLm9yZwpodHRwOi8vbGlzdHMu aW5mcmFkZWFkLm9yZy9tYWlsbWFuL2xpc3RpbmZvL2xpbnV4LWFybS1rZXJuZWwK 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 3F615C43334 for ; Wed, 6 Jul 2022 15:41:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BEC186B0071; Wed, 6 Jul 2022 11:41:07 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B9BA36B0073; Wed, 6 Jul 2022 11:41:07 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AB13C6B0074; Wed, 6 Jul 2022 11:41:07 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 9CBF46B0071 for ; Wed, 6 Jul 2022 11:41:07 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 642E220ADD for ; Wed, 6 Jul 2022 15:41:07 +0000 (UTC) X-FDA: 79657088574.16.005F426 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf11.hostedemail.com (Postfix) with ESMTP id D9DE140030 for ; Wed, 6 Jul 2022 15:41:06 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id D4D3CB81AF1; Wed, 6 Jul 2022 15:41:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E284AC3411C; Wed, 6 Jul 2022 15:40:59 +0000 (UTC) Date: Wed, 6 Jul 2022 16:40:56 +0100 From: Catalin Marinas To: "guanghui.fgh" 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 Subject: Re: [PATCH v4] arm64: mm: fix linear mem mapping access performance degradation Message-ID: References: <5d044fdd-a61a-d60f-d294-89e17de37712@linux.alibaba.com> <20220705121115.GB1012@willie-the-truck> <9974bea5-4db9-0104-c9c9-d9b49c390f1b@linux.alibaba.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <9974bea5-4db9-0104-c9c9-d9b49c390f1b@linux.alibaba.com> ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1657122067; a=rsa-sha256; cv=none; b=TJpY29WkYCVgMwVhHoXwzHNpcNC+4tLr5vabHiMShS+ylFhutG7+puC9IPeONNcWKEDkYT ivpSorLhjnv+yytfgwvpkput8UBJIv3J+Dr85OEpx+BNtxVIL9kWAtZ6eMKuDEcAGIPxvm RPOq9Y063PXSSG/ihaxfql2HAFjCOm4= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=arm.com (policy=none); spf=pass (imf11.hostedemail.com: domain of cmarinas@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=cmarinas@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1657122067; 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=eIpaEbFJ5/d8nnqtuan+T4qnfUxaGf2HhtBexsCYVhc=; b=pMKdT+rFKY55YaRrNcIZaY3Q8HhLdCSCOI2XHyM5NDAmIDTLcQqu8esEIledWdpkq/0dKr Tb7QYCrrSVcQy6nEDVkMMFX4uTE1+r4a8MasyY0rkmHlcLv33KsZdv67eo7h2lwbyyohwn Mv12YDujpFaq7RpuxXaE5liMdSDrYIY= X-Stat-Signature: a7pyef1iphhb7paduk9nqe9skfzrqitk X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: D9DE140030 Authentication-Results: imf11.hostedemail.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=arm.com (policy=none); spf=pass (imf11.hostedemail.com: domain of cmarinas@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=cmarinas@kernel.org X-HE-Tag: 1657122066-604707 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 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). -- Catalin