From patchwork Mon Jun 12 09:38:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Domenico Cerasuolo X-Patchwork-Id: 13275951 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 A88FFC7EE25 for ; Mon, 12 Jun 2023 09:38:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 40E0D6B0072; Mon, 12 Jun 2023 05:38:24 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3BDD36B0074; Mon, 12 Jun 2023 05:38:24 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 25E696B0075; Mon, 12 Jun 2023 05:38:24 -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 141F46B0072 for ; Mon, 12 Jun 2023 05:38:24 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id E2B0F1201A8 for ; Mon, 12 Jun 2023 09:38:23 +0000 (UTC) X-FDA: 80893595286.09.0DDF605 Received: from mail-ej1-f49.google.com (mail-ej1-f49.google.com [209.85.218.49]) by imf05.hostedemail.com (Postfix) with ESMTP id 1C51B100014 for ; Mon, 12 Jun 2023 09:38:21 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b="F+XqBLr/"; spf=pass (imf05.hostedemail.com: domain of cerasuolodomenico@gmail.com designates 209.85.218.49 as permitted sender) smtp.mailfrom=cerasuolodomenico@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1686562702; 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:references:dkim-signature; bh=XfQ5vz07/mwEtSuWTr+saoqBNiKtLGt2UshbSYxHSJg=; b=WNa6HbBOD2a+hj+kJJYdfODzy1nQGqfsJUKw46FGe0REKx/hB/f3xhE+jm+1AjThDez2VS KFN5fMRXYC97g7qF/D/zj3JGpXpK7spNkFFJp/qNOApRUfRX2PyK5PQkyKpozrcnH0zSnB 6FcL3ksCClE6nmWipnWxkTkfrXie9Uk= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1686562702; a=rsa-sha256; cv=none; b=QD7X8CldQE0Ah15U4z8gBW7g1+9YPvugjRrdGniJlqVffDFiVdWoT4PNNha4hESD6VJc/p YzMumlB+jsQdcc9XzLAa+mPua3PAHt2xZHabM9lQIsbVDTQl8WaSDiLBAasyCT9nX+KozJ 5XmDm8uVQUYdnIW7iPrAGI2pdxKv7gY= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b="F+XqBLr/"; spf=pass (imf05.hostedemail.com: domain of cerasuolodomenico@gmail.com designates 209.85.218.49 as permitted sender) smtp.mailfrom=cerasuolodomenico@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-ej1-f49.google.com with SMTP id a640c23a62f3a-9786fc23505so611113366b.2 for ; Mon, 12 Jun 2023 02:38:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1686562700; x=1689154700; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=XfQ5vz07/mwEtSuWTr+saoqBNiKtLGt2UshbSYxHSJg=; b=F+XqBLr/1WjE7Ug2RtuXe2SdhSpBlzDj3oGQnRyVt1d/dtCaD+XXpwXcDrZw4+n2MZ QcEloaAnK59jSL/5pZxzXeDNBVnna91t1rbQmJuA1G5y4xNfdWcL6PKmxm0QoCCV/qu2 mNGA+kPy4057ftxU0VgtHcN01tER2TP3wdJwspu25m7B0kpb1bY3KfUsP438ktxuSIda e/vrpHFjfXX6hV5LCpYJDUeE8eYFpVZ1TvmC58OO/oBmiHAWcTatJ2pO9X9L8k3QwE6P qz0nSOPl576ztcw/4bZysXhbje4eRw7CgIJcxnpHZe38MTpgslcyzdYI+CnbHUGjrMbu ccvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686562700; x=1689154700; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=XfQ5vz07/mwEtSuWTr+saoqBNiKtLGt2UshbSYxHSJg=; b=gU/4kGiIWn+v73hVEElBsxzj79tAQOtDA1v9NqTfCvS+jFkSGp3aA2Sd80VxeYKs4V TXwYE6oJaJQvm4PQjL5QmEZlxcYpeeajKeSatGDvz2gCnQmcB3plDNXEEvxBhzTvA/Vl URXEsK4NnPWyA9PjgCN/aSVGYNbrpIjpiKZqiNO2iCQtDBygZFg9YpRlnWP6drIkQ1z5 Lot8EFr7GRHnGdZZfmd278FCiyfp6WYU3YAcc6k70cwP7J08IPGojxZ2sH5D47j993Zs dVgTjFAeiAKkYsqX9TXlo5k2c/K7pfSYATSlL4YVVlz4/n/C6cJ8HlK5SD5LeGZ7QwXH ZsZg== X-Gm-Message-State: AC+VfDy5cLccOLB4LMyrwfsPop688+gnMsmIrxiwCglL0KasZOUNIUON W4FxYhtvabcnwxszo1Ftfzg= X-Google-Smtp-Source: ACHHUZ6kT4+nqOwRUSv2g8qLyoK/ZLbw0Hrp5QDubdNrVy0Gdaq60JjrgieMiw4EYdkUPFCgb34eIQ== X-Received: by 2002:a17:907:1b1c:b0:966:5730:c3fe with SMTP id mp28-20020a1709071b1c00b009665730c3femr8843144ejc.52.1686562700314; Mon, 12 Jun 2023 02:38:20 -0700 (PDT) Received: from lelloman-5950.homenet.telecomitalia.it (host-212-171-43-8.retail.telecomitalia.it. [212.171.43.8]) by smtp.gmail.com with ESMTPSA id ce23-20020a170906b25700b0097887b68c17sm4951358ejb.98.2023.06.12.02.38.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Jun 2023 02:38:19 -0700 (PDT) From: Domenico Cerasuolo To: vitaly.wool@konsulko.com, minchan@kernel.org, senozhatsky@chromium.org, yosryahmed@google.com, linux-mm@kvack.org Cc: ddstreet@ieee.org, sjenning@redhat.com, nphamcs@gmail.com, hannes@cmpxchg.org, akpm@linux-foundation.org, linux-kernel@vger.kernel.org, kernel-team@meta.com, Domenico Cerasuolo Subject: [PATCH v3 0/7] mm: zswap: move writeback LRU from zpool to zswap Date: Mon, 12 Jun 2023 11:38:08 +0200 Message-Id: <20230612093815.133504-1-cerasuolodomenico@gmail.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Rspamd-Queue-Id: 1C51B100014 X-Rspam-User: X-Stat-Signature: 63yyazjqrcqodeoi1sj8jyu8cfm4smqw X-Rspamd-Server: rspam03 X-HE-Tag: 1686562701-277092 X-HE-Meta: U2FsdGVkX19YhoX6Jdytka7Z/3ejRtHJnYOAwnc657zG5l8neVh36rskugKPV8pWam+OVGfcyQbprSVkLTxdP/x0Tx3gfFBCZwnZ6nshjLras329qYjZlA2frIOIPMy9gcsDEeO/gVI3m9EYV1v68AkXqdSQnNhH4bwKFklDNT/zveFS3vNmSO5d3eecnjZXz60O7dZUfDvRtvZw9bre20CihvkDosTQToS9uyyb1gRRSuKsV9KWovYnD6WGKuDijeyBlV29nn56BH4m2VIGnxN8/OxVjcNkn2mr1lTtC3vTO+L6TOsGrt22JtrcVnN9fOdNiTAmZEumANZQa0nUa/Z4nJu/UmpoCD13mhIIq6RfdButmUZ7tAmaPp2L129adFmvkoVve6I41lTC9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kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: This series aims to improve the zswap reclaim mechanism by reorganizing the LRU management. In the current implementation, the LRU is maintained within each zpool driver, resulting in duplicated code across the three drivers. The proposed change consists in moving the LRU management from the individual implementations up to the zswap layer. The primary objective of this refactoring effort is to simplify the codebase. By unifying the reclaim loop and consolidating LRU handling within zswap, we can eliminate redundant code and improve maintainability. Additionally, this change enables the reclamation of stored pages in their actual LRU order. Presently, the zpool drivers link backing pages in an LRU, causing compressed pages with different LRU positions to be written back simultaneously. The series consists of several patches. The first patch implements the LRU and the reclaim loop in zswap, but it is not used yet because all three driver implementations are marked as zpool_evictable. The following three commits modify each zpool driver to be not zpool_evictable, allowing the use of the reclaim loop in zswap. As the drivers removed their shrink functions, the zpool interface is then trimmed by removing zpool_evictable, zpool_ops, and zpool_shrink. Finally, the code in zswap is further cleaned up by simplifying the writeback function and removing the now unnecessary zswap_header. Based on mm-stable + commit 414fb1ae68b7("mm: zswap: support exclusive loads") currently in mm-unstable. V2: - fixed lru list init/del/del_init (Johannes) - renamed pool.lock to lru_lock and added lock ordering comment (Yosry) - trimmed zsmalloc even more (Johannes | Nhat) - moved ref drop out of writeback function (Johannes) V3: - rebased on commit 414fb1ae68b7 ("mm: zswap: support exclusive loads") - renamed zswap_shrink to zswap_reclaim_entry (Yosry) - compacted reclaim entry function dropping tree_entry (Johannes) - deleted .shrink = NULL from driver-specific patches and re-worded commit messages (Minchan and Johannes) - fixed some indentations and comments (Johannes) Domenico Cerasuolo (7): mm: zswap: add pool shrinking mechanism mm: zswap: remove page reclaim logic from zbud mm: zswap: remove page reclaim logic from z3fold mm: zswap: remove page reclaim logic from zsmalloc mm: zswap: remove shrink from zpool interface mm: zswap: simplify writeback function mm: zswap: remove zswap_header include/linux/zpool.h | 20 +-- mm/z3fold.c | 249 +------------------------- mm/zbud.c | 167 +----------------- mm/zpool.c | 48 +---- mm/zsmalloc.c | 396 ++---------------------------------------- mm/zswap.c | 190 +++++++++++--------- 6 files changed, 134 insertions(+), 936 deletions(-)