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 C8054C7EE29 for ; Fri, 19 May 2023 16:21:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230240AbjESQVW (ORCPT ); Fri, 19 May 2023 12:21:22 -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: linux-kernel@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