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 8DC96C77B7D for ; Wed, 17 May 2023 03:42:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232508AbjEQDmY (ORCPT ); Tue, 16 May 2023 23:42:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60792 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232490AbjEQDmR (ORCPT ); Tue, 16 May 2023 23:42:17 -0400 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 130DF35A4; Tue, 16 May 2023 20:42:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1684294936; x=1715830936; h=from:to:cc:subject:references:date:in-reply-to: message-id:mime-version:content-transfer-encoding; bh=bEq3/lkC7Pzz/AEGPXybBFp4PDg/dC0oORu6X+NdoEA=; b=aIE3v1CCyqGb9c5+TfNpGJCHUP7fsEUqr4jx57vekT+CzIidHll86n/B 6+zq6PDJBlIyWT166yz+Osye/S1ohqOM6672v7sJrZz4/mPEs8xnzcK+s pvgJIGJSV8lrcXitW2PrqhEZgd0OW6RMajZDGXOCxJu1u5qrFGrMhWHDe 2sMPJCencB/OLFAeove1TYm0Qa5REf1nkMjWgjY6YKJXNzsyspx5HNw5V rscap0z4iUqcOWAEFE6+Rx/eF7dXcXTPCR1wJlUcwoNd8wMJwKHEe5Dfb EGaT0uBqGJ8FEFLytWlRLKFSJ6lZiRx6Z+rbn+JbVZeicZv/v8K/UTknx g==; X-IronPort-AV: E=McAfee;i="6600,9927,10712"; a="379842594" X-IronPort-AV: E=Sophos;i="5.99,280,1677571200"; d="scan'208";a="379842594" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 May 2023 20:42:15 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10712"; a="948103305" X-IronPort-AV: E=Sophos;i="5.99,280,1677571200"; d="scan'208";a="948103305" Received: from yhuang6-desk2.sh.intel.com (HELO yhuang6-desk2.ccr.corp.intel.com) ([10.238.208.55]) by fmsmga006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 May 2023 20:42:11 -0700 From: "Huang, Ying" To: Peter Collingbourne Cc: Catalin Marinas , =?utf-8?B?UXVuLXdlaSBMaW4g?= =?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" , =?utf-8?Q?C?= =?utf-8?Q?hinwen_Chang_=28=E5=BC=B5=E9=8C=A6=E6=96=87=29?= , "kasan-dev@googlegroups.com" , =?utf-8?Q?Kuan-Ying_Lee_=28=E6=9D=8E?= =?utf-8?Q?=E5=86=A0=E7=A9=8E=29?= , =?utf-8?B?Q2FzcGVyIExpICjmnY7kuK3mpq4p?= , "gregkh@linuxfoundation.org" , vincenzo.frascino@arm.com, Alexandru Elisei , will@kernel.org, eugenis@google.com, Steven Price , stable@vger.kernel.org Subject: Re: [PATCH v3 1/3] mm: Call arch_swap_restore() from do_swap_page() References: <20230517022115.3033604-1-pcc@google.com> <20230517022115.3033604-2-pcc@google.com> Date: Wed, 17 May 2023 11:40:58 +0800 In-Reply-To: <20230517022115.3033604-2-pcc@google.com> (Peter Collingbourne's message of "Tue, 16 May 2023 19:21:11 -0700") Message-ID: <87353v7hh1.fsf@yhuang6-desk2.ccr.corp.intel.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Peter Collingbourne writes: > 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/I6470efa669e8bd2f841049b8c= 61020c510678965 > Cc: # 6.1 > Fixes: c145e0b47c77 ("mm: streamline COW logic in do_swap_page()") > Reported-by: Qun-wei Lin (=E6=9E=97=E7=BE=A4=E5=B4=B4) > Closes: https://lore.kernel.org/all/5050805753ac469e8d727c797c2218a9d780d= 434.camel@mediatek.com/ > --- > 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) > } > } >=20=20 > + /* > + * 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 Should you add Suggested-by: David Hildenbrand for 1/3 and 2/3. It looks good for me for swap code related part. Feel free to add Acked-by: "Huang, Ying" to 1/3 and 2/3. Best Regards, Huang, Ying