From patchwork Wed May 17 02:21:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Collingbourne X-Patchwork-Id: 13244072 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 7CBDBC7EE24 for ; Wed, 17 May 2023 02:21:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id ED70B280002; Tue, 16 May 2023 22:21:30 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E6188280001; Tue, 16 May 2023 22:21:30 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CB31A280002; Tue, 16 May 2023 22:21:30 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id BBA0B280001 for ; Tue, 16 May 2023 22:21:30 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 736C740444 for ; Wed, 17 May 2023 02:21:30 +0000 (UTC) X-FDA: 80798145540.30.5A803C9 Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) by imf11.hostedemail.com (Postfix) with ESMTP id 97B7C4000F for ; Wed, 17 May 2023 02:21:28 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=pXVJppsk; spf=pass (imf11.hostedemail.com: domain of 3JzpkZAMKCFYD004CC492.0CA96BIL-AA8Jy08.CF4@flex--pcc.bounces.google.com designates 209.85.219.201 as permitted sender) smtp.mailfrom=3JzpkZAMKCFYD004CC492.0CA96BIL-AA8Jy08.CF4@flex--pcc.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1684290088; 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=DmZ7qJu2QJbmubDEgRMJhswdry7Qhukww11ZPOJRgvs=; b=Jh7Cy4GvRW+jGbttzfJ0bocF1xujNusGoP5wGPmeBhrKx28YC3LmTrx5dBABlfuDaUhMDc ycATNC9JydTA1ht54rCxuG7nzy8ih671Yvuz6yi8C4aGDq92HrX/mgMmyoZYBPPnFNg8cq NlVM/GQb89en5qnRsVDv2gn+mKLJHOw= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=pXVJppsk; spf=pass (imf11.hostedemail.com: domain of 3JzpkZAMKCFYD004CC492.0CA96BIL-AA8Jy08.CF4@flex--pcc.bounces.google.com designates 209.85.219.201 as permitted sender) smtp.mailfrom=3JzpkZAMKCFYD004CC492.0CA96BIL-AA8Jy08.CF4@flex--pcc.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684290088; a=rsa-sha256; cv=none; b=aCJEXul4wgmsjtanra9pNlQKMe95NRoeSAa9hKTR9/hWeoW+//h/Yz17YJNSLyXzM8fqnT Op+TH6+hJ2NHLyxvv/OL5yhs9UFoOgxWbUJDaDxnc5J0WunmVC5azUCMAQ3suGgJkQmmCg QkWP7++3NLYDMwh+ufnUmjHkA9DRvV0= Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-ba237aec108so144253276.3 for ; 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=kcyAhGTgTNKleFXhSzgvXeVFWPZef3mnuRnpdELrBkSxhMfNldRUnv6GrEI0jcJvDE OUmS5KXhqHzgGK1l7A+puTbmy797Bf4F1SpiB4A9Yjoh5t6dAYVkqC/VRo1eAff+bmtS PTOOzvYLx7qhiCDo/UlTWGBLH+7AlN3MZqSjEqS7mutZ6Pl80eMpUvudtFUe+MAMo+cO w6H4dQYHZEHBRNkAAH8BGhXoC3ieOghGDj76Euw3ZVO6McAW68TZiDlIh1iUXvrfK5Qs jfY2rIyC28b0X2VuaStnncxfr4g4qWFlAgEtkYH5WlkGVD2Nzx79MPFrHUL5h3OlD5TO bsOA== X-Gm-Message-State: AC+VfDyrGipX8qs8xljJ+CJkL+KEYGoXbXxecqoPa7ZoNO1AHdZT2ysV WgQyHwGx5h+ik6AHeoG8CJIR/Hs= X-Google-Smtp-Source: ACHHUZ5CS7mk6mAM2fYvrtpJa+GCdOe26eXVwKAHAWQiAcvcFXtzYZLVtM0rm9Ojto/ISeUmGRcWqts= 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 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-Stat-Signature: qxggsph3zh6qbbs8jnmkm8sosjuwabrs X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 97B7C4000F X-Rspam-User: X-HE-Tag: 1684290088-202520 X-HE-Meta: U2FsdGVkX18bqaM8MLE1GGEQ5ZXkI+788lsfGnuqvHkIWfzxuhy/2CeEG+4ubudyRDybf6oW/rDUGgmS1yd80QCjXmdrLuzZU8zrxXRFyFJXZ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ZII554IOAtiRp/Ih23g9NicuLj3PqWYru3TfkUhh1r+xrj9OJ9OhaplNqWsTVPdgfNSWr3DN/rHY1Ztlt/6vcJ3p/oSbjvWzBYRVSZQAAAAyfjdx15BfXOgipWwA4bilgLfztgeR27YusDkCGeRw4jBzLmcSVrIaoZk+vSpHrcAtfYpH843ngrmN0rnz0Zdk5F3snR94XUp1t9eScwl1zTtDDu14dJjwVtoUJVbdXV/8OyxQyKttpUkOR/O6g0BJF+Jf6Vm2qBwAn0rd1K5CCVfCl5CJRqaa3YHf3/eBYxEvZPpg/5JMr6zIjyFoOYIsdm2koaT54uV9Jq4OceTYaMDwaBtO4WZQXOm9nmyrm0BOqx9mrqg0lT5lk8ROjqLcd4iLX/jrbhfhM7imMIbWFYsM8cnPBPZbKmXBjq1yInMf2xmS5h9GhnvMY6s3zg1bmNM55f9rACXXCQ3vFkWwzcvotN8+lllXMgIl3c7cXk2kxFNJlfGxeecI2IfPtUvEmvFjjlHbU4Reg66Nypkf0JdsK3NS81V 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 Acked-by: David Hildenbrand 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));