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 18EF5C46467 for ; Thu, 12 Jan 2023 02:58:14 +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:From:References:Cc:To: Subject:MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=QKCs+zjkhBEtemp0pa4XQ3W+z2Ou/MOgJzzGotLFIKg=; b=TO+U11xjXZwHdd urX5bj2DlrgtAq9JuIDjoPY74qor3fT1bnYxdJogfFzr5om3mpvLvMtI3+z6oLqIkGQKumb2JFtKV 2t4r+YbzhznWOCIby7M07lFLg5Z0ARlEGr3StXhuUZAXOtlGa3a7mVUTd1J+5IiUEFVKpu+EgLXbw Y1Zf0+Lj7XCpoGWbw7LUC8mzukM5MC8Vvf1DSYiGZyXU3b81yyEMxBkkIMYpR8mZvJyHU9ZbO6URG wYcRXcB+n2rcD9/SDlqFByRH/h2nS0mPxt0CwmQ7DuQHmKD6GDMKTu1V8pq50pOhXBXhmN4lqYe4h kjjrpTmAwy71jg2hXV8g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pFnmF-00DWV5-Ej; Thu, 12 Jan 2023 02:57:15 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pFnmB-00DWUS-MA for linux-arm-kernel@lists.infradead.org; Thu, 12 Jan 2023 02:57:13 +0000 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 10118FEC; Wed, 11 Jan 2023 18:57:50 -0800 (PST) Received: from [10.162.41.9] (unknown [10.162.41.9]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E18713F67D; Wed, 11 Jan 2023 18:57:05 -0800 (PST) Message-ID: Date: Thu, 12 Jan 2023 08:27:02 +0530 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.2 Subject: Re: [PATCH v2] arm64: Avoid repeated AA64MMFR1_EL1 register read on pagefault path Content-Language: en-US To: Gabriel Krisman Bertazi , Anshuman Khandual Cc: catalin.marinas@arm.com, will@kernel.org, linux-arm-kernel@lists.infradead.org, broonie@kernel.org References: <20230109151955.8292-1-krisman@suse.de> <25058f6d-a434-6166-7a9d-1ee7f98130a3@arm.com> <87pmbldwpi.fsf@suse.de> From: Anshuman Khandual In-Reply-To: <87pmbldwpi.fsf@suse.de> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230111_185711_855622_0CA8F3C6 X-CRM114-Status: GOOD ( 20.46 ) 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="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 1/11/23 19:01, Gabriel Krisman Bertazi wrote: > Anshuman Khandual writes: > >> On 1/9/23 20:49, Gabriel Krisman Bertazi wrote: >>> Accessing AA64MMFR1_EL1 is expensive in KVM guests, since it is emulated >>> in the hypervisor. In fact, ARM documentation mentions some feature >>> registers are not supposed to be accessed frequently by the OS, and >>> therefore should be emulated for guests [1]. >> >> I am just curious, is this the only system register access (AA64MMFR1_EL1) >> causing such performance problems ? > > I haven't audited all the system registers. For AA64MMFR1_EL1 this is > the only instance where the frequency of access affects performance in a > meaningful way for my workload. > > I have a real-world bug report about it, and by profiling vm exit > events, I can also argue this is the only instance of any emulated msr > read/write that happens frequently enough to change the order of > magnitude of exit events measured by perf for my workload between, at > least, 5.4 (it was introduced in v5.12, but I have data back to 5.4) and > mainline. > >>> Commit 0388f9c74330 ("arm64: mm: Implement >>> arch_wants_old_prefaulted_pte()") introduced a read of this register in >>> the page fault path. But, even when the feature of setting faultaround >> >> Right, although cpu_has_hw_af() was added earlier via commit 47d7b15b88f9 >> ("arm64: cpufeature: introduce helper cpu_has_hw_af()"), but above commit >> did add this on regular page fault path via do_set_pte(). > > Indeed. The only other usage of this function is in wp_page_copy, and, > from what I can tell, it is in an unlikely() branch when COW is being > performed on a page that was recently unmapped. It is not something > frequent enough that I saw in profiling. > >>> ID_AA64MMFR1_EL1_HAFDBS_SHIFT); >>> } >> >> LGTM but as mentioned earlier, are there not other similar instances or this >> is just more problematic being on direct page fault path ? > > I think a full audit of the emulated system registers in kvm will be > required to definitely answer it. But this instance is, by far, the hottest > case in the codebase. > Thanks for the additional details. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel