Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp5695987rwd; Mon, 5 Jun 2023 07:22:06 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6HkuGzyxut3TtMhlpk1AJg1MzKOLcmlX0d+fAQXfC1E/natBh0Xt2atxA3vCzkYlUYbXXP X-Received: by 2002:a17:902:c405:b0:1b0:aec3:ed34 with SMTP id k5-20020a170902c40500b001b0aec3ed34mr5100364plk.52.1685974926655; Mon, 05 Jun 2023 07:22:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685974926; cv=none; d=google.com; s=arc-20160816; b=06KoTaWb4uCqXA7lkpt/r5uw03YLZ4eDV7HYoeW41f+IjykiW2GxcINhvl3keP+K8F vOsD3dJnCi9J5KEDckNxEuwITsee0UFe3nxanXYmY3uscY31Y83OewpEldgYdcpIkGo9 yRWH5RVqEv7NzgwdkIUnAvksXsjAdBzIMId8ey3WicR7xFRRfMf6Mhsys7Fic28JxtsU 78QMXJupX0PP/NxtNF4+ZnaDK2yIdMQ23jGyWrM87gXu0FxC4UrrHIaDcp9WXFcvlxpd xag3BjzMc8pgsDOMH3MwfOcIJJ/DEPkkoDZZ3Ja0aWnIcpTeWimNLKFK2jENGc0jYdhI 6GmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=SEbMdkTYQd1XGwIQ1d9jIUEnt/7HRRl3aea4595yQQQ=; b=xIbwxVtv/eJR0HQXpoVhtPlDpZGUglb0f3bFLreg+l1uEmrIUFLkybDb4IBK6dziMp OzonVEyO6m5s1N2t/yX6qdrslxvivWcMEQJqH0BNn1ePRoPtmR2XyoagLU5MTvc16YMf MelwGSziwBzetiqHmnSga7RVJafhWXNKVvgOB1xxq0sjE7wKNof/Mn7WHoJyrtxqUfI2 QG2YDvC0WUZ83Rb129x/gj5O7Fw96+pII3X5eunYECmEVQ9kUU6OmJcD4+WxqfldjsAV NzHgfltVR4b5vKc9Qxlvm7CLhkLfBJ5P9yM/vMMsmvtdK0eg2GVnokJNYeRzPoTEDg5F a4wA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=P8rvPmfM; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i14-20020a170902c94e00b001a1e0fd406csi5657191pla.217.2023.06.05.07.21.53; Mon, 05 Jun 2023 07:22:06 -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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=P8rvPmfM; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231967AbjFEOGU (ORCPT + 99 others); Mon, 5 Jun 2023 10:06:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34428 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233771AbjFEOGI (ORCPT ); Mon, 5 Jun 2023 10:06:08 -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 97EEB122; Mon, 5 Jun 2023 07:06:02 -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 1377261671; Mon, 5 Jun 2023 14:06:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 43F84C433D2; Mon, 5 Jun 2023 14:05:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1685973961; bh=owgJ2JpHb0soEawFXmtTH142XPFNTNcm+kX8RwdJzrw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=P8rvPmfMPFhkA/+lwOFdVC7Dj9vKBHQCUCXWNlRg6AGoa0sWtr23aAYTfZ0dO7QXO 8wyrfhiG3fzyG0GE2T+vqkK+fk0TYzo2EJTd/6Vp6SC95GdqAwx7c0WuWH/BvqcPRU jRYGNKaYaOzPuo2mdMYiLrd61NFpdya35mhm4Eekt7TIEObXLc5Jvu9RIrvgLjCmNf YJLO3z3vOXI3Ft78f4n1ydPpUFv8r8jdoDz/TqDJxB7B0xv9xCVISxNn+2rWv4Ck6W 3mhwWc35qxqJlJK5NhVpOiWtvkBEP/YGHKvgPNzRhZTuXZIElg8qL1+egPddVLcZLY fwyA0nVldOaYQ== Date: Mon, 5 Jun 2023 15:05:54 +0100 From: Will Deacon To: Peter Collingbourne , akpm@linux-foundation.org Cc: Catalin Marinas , 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 , eugenis@google.com, Steven Price , stable@vger.kernel.org Subject: Re: [PATCH v4 1/3] mm: Call arch_swap_restore() from do_swap_page() Message-ID: <20230605140554.GC21212@willie-the-truck> References: <20230523004312.1807357-1-pcc@google.com> <20230523004312.1807357-2-pcc@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20230523004312.1807357-2-pcc@google.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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 Hi Peter, On Mon, May 22, 2023 at 05:43:08PM -0700, Peter Collingbourne wrote: > Commit c145e0b47c77 ("mm: streamline COW logic in do_swap_page()") moved > the call to swap_free() before the call to set_pte_at(), which meant that > the MTE tags could end up being freed before set_pte_at() had a chance > to restore them. Fix it by adding a call to the arch_swap_restore() hook > before the call to swap_free(). > > Signed-off-by: Peter Collingbourne > Link: https://linux-review.googlesource.com/id/I6470efa669e8bd2f841049b8c61020c510678965 > Cc: # 6.1 > Fixes: c145e0b47c77 ("mm: streamline COW logic in do_swap_page()") > Reported-by: Qun-wei Lin (林群崴) > Closes: https://lore.kernel.org/all/5050805753ac469e8d727c797c2218a9d780d434.camel@mediatek.com/ > Acked-by: David Hildenbrand > Acked-by: "Huang, Ying" > Reviewed-by: Steven Price > Acked-by: Catalin Marinas > --- > v2: > - Call arch_swap_restore() directly instead of via arch_do_swap_page() > > mm/memory.c | 7 +++++++ > 1 file changed, 7 insertions(+) > > diff --git a/mm/memory.c b/mm/memory.c > index f69fbc251198..fc25764016b3 100644 > --- a/mm/memory.c > +++ b/mm/memory.c > @@ -3932,6 +3932,13 @@ vm_fault_t do_swap_page(struct vm_fault *vmf) > } > } > > + /* > + * Some architectures may have to restore extra metadata to the page > + * when reading from swap. This metadata may be indexed by swap entry > + * so this must be called before swap_free(). > + */ > + arch_swap_restore(entry, folio); > + > /* > * Remove the swap entry and conditionally try to free up the swapcache. > * We're already holding a reference on the page but haven't mapped it It looks like the intention is for this patch to land in 6.4, whereas the other two in the series could go in later, right? If so, I was expecting Andrew to pick this one up but he's not actually on CC. I've added him now, but you may want to send this as a separate fix so it's obvious what needs picking up for this cycle. Cheers, Will