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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 808D6C77B7A for ; Fri, 19 May 2023 16:21:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229842AbjESQVU (ORCPT ); Fri, 19 May 2023 12:21:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49228 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229969AbjESQVS (ORCPT ); Fri, 19 May 2023 12:21:18 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A058CC9; Fri, 19 May 2023 09:21:17 -0700 (PDT) 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 5BC396591C; Fri, 19 May 2023 16:21:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B48C8C433D2; Fri, 19 May 2023 16:21:12 +0000 (UTC) Date: Fri, 19 May 2023 17:21:09 +0100 From: Catalin Marinas To: David Hildenbrand Cc: Peter Collingbourne , 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" , 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 , stable@vger.kernel.org Subject: Re: [PATCH 1/3] mm: Move arch_do_swap_page() call to before swap_free() Message-ID: References: <20230512235755.1589034-1-pcc@google.com> <20230512235755.1589034-2-pcc@google.com> <7471013e-4afb-e445-5985-2441155fc82c@redhat.com> <851940cd-64f1-9e59-3de9-b50701a99281@redhat.com> <80f45fec-3e91-c7b3-7fb4-1aa9355c627a@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <80f45fec-3e91-c7b3-7fb4-1aa9355c627a@redhat.com> Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org On Fri, May 19, 2023 at 11:21:35AM +0200, David Hildenbrand wrote: > > > Sorry, I meant actual anonymous memory pages, not shmem. Like, anonymous > > > pages that are COW-shared due to fork() or KSM. > > > > > > How does MTE, in general, interact with that? Assume one process ends up > > > modifying the tags ... and the page is COW-shared with a different > > > process that should not observe these tag modifications. > > > > Tag modifications cause write faults if the page is read-only, so for > > COW shared pages we would end up copying the page in the usual way, > > which on arm64 would copy the tags as well via the copy_highpage hook > > (see arch/arm64/mm/copypage.c). > > Oh, that makes sense, thanks for pointing that out! > > ... and I can spot that KSM also checks the tag when de-duplicating: > pages_identical() ends up calling memcmp_pages(), which knows how to deal > with tags. > > Interestingly, calc_checksum() does not seem to care about tags. But that > simply implies that pages with the same content have same checksum, > independent of the tag. And pages_identical() is the single source of truth. That was my assumption at the time, there would be a memcmp_pages() in case of checksum collision. -- Catalin 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 45500C77B7A for ; Fri, 19 May 2023 16:21:42 +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=AC8F/yggdZvnGMGHGKW6h03e/MijphqGcgCZvzk4QAI=; b=vaoWMi3VA2T4kM TcOaUP8vSH9WSC6iXKUtU7UIDs6yJavlBHzNktP7fDnA6jrs67TmvaCTauVJBPSajpUJmHqz4M1jY NT8QJ8n8SDIUMibpElDz2HYmDO0kodDQFE2S62CDI2OfTv/mP9IJua2jBxStv9oNqLMAmdc1rVzwm qf3Ko6z11igJ7bAUppghL8aHX7Brt9BhRGhE+TufXjrS7AraMlJGMxNKqUupKaxyYTBdgN201dybJ gq2yAoMXjl8j8eHFkv07b8cSW38h4EHQDKm1LDceVDzXfZWA/YANf/aNOj0cZO1RzjPb5ZRmLo5pV LEMGY95nugTNr+GoePCg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q02r3-00Gi2G-3B; Fri, 19 May 2023 16:21:21 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q02r0-00Gi1F-0h for linux-arm-kernel@lists.infradead.org; Fri, 19 May 2023 16:21: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 580B76591A; Fri, 19 May 2023 16:21:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B48C8C433D2; Fri, 19 May 2023 16:21:12 +0000 (UTC) Date: Fri, 19 May 2023 17:21:09 +0100 From: Catalin Marinas To: David Hildenbrand Cc: Peter Collingbourne , 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" , 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 , stable@vger.kernel.org Subject: Re: [PATCH 1/3] mm: Move arch_do_swap_page() call to before swap_free() Message-ID: References: <20230512235755.1589034-1-pcc@google.com> <20230512235755.1589034-2-pcc@google.com> <7471013e-4afb-e445-5985-2441155fc82c@redhat.com> <851940cd-64f1-9e59-3de9-b50701a99281@redhat.com> <80f45fec-3e91-c7b3-7fb4-1aa9355c627a@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <80f45fec-3e91-c7b3-7fb4-1aa9355c627a@redhat.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230519_092118_306247_FA81EF34 X-CRM114-Status: GOOD ( 19.32 ) 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 Fri, May 19, 2023 at 11:21:35AM +0200, David Hildenbrand wrote: > > > Sorry, I meant actual anonymous memory pages, not shmem. Like, anonymous > > > pages that are COW-shared due to fork() or KSM. > > > > > > How does MTE, in general, interact with that? Assume one process ends up > > > modifying the tags ... and the page is COW-shared with a different > > > process that should not observe these tag modifications. > > > > Tag modifications cause write faults if the page is read-only, so for > > COW shared pages we would end up copying the page in the usual way, > > which on arm64 would copy the tags as well via the copy_highpage hook > > (see arch/arm64/mm/copypage.c). > > Oh, that makes sense, thanks for pointing that out! > > ... and I can spot that KSM also checks the tag when de-duplicating: > pages_identical() ends up calling memcmp_pages(), which knows how to deal > with tags. > > Interestingly, calc_checksum() does not seem to care about tags. But that > simply implies that pages with the same content have same checksum, > independent of the tag. And pages_identical() is the single source of truth. That was my assumption at the time, there would be a memcmp_pages() in case of checksum collision. -- Catalin _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel