Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2750107rwd; Fri, 19 May 2023 09:40:01 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7eUjNU5DxGms+G8ST6wadfP4MV//geeIgNUYsNEM66n75vFNCOF3cgpP1LhMnj7TZPLjWO X-Received: by 2002:a17:902:e885:b0:1ab:fb6:1e72 with SMTP id w5-20020a170902e88500b001ab0fb61e72mr3399386plg.42.1684514401299; Fri, 19 May 2023 09:40:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684514401; cv=none; d=google.com; s=arc-20160816; b=umgwPbBpquOu+oLo7xHWtrch4OCvSVgt/d/KMJuQBJMS44twmigQzCpYnm0tn0fdN4 11qOiX9bQ8UtHJRkaJ9hbXpWSRyM4wLgyQRHCxEK24C7cCVQXCJt+W5teavUzCligT9M rLwKZgIkNtxc2r8GrESgfi9wCU8xjWuXmedBoGYd9vg+i4L6ivvey+ieToO0Jtm4oD+X 6eSf/sG6iQeYIs9mNYnzTfXhNSbAAQf+uSpfoqac3joECYWS72uvrwRnUUCd3aDeRdtW 1JO9B6VfbxRjUMTnk9Rku1mwUgxg7iUe59Wh9tocOsuqGkBbRjGaTSDaUWNmqtqy9YZG vnBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=2vDnzHQB9aPGY01kAbFiYHB/+o+ke0Sr0xEkRU6So+Y=; b=GZ6L8aSjIxTTSUumH4b+hrot+seY2E9pyuQhtF2jvREpnMQZFw3ZFLb6LPzkSMzfVi cvxILyNpaUNH5psZPjatgZWw97mcJHZ0HSH9fAqw8BAOT5UVh19wCuvURaledwx/KlVU sum2Vr2kncmORIbVH7A0xugVWsh5ZFrd2FIKQ2VOl7FVusA8wVhgmfQO+1FKIJfIFIB9 zyc4sJAErcxU5nhsff/Ar/RdxCdNPTz395bVNqCizAUE2yz5CNk4oayRkI/jRuP7FKET ldDzVmvbxCAWYjOdFEsP06pWZMVQsnJvp21JNufvMvboU1bm5YJjuE6Egppx0k/grp7T fD/Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t9-20020a170902e84900b001a69d1be184si3967631plg.506.2023.05.19.09.39.40; Fri, 19 May 2023 09:40:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230201AbjESQVU (ORCPT + 99 others); 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> X-Spam-Status: No, score=-4.0 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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