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: 13244077 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2C578C77B7A for ; Wed, 17 May 2023 02:22:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:From:Subject:References: Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=gc+YVDMflBHvPcaXnm9DlVfMKmB0Nxr7jZAV66Oq9Fo=; b=ke0RAb+EiMLET9NiDTnDcQWnF8 d57+pb4BUnwulKp8gErT1oB308oc8wnkhzY3XstWu9282DAq0TBIvd4wI8NeYkSO/AH5va4mj1VBt OJ9ErYP8nUPYbyuXMbX3xt0r7+L3opyEHnu38bG4NIEJgMS2heddNgHlR8txwS2d4DDefVBkFPBgt tUKBDY4bUwHXTvA6PBfWKJXnIx/WrUMbBctjUZ+JjR524ZNWXtoWt6cY95hKAnFxd9lq9KvH5A6MJ /D+CcjBBUdx08Wa1BlYLj/L8+WPqxqD0/SG423jvtcdSgkyo3dj39lNkniEAcz6Vye9Gc+GKOEk+Y AKYDEcHA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pz6nM-007oN3-31; Wed, 17 May 2023 02:21:40 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pz6nI-007oLG-2M for linux-arm-kernel@bombadil.infradead.org; Wed, 17 May 2023 02:21:36 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Type:Cc:To:From:Subject: References:Mime-Version:Message-Id:In-Reply-To:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=DmZ7qJu2QJbmubDEgRMJhswdry7Qhukww11ZPOJRgvs=; b=hFtI8STOOhMnK8MeBragv6P7wD HepdtQYM6nMPiPomJr9PEhWqn8ijOQVWHWzkLFqg8LvSrqhgHO92DqViMFbvuwoysPhIYAw9Zmv6L un7KuL79rwemsS9vLEAOg//PfywXGaO45fjPCEPc2D2J35wPHXmp07BJ5cR632CTL5JJRCqZgrRRP 8ox6AYs/gSIS0e/eyNt7J1H05cX9hPZnMlnXI5T3eaYqC2rojf51iTWuukjbVZ2wwl5OlFHI0QAKG D36RJ5zfuKPiGwcxAViA1ZicP2kOUa+d9xmtlDIVzeOgxAewr4Nv6Pd9ulfVB/ptqLO9KIqpKf+08 RGkD+y0g==; Received: from mail-yb1-xb4a.google.com ([2607:f8b0:4864:20::b4a]) by desiato.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pz6nD-00CqdI-2w for linux-arm-kernel@lists.infradead.org; Wed, 17 May 2023 02:21:35 +0000 Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-ba8217b3d30so145544276.2 for ; Tue, 16 May 2023 19:21:29 -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=Jvx+4tfsguhs1rS48sJM9MQbkRUPvV3K+XoXdtmgMnuMOv2L3gxDIMQRlbnmVMrim4 f31VcypZN8DI2yANtAH+LSyIiTGudVoS5070Jj55hqGkNi041jaJaIpJBcKtioswD5pq HvTd8qIRL6VWTS7bl11jd+T/Kf90xd4QwaSB1L3tF7Vs0aPK3jX7Q1iJTa9fYmhY/v64 RL/4z631OJmdrlPlbo2oSme1pTDk9daKnj55P2KeGFaDFr7pcdqcv2lsVrWmqmwiGoII Q9q0WgvQzXCH6LBoUeH2p/UD+YUztKrzD8luVE6lOBRYA/Maeq/BECnhjDPtXjLLRZeD EhvA== X-Gm-Message-State: AC+VfDzqucJNM9xLlayWR8YotvVRBeSPBRe9B9QPw/v+eDgu9SGRryp3 Rgq1Q3swyuv+BtuMnWmbUAA4P/A= 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-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230517_032132_928071_BDF26BD9 X-CRM114-Status: GOOD ( 10.33 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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));