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 A4D8DC77B7A for ; Fri, 19 May 2023 16:54:38 +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=bcjZTdrVzTXbpLGWxT+jNkpBXYAIvSViePnFhuRJWxU=; b=DAhHiyJfH2Qc7J XyREeWsPA6kmEoMkxvPt2YAj9CKOno+uTqG1kDFKBnR6GwXP1oLxpDb+/IQ0Rgz1tUv29CNcYkf4s Mg3+3riIVIdU3sY2W77j68TqWV/dk1AaU/tYaL7FZojDwdwp7LNHy0oRqnPaQku46zgNRbZ5pQ9W/ GkDISjP2wIZk5aOvL0WJX03sFm6cf7W50dAF6cSp5t6MULsdo8jOPQ0Ca1ZAKmK0ZDnJAJzpcWo9b Yi/E662ZIoIaDIo6RUAp2oS3j24NX4OnnXfbUxb0y5ljK/51rlsRFiUOEtsAPLupIPf8WUCBkCK7p ZyXPaBVI9yGuVzgfQ+Pg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q03My-00GmEl-0J; Fri, 19 May 2023 16:54:20 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q03Mv-00GmDG-3D for linux-arm-kernel@lists.infradead.org; Fri, 19 May 2023 16:54:19 +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 dfw.source.kernel.org (Postfix) with ESMTPS id 4C41165951; Fri, 19 May 2023 16:54:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DFFBFC433EF; Fri, 19 May 2023 16:54:11 +0000 (UTC) Date: Fri, 19 May 2023 17:54:09 +0100 From: Catalin Marinas To: Peter Collingbourne Cc: Qun-wei Lin =?utf-8?B?KOael+e+pOW0tCk=?= , linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, "surenb@google.com" , "david@redhat.com" , Chinwen Chang =?utf-8?B?KOW8temMpuaWhyk=?= , "kasan-dev@googlegroups.com" , Kuan-Ying Lee =?utf-8?B?KOadjuWGoOepjik=?= , Casper Li =?utf-8?B?KOadjuS4reamrik=?= , "gregkh@linuxfoundation.org" , vincenzo.frascino@arm.com, Alexandru Elisei , will@kernel.org, eugenis@google.com, Steven Price Subject: Re: [PATCH v3 3/3] arm64: mte: Simplify swap tag restoration logic Message-ID: References: <20230517022115.3033604-1-pcc@google.com> <20230517022115.3033604-4-pcc@google.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20230517022115.3033604-4-pcc@google.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230519_095418_077899_4E90FD6D X-CRM114-Status: GOOD ( 18.92 ) 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 Tue, May 16, 2023 at 07:21:13PM -0700, Peter Collingbourne wrote: > As a result of the previous two patches, there are no circumstances > in which a swapped-in page is installed in a page table without first > having arch_swap_restore() called on it. Therefore, we no longer need > the logic in set_pte_at() that restores the tags, so remove it. > > Because we can now rely on the page being locked, we no longer need to > handle the case where a page is having its tags restored by multiple tasks > concurrently, so we can slightly simplify the logic in mte_restore_tags(). [...] > diff --git a/arch/arm64/mm/mteswap.c b/arch/arm64/mm/mteswap.c > index cd508ba80ab1..3a78bf1b1364 100644 > --- a/arch/arm64/mm/mteswap.c > +++ b/arch/arm64/mm/mteswap.c > @@ -53,10 +53,9 @@ void mte_restore_tags(swp_entry_t entry, struct page *page) > if (!tags) > return; > > - if (try_page_mte_tagging(page)) { > - mte_restore_page_tags(page_address(page), tags); > - set_page_mte_tagged(page); > - } > + WARN_ON_ONCE(!try_page_mte_tagging(page)); > + mte_restore_page_tags(page_address(page), tags); > + set_page_mte_tagged(page); > } Can we have a situation where two processes share the same swap pte (CoW) and they both enter the do_swap_page() or the unuse_pte() paths triggering this warning? Other than that, the looks nice, it simplifies the logic and probably saves a few cycles as well on the set_pte_at() path. Reviewed-by: Catalin Marinas _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel