From patchwork Tue May 23 00:43:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Collingbourne X-Patchwork-Id: 13251301 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 04D36C77B75 for ; Tue, 23 May 2023 00:43:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 905B3900003; Mon, 22 May 2023 20:43:23 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 84059280001; Mon, 22 May 2023 20:43:23 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 69380900004; Mon, 22 May 2023 20:43:23 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 5A228900003 for ; Mon, 22 May 2023 20:43:23 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 2E78780587 for ; Tue, 23 May 2023 00:43:23 +0000 (UTC) X-FDA: 80819671086.13.72C0CF9 Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) by imf14.hostedemail.com (Postfix) with ESMTP id 5F298100006 for ; Tue, 23 May 2023 00:43:21 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b="bdogDu/L"; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf14.hostedemail.com: domain of 3KAxsZAMKCBsG337FF7C5.3FDC9ELO-DDBM13B.FI7@flex--pcc.bounces.google.com designates 209.85.219.202 as permitted sender) smtp.mailfrom=3KAxsZAMKCBsG337FF7C5.3FDC9ELO-DDBM13B.FI7@flex--pcc.bounces.google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1684802601; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=bX87CylYnN+5c55ItUvtBMTDdL52LhDBMQG45ADuUIs=; b=rbqP86GcE0aAyrd4YzacRX4kFBvTjGHOusgKSqW5tf03wzu4Zfb29B3/XxynKip0ZBUkq3 loeJdsNoq1HUxVGJWA1IVE/are7CQ9P9MMlIXF442d0yD6MBkX2Nsi9uRc755F2SLVGTfO bWhdxgCGiGtlnfsuhIYMKB4Y2z7na70= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b="bdogDu/L"; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf14.hostedemail.com: domain of 3KAxsZAMKCBsG337FF7C5.3FDC9ELO-DDBM13B.FI7@flex--pcc.bounces.google.com designates 209.85.219.202 as permitted sender) smtp.mailfrom=3KAxsZAMKCBsG337FF7C5.3FDC9ELO-DDBM13B.FI7@flex--pcc.bounces.google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684802601; a=rsa-sha256; cv=none; b=qJdCAcDkgPNrVdTkU0FGVDHRCqQ6Z7CDEacQdcYbIdZ0SDklCBIzdZOP+FJbjKdE4VfMBK WD2JgpAcJ2OEjbKfUnW3Xz2kXhdVO6l0ekDUp5O5CfbNLXRQ/h0oQXGw6UOuC1eOiByXKF SB++DQ/+jRwlp8EGByPVdg+qKrBJGo4= Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-ba8c9e9e164so8222808276.2 for ; Mon, 22 May 2023 17:43:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1684802600; x=1687394600; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=bX87CylYnN+5c55ItUvtBMTDdL52LhDBMQG45ADuUIs=; b=bdogDu/LWKIXK0xhj/mHEXmPSLZDQ4wTkCFpl5MS9xXgMH/lrIKDBgMm2OVW0088Ob UUXOUas2bD7bxDVYmP+pP6qAeeNNcNNzpyrJngzal1hujSvkuKEu7+oTZMvffng5FsBp gwlthK4wI9AiO+Fdzy5ned4Ve4n2qyJlWIgHIhgxohsY1Qw8A0XJY+vCXRNI9cCOvTZk GipdqA6ZJmCkCppBtgmsiSQUIm6BRaEmUEy2YBmPt0Mrmuq/dUUS0r0t46hxsqR6HbX9 qaAwcxK6iWLJ/y3GzsvNuhSXXmpx/eIa9uHJFpCvIlk4HbNQJ1mX497oATiIBKnqBGwO uixA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684802600; x=1687394600; 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=bX87CylYnN+5c55ItUvtBMTDdL52LhDBMQG45ADuUIs=; b=Sho56kz/fIQJYhze5dNEeWDl2CW2SVCZExThRLwEnFVZofoxNvyQxdxO5ZXkFWvJ19 4DprovnxnJ9mdnjTxNk6/LKYaioJZ+yzIQ7QPEi8fXfPS9CtWGetyIX+QiFfFHsOXYeF BtoyERyzdcIMa/BKf2p9dNUC+LsSDNCeBBBwkQc5lPWI6MWoXIXxOoahjulDv2gpbu4C rlq+LWfM1uYfMyi6n8zdD2qsPi3qjJKHq+KhFUTlDW2K576WDLORUCQULvWx/N1bhUDF n07EG0fdYf4lLk9i7DSYzj9Pa38gBbyL2dlnIB9dI5Y06kS3zGzCkiLiVDGlsKSNXeV4 XjHA== X-Gm-Message-State: AC+VfDzEjQKM/JCSTF5WKijgCLZD4H2iPKC/oOaB23y6NZQMdMRaHxk9 WQx754OIc+QFH/WoMocYekp3IwY= X-Google-Smtp-Source: ACHHUZ7h2YrRQhx18dwlYMT7aHixdC7I8JgE0ax2zPvocyh8XVLX5phmGOcIHrUfvAqU9QnxAXjxEvs= X-Received: from pcc-desktop.svl.corp.google.com ([2620:15c:2d3:205:3d33:90fe:6f02:afdd]) (user=pcc job=sendgmr) by 2002:a25:d55:0:b0:ba8:9455:85b9 with SMTP id 82-20020a250d55000000b00ba8945585b9mr5274091ybn.4.1684802600447; Mon, 22 May 2023 17:43:20 -0700 (PDT) Date: Mon, 22 May 2023 17:43:09 -0700 In-Reply-To: <20230523004312.1807357-1-pcc@google.com> Message-Id: <20230523004312.1807357-3-pcc@google.com> Mime-Version: 1.0 References: <20230523004312.1807357-1-pcc@google.com> X-Mailer: git-send-email 2.40.1.698.g37aff9b760-goog Subject: [PATCH v4 2/3] mm: Call arch_swap_restore() from unuse_pte() From: Peter Collingbourne To: Catalin Marinas Cc: Peter Collingbourne , " =?utf-8?b?UXVuLXdlaSBMaW4gKA==?= =?utf-8?b?5p6X576k5bS0KQ==?= " , linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, "surenb@google.com" , "david@redhat.com" , " =?utf-8?b?Q2hpbndlbiBDaGFuZyAo?= =?utf-8?b?5by16Yym5paHKQ==?= " , "kasan-dev@googlegroups.com" , " =?utf-8?b?S3Vhbi1ZaW5nIExlZSAo5p2O5Yag56mOKQ==?= " , " =?utf-8?b?Q2FzcGVyIExpICjmnY7kuK3mpq4p?= " , "gregkh@linuxfoundation.org" , vincenzo.frascino@arm.com, Alexandru Elisei , will@kernel.org, eugenis@google.com, Steven Price X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 5F298100006 X-Stat-Signature: dwm947soayruuspigs1y3kx4cqaagwjr X-Rspam-User: X-HE-Tag: 1684802601-868574 X-HE-Meta: U2FsdGVkX1+srnGUtgP+cEpKj3MCJk0vChk9QyclhN9ygjY7jL3CM8ZqJ8MS9NvEwUbY9pdTsxuO3AUX6S4x9DcD+z2dlYwRmFlWVE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ixtSlDyjbPh0sgmaezsNZJjDV7VwxUY9O9ZvNyQwxSYIodQoBrlkoWXE8AGVGRSHp2arp3LouTpICOCc9yESbl4sPoNCQFIkTSvKBrS9vpBBfZRJd6MvFbdM+bx0uWEj42A1aRgk77CynIIWj7Bxek3ZNtEB6bxodFgTp7fSVTMH1/aSbElDsy1YpwRz8Tm1bn++20sNeJt/hMmso+gsDesAvWlcls0F1whoAqlQi/rpHVymBPlCli7k/QQZ8GG02o4GD6crq6wr4ez1K/+jY2Wuyiz1qz98WyImAcQnWWOCGVnrKSmSIzgjGfaiT6D9G4gSpHlK+ONiEec2oWglOyG5LwBTWnA7/TUg+kwssnKK2DSRDD5My27uVg+yXlZSRBJAy9UuzOtGYRsXlkl6BaAwcUpXsbaOsh4sv9q6GLSDjbNICX33Ba2D6XJzaMBTMrIo39vRL98mBMxF25jpvER7s/kTD4/R1Voq1hWXkneKRl8BdugimsOq/6ctz+UJPa8TZW5fJTnPfNvE0Zcg/MP5atyhpn9QgJuBTsyS1x+ma3k7E7GPWfG536FYQZdRGrqEM5iGSOXLKcTHc06r/w2OMj6GW8BCYL2+42i4hCWI6ay42G48VzTZo= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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 Link: https://linux-review.googlesource.com/id/I68276653e612d64cde271ce1b5a99ae05d6bbc4f Suggested-by: David Hildenbrand Acked-by: David Hildenbrand Acked-by: "Huang, Ying" Reviewed-by: Steven Price Acked-by: Catalin Marinas --- 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));