From patchwork Sat Jul 15 04:23:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13314373 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 67DD8EB64DC for ; Sat, 15 Jul 2023 04:23:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9A63E6B0071; Sat, 15 Jul 2023 00:23:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 956516B0072; Sat, 15 Jul 2023 00:23:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 845556B0074; Sat, 15 Jul 2023 00:23:53 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 73ACE6B0071 for ; Sat, 15 Jul 2023 00:23:53 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 4229B160109 for ; Sat, 15 Jul 2023 04:23:53 +0000 (UTC) X-FDA: 81012553146.07.C311C7F Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf23.hostedemail.com (Postfix) with ESMTP id 5C80514000B for ; Sat, 15 Jul 2023 04:23:51 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=PrC2Q5i1; dmarc=none; spf=none (imf23.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1689395031; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=aZOTevyyG/oq7Dcb/mDg4h3vECd5Czx9C+nnro/i/yI=; b=31g/n81Mw97SDNw5sxZ9MmAA2uSlpwjDMBWUIpYnhW1M5AGptklofqy1TyLz8C9XOGSa4Q RlMir3d1BNQxo6uAhVzm1A7p1nxC2D9L4CjnFxW/qP2lLQ2r0gI5fu37PZ8H4uXOCsdsau sGrenf9Y2WcdnbSLIKU6HxsZKGwt7ds= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=PrC2Q5i1; dmarc=none; spf=none (imf23.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1689395031; a=rsa-sha256; cv=none; b=YjSC96J6xyBfYvAO0/HdJAFG11pzy8WYwatCngD5Q2UwqP686o10EyA5dAwA6qngzy/9sn UPUxhbpxtymfnDxyiflh8xxOdZC1/Jzn4aVROMnnZymyM1OjImf70blI54miRNJHu2AHND 5J+dWKYvC6SyTdtGX1JZ8N5ed49CxzE= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=aZOTevyyG/oq7Dcb/mDg4h3vECd5Czx9C+nnro/i/yI=; b=PrC2Q5i1RZUQ3NoWBymN8xdsDw VN9bzJ75Grrvkb2F/xMhSInJJKrjHYSrDiJu9Xz/AD/RyXELC58gEjFJHB7ADGAX8Tnys8yOuV2bM rfGZ4Lxfxnvu/yaz+Gx5bDS54gJNSJ1nA/CirJF8hbPtLQY4p3WMbWLdnOssESTuhpz5rCCKPj46f yu9xO+DnTP0rAlinUHRpeJ102wP6g7teVzOnYWub18YqnzON7d4UeG1hqCCuU5vuAZZyIy97m2TP9 XbUwm9tLEeZywDy7frHNsQXCf/HZi8bjPWB2O1fMmqwoGpZNoJ8u6m17dNfXibTmPDs85K7YUopTG QAzbF+Kw==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1qKWos-001p3q-EK; Sat, 15 Jul 2023 04:23:46 +0000 From: "Matthew Wilcox (Oracle)" To: Johannes Weiner Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org, linux-kernel@vger.kernel.org, vitaly.wool@konsulko.com, cerasuolodomenico@gmail.com, nphamcs@gmail.com, hch@infradead.org, yosryahmed@google.com, akpm@linux-foundation.org Subject: [PATCH 2/5] zswap: Make zswap_store() take a folio Date: Sat, 15 Jul 2023 05:23:40 +0100 Message-Id: <20230715042343.434588-3-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20230715042343.434588-1-willy@infradead.org> References: <20230714194610.828210-1-hannes@cmpxchg.org> <20230715042343.434588-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 5C80514000B X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: n7ek38wxjdibkbwdt4e7wz9zft3431f6 X-HE-Tag: 1689395031-98715 X-HE-Meta: U2FsdGVkX1+WV4yAhCr+Nu/U1JSSiQE9Kq1hnyQc/1QdtqaQnMSLJCELkmj9YOBO3nZV1XD9Zu2VnErQURPrFOaUeh27ilq30RGrqwI70299V9o78AYvX88adxEt5xY1+hXJTsqA0NRLr3jHYtkCsixKfP8Hp60BUkXvOsdjZi6xl9WCmJiwnCn636Z9yRf9HCJMlO9lm2PCky3lxsHvpDZtOxsg/AfWmHdqpFqAIMD+SMl7JbxLK28W+jMcR2Qyq52ISDliythkEPdkoDfcn9s6VRfCwDhMoYwPDMLN0LcYYuWaWuB3mWHI3Lxe/yAQs/0kbLQ+k9D0V2mbvLS9jO+4nq/mBonDwky6jl3Bmpb/gIr8olAFcwGtjKkx9vSLcdSa6jlAhN+77U+J1W2L2GjcZ2l2JGD6RZAxA85599EA6IG9j9r1jCyRRXm9kvNIsp+RBQ6MYl5t7G/xdErbot0AcOj+ZZ/O2N9FiK+ZBAiGqif5kQnDq6xGwvAbbFy/vhVYuRG1qARuf5ZMDvpTWmr/4DICaZaIOj6Ml4/2RBZFyvZsbZnWgRmBLSjgfiNUFQc4P4HMkpYtxXeCRbAoRRWj3d/0xtZ+KpUCn5tcHKmVe0qhsJxpnR4+4u1O/DgqDBENuhHe3N/TanDMM7+D1/CfRYZisjA6F4JwooMYllDHtwCWDysxcq5ceNMxJ9MQvJc56ZyBgvBmxE+23ZFb2k212JzEC3K7tQYLx9BzZJKo+z4dD+75EO60fq661Hg2rSjWqdnV4JL7cgi7r1FCmU64O3dYvuuJBLZYkXYqACbZBwzT3RA/2S0DW+jsEbwQFeNzT2zEq0s1ZKfuu7FJnyPm3IksIsC8ZLqIQW46TKiaInWflLZ2AzFpXJG/qh8JZ4EGOdQJ7Cm7DxBoB8w4qqsSqU0ca5bcdso7EmHWVr9UpKs471nTRvoQeEzdlFkQrtjmunXW1go0T1D0YZl wt8vcbNG gEntoZKP8QC7/84esrEK/PYhC2FVhUwPtjp8ichOTORI+/mf8/yT37g7fgt1zKInRpdHHdajMTGQmOukPQrUjsVTmbvo3PrcHUvl1Y/ml/QuKtasq77Zds5Bb5hxiDqU3NxMYNlu2yOMvKJZebaGHfDuGLT8Zub6RtDA86T5u6gXJ1NHEJDCLiIlEEcjLgI2hvqph3+y5pSZIoxixnFr8UZIcSw+EPuFXv3c6 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: Only convert a few easy parts of this function to use the folio passed in; convert back to struct page for the majority of it. This does remove a few hidden calls to compound_head(). Signed-off-by: Matthew Wilcox (Oracle) --- include/linux/zswap.h | 4 ++-- mm/page_io.c | 2 +- mm/zswap.c | 13 +++++++------ 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/include/linux/zswap.h b/include/linux/zswap.h index 850c377d9b6d..9f318c8bc367 100644 --- a/include/linux/zswap.h +++ b/include/linux/zswap.h @@ -10,7 +10,7 @@ extern atomic_t zswap_stored_pages; #ifdef CONFIG_ZSWAP -bool zswap_store(struct page *page); +bool zswap_store(struct folio *folio); bool zswap_load(struct page *page); void zswap_invalidate(int type, pgoff_t offset); void zswap_swapon(int type); @@ -18,7 +18,7 @@ void zswap_swapoff(int type); #else -static inline bool zswap_store(struct page *page) +static inline bool zswap_store(struct folio *folio) { return false; } diff --git a/mm/page_io.c b/mm/page_io.c index 32afc2a52982..b9fda7fb4e75 100644 --- a/mm/page_io.c +++ b/mm/page_io.c @@ -198,7 +198,7 @@ int swap_writepage(struct page *page, struct writeback_control *wbc) folio_unlock(folio); return ret; } - if (zswap_store(&folio->page)) { + if (zswap_store(folio)) { folio_start_writeback(folio); folio_unlock(folio); folio_end_writeback(folio); diff --git a/mm/zswap.c b/mm/zswap.c index f6a78e085479..ba50b186ee27 100644 --- a/mm/zswap.c +++ b/mm/zswap.c @@ -1201,11 +1201,12 @@ static void zswap_fill_page(void *ptr, unsigned long value) memset_l(page, value, PAGE_SIZE / sizeof(unsigned long)); } -bool zswap_store(struct page *page) +bool zswap_store(struct folio *folio) { - swp_entry_t swp = { .val = page_private(page), }; + swp_entry_t swp = folio_swap_entry(folio); int type = swp_type(swp); pgoff_t offset = swp_offset(swp); + struct page *page = &folio->page; struct zswap_tree *tree = zswap_trees[type]; struct zswap_entry *entry, *dupentry; struct scatterlist input, output; @@ -1219,11 +1220,11 @@ bool zswap_store(struct page *page) gfp_t gfp; int ret; - VM_WARN_ON_ONCE(!PageLocked(page)); - VM_WARN_ON_ONCE(!PageSwapCache(page)); + VM_WARN_ON_ONCE(!folio_test_locked(folio)); + VM_WARN_ON_ONCE(!folio_test_swapcache(folio)); - /* THP isn't supported */ - if (PageTransHuge(page)) + /* Large folios aren't supported */ + if (folio_test_large(folio)) return false; if (!zswap_enabled || !tree)