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 64EA9C678DA for ; Wed, 11 Jan 2023 13:33:07 +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:MIME-Version:Message-ID:In-Reply-To: Date:References:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=vwnwldEpx4KMlxPofBlVqNS+uWJb5o4IkblNk9Cb4CM=; b=fgQQL8cS5RuMBU bBtnEfcR3gy4b3EpjUCUWqVvHe/DxYDZ7CixMMrAzhqilePcIdz/SquSbuJKGiE2N814+D6Bnrg1B V2Q592MqbLSvx3GbzDn8Es0lI/UmOuUe4EVHX0N2CXBa4TM8yFoHVTTKjBe3go+7cgCLzwJWf/B78 mJVq2cvjHQAFFQcDTbRNH6JT+t4BRCOHty6Mgmk8NyBcgQpkvaIeJ0oJ4fqYOHOlQL5n4hoyntKAW DwOV4PkuWqE14Ua4Fr1T0oT5FDV/WqJ6t9J0YpSrrLo6knMKW0uyDAIw+Hii+pxbKjAQg2yvbewE9 XqDrI6uGu+9KOgYOuTOQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pFbCj-00Baat-7S; Wed, 11 Jan 2023 13:31:46 +0000 Received: from smtp-out1.suse.de ([195.135.220.28]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pFbCQ-00BaOX-01 for linux-arm-kernel@lists.infradead.org; Wed, 11 Jan 2023 13:31:29 +0000 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 2F9B617A29; Wed, 11 Jan 2023 13:31:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1673443884; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=3KsjT0aXQqkhBjXC8wvn9kIg0yScB8sEwzPSBMo58rA=; b=Jgu1cJQlnv9B9MN0zBhReltvgn96X7APtn9kq1boit4wHAl3aRoMvV267MVotu07qtMBPK ndjj2TX0e/PpA07iUv2PG7h8asjvcTMUV1BsMbuvGIjlmnv6y9F1Tqrl7S8HLQccLAdIt3 AcZO7xq2BdgHpVqBumFl3fFKfAh8KRQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1673443884; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=3KsjT0aXQqkhBjXC8wvn9kIg0yScB8sEwzPSBMo58rA=; b=SRJSsNVM2LsNGUn6cKRm3Gpuhgcdy/65D6H5TcdSTk07SqtFC2vdUmxxsg+/rBov1zHOaY TxWqggeXGaej49CA== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id AD5DF1358A; Wed, 11 Jan 2023 13:31:23 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id oleWHCu6vmORbQAAMHmgww (envelope-from ); Wed, 11 Jan 2023 13:31:23 +0000 From: Gabriel Krisman Bertazi To: Anshuman Khandual Cc: catalin.marinas@arm.com, will@kernel.org, linux-arm-kernel@lists.infradead.org, broonie@kernel.org Subject: Re: [PATCH v2] arm64: Avoid repeated AA64MMFR1_EL1 register read on pagefault path Organization: SUSE References: <20230109151955.8292-1-krisman@suse.de> <25058f6d-a434-6166-7a9d-1ee7f98130a3@arm.com> Date: Wed, 11 Jan 2023 10:31:21 -0300 In-Reply-To: <25058f6d-a434-6166-7a9d-1ee7f98130a3@arm.com> (Anshuman Khandual's message of "Wed, 11 Jan 2023 14:04:41 +0530") Message-ID: <87pmbldwpi.fsf@suse.de> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230111_053126_253212_0FD11E81 X-CRM114-Status: GOOD ( 17.44 ) 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 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. -- Gabriel Krisman Bertazi _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel