Message ID | 20230517022115.3033604-3-pcc@google.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp839957vqo; Tue, 16 May 2023 19:57:29 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ67/No4/meVe85Pwfxcb8XTS+uqio79g876Lrebx/8BaeuxPT2PykNOsLWeuPx2YcxKlOek X-Received: by 2002:a17:902:c115:b0:1aa:d866:33cf with SMTP id 21-20020a170902c11500b001aad86633cfmr39657118pli.56.1684292249575; Tue, 16 May 2023 19:57:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684292249; cv=none; d=google.com; s=arc-20160816; b=dado3llHw8XC65BklBs9RHBnqujZznSsI/PxkzRMuQsWhZOczFSrQwm9mFV/DWtJi2 I8Kjy9CYIjpFwZmYnl8srCO08pnfhz/w1qAAcOvC/URJGImPZqmRgry1qSeDzPKRYuUE 3UWXo5sdVY1b5KtzD511FNz2x+RHZ0FGXAlyW1EI4KKq81q9Uj6povNcgDK0HLAWhsD1 pu0zxQ25S/P5Td1Ulr63b954uPUz9SmdmSKVUC55lFdPB9DAn6nMVVW/xirWr5k/jM8Q roGaAQffVHhHrd16HKGi/6Llr8shBgFuH4K62ukePuqZtB8Mbf4HFjCtDL2Kv+BpgOsz 7mIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:references:mime-version :message-id:in-reply-to:date:dkim-signature; bh=DmZ7qJu2QJbmubDEgRMJhswdry7Qhukww11ZPOJRgvs=; b=VE+0Gt8ontKgDIWTrIZLrz8SzwsByEwQ/Bp058rJMqwa0CyPgXb7yz3m/hf3LahMwX /sOlaucO7MrhSdak8AtU2vuH18seSVFXF0Nm53qebqNtMbKD9IWROFR88VM4vM3fChUn KXMjvjw68FDNu0M7zBDIeILbxml/l/pRbF6OLd3nHTsvuCd46r8E1UHWMG+Rk4KoJ1X4 3DhexlXpxey06NENf0Ezcwri4Ky1sEMjxUaRcVOJcHlJz8LoAkx6BzYx1lUiVqpe9cBT Q7BRuIYKMV+AbgDiNN8OyWR77CQZ6zKaXl/W+j8Pr5b3QwL4mSoO7n7SAvwsVwznapuh oQzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=pXVJppsk; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b6-20020a170902b60600b001ab0c00aec4si12075766pls.482.2023.05.16.19.57.17; Tue, 16 May 2023 19:57:29 -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=@google.com header.s=20221208 header.b=pXVJppsk; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231919AbjEQCVd (ORCPT <rfc822;abdi.embedded@gmail.com> + 99 others); Tue, 16 May 2023 22:21:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43522 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231899AbjEQCV3 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 16 May 2023 22:21:29 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8A4E940EF for <linux-kernel@vger.kernel.org>; Tue, 16 May 2023 19:21:28 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-ba8337a578dso151746276.1 for <linux-kernel@vger.kernel.org>; Tue, 16 May 2023 19:21:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1684290087; x=1686882087; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=DmZ7qJu2QJbmubDEgRMJhswdry7Qhukww11ZPOJRgvs=; b=pXVJppsksfHh4I2n3d8xVcufhKZZlJjnCny+rmQ4mjQKI0AW/cCK2hASK83KfSiYpL SwH5TVvYpvNqffEsNvDPgC+nhgLYFM3KaqHCuYbPaIFzls2lqfx0JYU50+6NVWzrME9W 1mfRz5hwNYEvKHUFnlT4dknNheNNzedfdZLSkBZlu7QlWmiIOdq/l+RcVRDobfHZBP0c 7otPYVh11OT4odfN5rNmMB6Xfe/sUmOnKNfozY8i+NNWwTSKo6jWbGtluyHsGeqrt/Um gaSjHg7Sh7LXhrO/UUQMLAjulMUlLvxOhNHHmrBn6+ZKABwqhlZs4QhdwbdE4TaSFaoL o8HQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684290087; x=1686882087; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=DmZ7qJu2QJbmubDEgRMJhswdry7Qhukww11ZPOJRgvs=; b=e0ftyAVCqq0vRIdKMF0bGZLpGogtMPzjlg4t1U0bEifTF8sPW2g/m4qPHPP7hMcoo2 Pw3wqQPyLXdsPHy5t7tVwmHuimJMpbduAZBxm1XNiS/CSDtbfCU2cCcTMpFjQ6g5DGWq NgZh7X7IR6cx1lt4u4MgvXVIz6vshHRyI1hCkigYH0rjgOPm5feIhvuDt64bZUqzjmxe 8OFsdRQSyoJAxlzcPH/Zq2wpqe/iIj3fgijCHnHP/gZutFL0tRWyp8U5WmLVlEpF9mf8 H8QqRJgcqsEAor9HDI5iDURQMQTv/x6BKAnbBiLGayDNd5GHzsp+CfspiTyLoXiiVBoI L7zQ== X-Gm-Message-State: AC+VfDyZec4nQXNQQ17UaFIPhwAiiuj4uoQACgfBnb8W1MAacB3XvOuf Q/7w9KbMD/FFTW4ppXUh63AHn+o= X-Received: from pcc-desktop.svl.corp.google.com ([2620:15c:2d3:205:b3a7:7c59:b96b:adaa]) (user=pcc job=sendgmr) by 2002:a25:8407:0:b0:ba8:4b22:4e8a with SMTP id u7-20020a258407000000b00ba84b224e8amr1065312ybk.0.1684290087741; Tue, 16 May 2023 19:21:27 -0700 (PDT) Date: Tue, 16 May 2023 19:21:12 -0700 In-Reply-To: <20230517022115.3033604-1-pcc@google.com> Message-Id: <20230517022115.3033604-3-pcc@google.com> Mime-Version: 1.0 References: <20230517022115.3033604-1-pcc@google.com> X-Mailer: git-send-email 2.40.1.606.ga4b1b128d6-goog Subject: [PATCH v3 2/3] mm: Call arch_swap_restore() from unuse_pte() From: Peter Collingbourne <pcc@google.com> To: Catalin Marinas <catalin.marinas@arm.com> Cc: Peter Collingbourne <pcc@google.com>, " =?utf-8?b?UXVuLXdlaSBMaW4gKA==?= =?utf-8?b?5p6X576k5bS0KQ==?= " <Qun-wei.Lin@mediatek.com>, linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, "surenb@google.com" <surenb@google.com>, "david@redhat.com" <david@redhat.com>, " =?utf-8?b?Q2hpbndlbiBDaGFuZyAo5by1?= =?utf-8?b?6Yym5paHKQ==?= " <chinwen.chang@mediatek.com>, "kasan-dev@googlegroups.com" <kasan-dev@googlegroups.com>, " =?utf-8?b?S3Vh?= =?utf-8?b?bi1ZaW5nIExlZSAo5p2O5Yag56mOKQ==?= " <Kuan-Ying.Lee@mediatek.com>, " =?utf-8?b?Q2FzcGVyIExpICjmnY7kuK3mpq4p?= " <casper.li@mediatek.com>, "gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>, vincenzo.frascino@arm.com, Alexandru Elisei <alexandru.elisei@arm.com>, will@kernel.org, eugenis@google.com, Steven Price <steven.price@arm.com> Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED, USER_IN_DEF_DKIM_WL 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766108429867654868?= X-GMAIL-MSGID: =?utf-8?q?1766108429867654868?= |
Series |
mm: Fix bug affecting swapping in MTE tagged pages
|
|
Commit Message
Peter Collingbourne
May 17, 2023, 2:21 a.m. UTC
We would like to move away from requiring architectures to restore
metadata from swap in the set_pte_at() implementation, as this is not only
error-prone but adds complexity to the arch-specific code. This requires
us to call arch_swap_restore() before calling swap_free() whenever pages
are restored from swap. We are currently doing so everywhere except in
unuse_pte(); do so there as well.
Signed-off-by: Peter Collingbourne <pcc@google.com>
Link: https://linux-review.googlesource.com/id/I68276653e612d64cde271ce1b5a99ae05d6bbc4f
---
mm/swapfile.c | 7 +++++++
1 file changed, 7 insertions(+)
Comments
On 17.05.23 04:21, Peter Collingbourne wrote: > We would like to move away from requiring architectures to restore > metadata from swap in the set_pte_at() implementation, as this is not only > error-prone but adds complexity to the arch-specific code. This requires > us to call arch_swap_restore() before calling swap_free() whenever pages > are restored from swap. We are currently doing so everywhere except in > unuse_pte(); do so there as well. > > Signed-off-by: Peter Collingbourne <pcc@google.com> > Link: https://linux-review.googlesource.com/id/I68276653e612d64cde271ce1b5a99ae05d6bbc4f > --- > mm/swapfile.c | 7 +++++++ > 1 file changed, 7 insertions(+) > > diff --git a/mm/swapfile.c b/mm/swapfile.c > index 274bbf797480..e9843fadecd6 100644 > --- a/mm/swapfile.c > +++ b/mm/swapfile.c > @@ -1794,6 +1794,13 @@ static int unuse_pte(struct vm_area_struct *vma, pmd_t *pmd, > goto setpte; > } > > + /* > + * 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, page_folio(page)); > + > /* See do_swap_page() */ > BUG_ON(!PageAnon(page) && PageMappedToDisk(page)); > BUG_ON(PageAnon(page) && PageAnonExclusive(page)); Acked-by: David Hildenbrand <david@redhat.com>
On 17/05/2023 03:21, Peter Collingbourne wrote: > We would like to move away from requiring architectures to restore > metadata from swap in the set_pte_at() implementation, as this is not only > error-prone but adds complexity to the arch-specific code. This requires > us to call arch_swap_restore() before calling swap_free() whenever pages > are restored from swap. We are currently doing so everywhere except in > unuse_pte(); do so there as well. > > Signed-off-by: Peter Collingbourne <pcc@google.com> > Link: https://linux-review.googlesource.com/id/I68276653e612d64cde271ce1b5a99ae05d6bbc4f Reviewed-by: Steven Price <steven.price@arm.com> > --- > mm/swapfile.c | 7 +++++++ > 1 file changed, 7 insertions(+) > > diff --git a/mm/swapfile.c b/mm/swapfile.c > index 274bbf797480..e9843fadecd6 100644 > --- a/mm/swapfile.c > +++ b/mm/swapfile.c > @@ -1794,6 +1794,13 @@ static int unuse_pte(struct vm_area_struct *vma, pmd_t *pmd, > goto setpte; > } > > + /* > + * 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, page_folio(page)); > + > /* See do_swap_page() */ > BUG_ON(!PageAnon(page) && PageMappedToDisk(page)); > BUG_ON(PageAnon(page) && PageAnonExclusive(page));
On Tue, May 16, 2023 at 07:21:12PM -0700, Peter Collingbourne wrote: > We would like to move away from requiring architectures to restore > metadata from swap in the set_pte_at() implementation, as this is not only > error-prone but adds complexity to the arch-specific code. This requires > us to call arch_swap_restore() before calling swap_free() whenever pages > are restored from swap. We are currently doing so everywhere except in > unuse_pte(); do so there as well. > > Signed-off-by: Peter Collingbourne <pcc@google.com> > Link: https://linux-review.googlesource.com/id/I68276653e612d64cde271ce1b5a99ae05d6bbc4f Acked-by: Catalin Marinas <catalin.marinas@arm.com>
diff --git a/mm/swapfile.c b/mm/swapfile.c index 274bbf797480..e9843fadecd6 100644 --- a/mm/swapfile.c +++ b/mm/swapfile.c @@ -1794,6 +1794,13 @@ static int unuse_pte(struct vm_area_struct *vma, pmd_t *pmd, goto setpte; } + /* + * 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, page_folio(page)); + /* See do_swap_page() */ BUG_ON(!PageAnon(page) && PageMappedToDisk(page)); BUG_ON(PageAnon(page) && PageAnonExclusive(page));