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 CD782C433EF for ; Tue, 5 Jul 2022 12:11:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3B5FF6B0071; Tue, 5 Jul 2022 08:11:28 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 365956B0073; Tue, 5 Jul 2022 08:11:28 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 22CAC6B0074; Tue, 5 Jul 2022 08:11:28 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 1124D6B0071 for ; Tue, 5 Jul 2022 08:11:28 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id C65F9357D4 for ; Tue, 5 Jul 2022 12:11:27 +0000 (UTC) X-FDA: 79652931414.12.BC03A5C Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf20.hostedemail.com (Postfix) with ESMTP id 518B91C0057 for ; Tue, 5 Jul 2022 12:11:26 +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 dfw.source.kernel.org (Postfix) with ESMTPS id 4B17661985; Tue, 5 Jul 2022 12:11:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CAC7DC341C7; Tue, 5 Jul 2022 12:11:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1657023083; bh=xx894h8t9r1HogxTqBUnJmpp/M0AqILhNb+ZPL3THQI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=uNgKo6jhuJULh+DvqMhsjgsekzUkkZNVWMvDYYA7ntWZLbKRAdWvfd+gACcAYbp0I dCQCNLJmnQuguvCTAzBvi6G5wQv44m2QfmvRb2BRJ1mOts4bwJQwzBW9LmPZMWM0v9 KgqYBmAWhJHn6XGLqhd8L1t+BwyQKfVps44h0Y+N96Wn/9LVV2/F0Y8uD9V2VHh7tY wBPuTJioL8OeAgSd2sS1zNyh5XfOu6vwDuShC/LKO/6ERm4BT02FcEZpdi/RAhMrUb cYkBHwYGzp5iKewKqfrHyOoieY6FijI/hjrGVShMSwM0qHUq6S8DcrbG9px0DirWPK NxoDdLggB8MEg== Date: Tue, 5 Jul 2022 13:11:16 +0100 From: Will Deacon To: "guanghui.fgh" Cc: Ard Biesheuvel , baolin.wang@linux.alibaba.com, catalin.marinas@arm.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, rppt@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: <20220705121115.GB1012@willie-the-truck> References: <20220704111402.GA31553@willie-the-truck> <4accaeda-572f-f72d-5067-2d0999e4d00a@linux.alibaba.com> <20220704131516.GC31684@willie-the-truck> <2ae1cae0-ee26-aa59-7ed9-231d67194dce@linux.alibaba.com> <20220704142313.GE31684@willie-the-truck> <6977c692-78ca-5a67-773e-0389c85f2650@linux.alibaba.com> <20220704163815.GA32177@willie-the-truck> <20220705095231.GB552@willie-the-truck> <5d044fdd-a61a-d60f-d294-89e17de37712@linux.alibaba.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <5d044fdd-a61a-d60f-d294-89e17de37712@linux.alibaba.com> User-Agent: Mutt/1.10.1 (2018-07-13) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1657023086; 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:dkim-signature; bh=pYaC70dkIq7stew2HU9cHNO7GP6M6CR195L+h0FQcJU=; b=G08xeeNDa6kGOltiZTLhTyc+KCYE0XZ8LGoOfpS+FdWFGRSKNJ4pa3csCOm+NWvqJ3x2ao XasS/fcupQTLYshgex9Sw9dbVCzKJ2d0Q/rvlcvTWB6X8hSXBoNK1uzfus0u0R2sczzfR5 yjbzruLmEYRBro4pceYsJhv6XAY0RHw= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=uNgKo6jh; spf=pass (imf20.hostedemail.com: domain of will@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=will@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1657023086; a=rsa-sha256; cv=none; b=lttO5DU0Nt+lq0TZCtQb0IQjWu3lgMQ9MHFN3vS9ZDAfYris6Krqbjwdw1S276ys+7Jxvb WeHOqJHf6wWyeI63Hh0TU2TqfT72gjBcDKzpNnM+knQwuoWGoZpvTXUYHo8nQaHTNBYwcP TzOSxCpq8pKyfB9Di5Ku6ctIPU57yoc= X-Stat-Signature: g4bju1tp8ih5p6iqkac97ydhrowa9sn6 X-Rspamd-Queue-Id: 518B91C0057 Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=uNgKo6jh; spf=pass (imf20.hostedemail.com: domain of will@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=will@kernel.org; dmarc=pass (policy=none) header.from=kernel.org X-Rspam-User: X-Rspamd-Server: rspam02 X-HE-Tag: 1657023086-35410 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 Tue, Jul 05, 2022 at 08:07:07PM +0800, guanghui.fgh wrote: > > > 在 2022/7/5 17:52, Will Deacon 写道: > > On Mon, Jul 04, 2022 at 07:09:23PM +0200, Ard Biesheuvel wrote: > > > On Mon, 4 Jul 2022 at 18:38, Will Deacon wrote: > > > > > > > > On Mon, Jul 04, 2022 at 10:34:07PM +0800, guanghui.fgh wrote: > > > > > Thanks. > > > > > > > > > > 在 2022/7/4 22:23, Will Deacon 写道: > > > > > > On Mon, Jul 04, 2022 at 10:11:27PM +0800, guanghui.fgh wrote: > > > ... > > > > > > > Namely, it's need to use non block/section mapping for crashkernel mem > > > > > > > before shringking. > > > > > > > > > > > > Well, yes, but we can change arch_kexec_[un]protect_crashkres() not to do > > > > > > that if we're leaving the thing mapped, no? > > > > > > > > > > > I think we should use arch_kexec_[un]protect_crashkres for crashkernel mem. > > > > > > > > > > Because when invalid crashkernel mem pagetable, there is no chance to rd/wr > > > > > the crashkernel mem by mistake. > > > > > > > > > > If we don't use arch_kexec_[un]protect_crashkres to invalid crashkernel mem > > > > > pagetable, there maybe some write operations to these mem by mistake which > > > > > may cause crashkernel boot error and vmcore saving error. > > > > > > > > I don't really buy this line of reasoning. The entire main kernel is > > > > writable, so why do we care about protecting the crashkernel so much? The > > > > _code_ to launch the crash kernel is writable! If you care about preventing > > > > writes to memory which should not be writable, then you should use > > > > rodata=full. > > > > > > > > > > This is not entirely true - the core kernel text and rodata are > > > remapped r/o in the linear map, whereas all module code and rodata are > > > left writable when rodata != full. > > > > Yes, sorry, you're quite right. The kernel text is only writable if > > rodata=off. > > > > But I still think it makes sense to protect the crashkernel only if > > rodata=full (which is the default on arm64) as this allows us to rely > > on page mappings and I think fits well with what we do for modules. > > > > > But the conclusion is the same, imo: if you can't be bothered to > > > protect a good chunk of the code and rodata that the kernel relies on, > > > why should the crashkernel be treated any differently? > > > > Thanks. > > > > Will > Thanks. > > 1.The rodata full is harm to the performance and has been disabled in-house. > > 2.When using crashkernel with rodata non full, the kernel also will use non > block/section mapping which cause high d-TLB miss and degrade performance > greatly. > This patch fix it to use block/section mapping as far as possible. > > bool can_set_direct_map(void) > { > return rodata_full || debug_pagealloc_enabled(); > } > > map_mem: > if (can_set_direct_map() || IS_ENABLED(CONFIG_KFENCE)) > flags |= NO_BLOCK_MAPPINGS | NO_CONT_MAPPINGS; > > 3.When rodata full is disabled, crashkernel also need protect(keep > arch_kexec_[un]protect_crashkres using). > I think crashkernel should't depend on radata full(Maybe other architecture > don't support radata full now). I think this is going round in circles :/ As a first step, can we please leave the crashkernel mapped unless rodata=full? It should be a much simpler patch to write, review and maintain and it gives you the performance you want when crashkernel is being used. Will