From patchwork Fri Nov 18 18:24:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nhat Pham X-Patchwork-Id: 1926 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp353320wrr; Fri, 18 Nov 2022 10:46:33 -0800 (PST) X-Google-Smtp-Source: AA0mqf6qtVtqUoeZmcikOww2MdiVP/cQfMwN4bwuEj6/SRZa6bxf8R6dIq2ueP9JU6YB7sU83fdH X-Received: by 2002:a17:90a:4147:b0:214:2214:869e with SMTP id m7-20020a17090a414700b002142214869emr15575975pjg.76.1668797193555; Fri, 18 Nov 2022 10:46:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668797193; cv=none; d=google.com; s=arc-20160816; b=Wax96Sdph+4pS8JzsGVpEPJPW1tX1R6C5BI0EqRQVfOueqikTNOM1KjRLnFtQxnIMe Fv7KHiuDedqa1WbHxQRSYbWyW3f8670UdbhWlqfTx1qzX0DRvaFUcjc/de54Z5AXKcIV NMo2rm1CF20dGpdQnU+x6lpoL3rNoKtAQdHtvKymwRd1UY9JokVVrMHueHxHJCnR3U8N ubb8Wr+r0iCAHLqK5GP3Ozi57B54mmF9PpNm78JuldRoU5iPKLYdrH+LnmOMCac0i0hr tYKtCkAy4uRWw9uUV61/K4IeH9PdPBf+faN1mvEuJm1CEcb0YQ4iV88mlY4P7Osq+sta DOrQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=6E6GpRuxKdp+o4hP203uhjB5+UZzDZfAaY7rEhcjmoU=; b=1GOsRUxvB0crpHB/iCQT2szY/a+xa7DgH2nbvIYEl9gAZm7kiaC196NmpQHk5fzK64 0O/d4zrCOR2+mU+nIlRX0RipohLpWIDzj76An4BI4m33r9z9Bvpj7Yj5n6QbzxzFMKji WFXZ/cG3+FWfbxMz3FQ/U4z9IXNglPj7+LW87LL+T266Y3mrwRpJbxoJNTjZmCfpD1d1 usJI0P0HuTBvtiBe6L142Mazeb6V1DbqecCcSFm0M1w6kBlGrCUT4TJZ3BN9XxX/0FKC Vm4EYBqbV9CekLWadDHRwK53npqWJMilpuTdLJAB4ywelYGnvxGHcXGmDpXph514Btb5 tJ6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=dgQqcKyO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bj16-20020a056a02019000b00476deba07a7si4773581pgb.229.2022.11.18.10.46.20; Fri, 18 Nov 2022 10:46:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=dgQqcKyO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235357AbiKRSZ1 (ORCPT + 99 others); Fri, 18 Nov 2022 13:25:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34252 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242696AbiKRSZI (ORCPT ); Fri, 18 Nov 2022 13:25:08 -0500 Received: from mail-pg1-x533.google.com (mail-pg1-x533.google.com [IPv6:2607:f8b0:4864:20::533]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B2C01942F5 for ; Fri, 18 Nov 2022 10:24:12 -0800 (PST) Received: by mail-pg1-x533.google.com with SMTP id 62so5641135pgb.13 for ; Fri, 18 Nov 2022 10:24:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=6E6GpRuxKdp+o4hP203uhjB5+UZzDZfAaY7rEhcjmoU=; b=dgQqcKyOimQp9XMKebGUyN62bGP1UyhSB1dXOIepkhFhQ0u7EuSIgK+z8cl7HS0+ax EqjZZK1zIob55ymdYqhT4IwS7jEI8Yeh0p9KpRYMBIqts3w/93LM7KdqmxEccD1GjB0/ ruUhKy7pFSb+aul93ooT1CmBJg7TjTKLBPA9SnHqaellRHZbJ+9aPHmTieZMt0Aa+N90 1tbhlT0FU6eSn3xTFq7s9fGhTR/ToyRuCe+zP4quCJ5KU4E/4WlTNSheFhu0kfEyKnRB zUueRTftg+8PW0Egi+dD0SaWA7Ydcn2IH4geFv5val8I4nMWaNzp9QjMDd+l0dariIM8 437g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=6E6GpRuxKdp+o4hP203uhjB5+UZzDZfAaY7rEhcjmoU=; b=il9z2VrBQxBvPEW3mU2lR40y56CHKS/9ZasuAywkkQzQmW63+O8uL0A8uBNXcdz6Ys B2exOBfKrjrCO/9nKn+Ti3vWtsNcRmZJ0/SgOUtQMd3uwNrRT9ztAJ2MiZgjqA/FLkSq Zx9EJslBj37I1EeJMLrLzQnbHXqPGriwKFvAMDDlqBOPSPK/y2nPrHIxYdkNT/vym4VJ 8Hd5fwKKnvzbwxk1PuMBnhz0T3y1lk5jW5KnOpUWCzMBQtCNb/isAYyEuDfSYpjPWXAZ /NzDC7/4kKTp3L/uBB2dh3juJkqs6klHI3TKja+FgMZAWkeW1OjbR8jDfjKuu9X0ohyW al/Q== X-Gm-Message-State: ANoB5pl3yBHaeB3ZISJvYIRCNvrP6QrDV+esVeAWpMScw4RTrhryi0t6 66xxKshuw4wzhJhkDSxMojnWEwIE7deBrg== X-Received: by 2002:a63:fa49:0:b0:476:f92f:885b with SMTP id g9-20020a63fa49000000b00476f92f885bmr7784709pgk.31.1668795849138; Fri, 18 Nov 2022 10:24:09 -0800 (PST) Received: from localhost (fwdproxy-prn-005.fbsv.net. [2a03:2880:ff:5::face:b00c]) by smtp.gmail.com with ESMTPSA id d10-20020a170902654a00b00188fcc4fc00sm2304255pln.79.2022.11.18.10.24.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Nov 2022 10:24:08 -0800 (PST) From: Nhat Pham To: akpm@linux-foundation.org Cc: hannes@cmpxchg.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, minchan@kernel.org, ngupta@vflare.org, senozhatsky@chromium.org, sjenning@redhat.com, ddstreet@ieee.org, vitaly.wool@konsulko.com Subject: [PATCH v5 0/6] Implement writeback for zsmalloc Date: Fri, 18 Nov 2022 10:24:01 -0800 Message-Id: <20221118182407.82548-1-nphamcs@gmail.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749860686078924756?= X-GMAIL-MSGID: =?utf-8?q?1749860686078924756?= Changelog: v5: * Add a new patch that eliminates unused code in zpool and simplify the logic for storing evict handler in zbud/z3fold (patch 2) * Remove redudant fields in zs_pool (previously required by zpool) (patch 3) * Wrap under_reclaim and deferred handle freeing logic in CONFIG_ZPOOL (patch 6) (suggested by Minchan Kim) * Move a small piece of refactoring from patch 6 to patch 4. v4: * Wrap the new LRU logic in CONFIG_ZPOOL (patch 3). (suggested by Minchan Kim) v3: * Set pool->ops = NULL when pool->zpool_ops is null (patch 4). * Stop holding pool's lock when calling lock_zspage() (patch 5). (suggested by Sergey Senozhatsky) * Stop holding pool's lock when checking pool->ops and retries. (patch 5) (suggested by Sergey Senozhatsky) * Fix formatting issues (.shrink, extra spaces in casting removed). (patch 5) (suggested by Sergey Senozhatsky) v2: * Add missing CONFIG_ZPOOL ifdefs (patch 5) (detected by kernel test robot). Unlike other zswap's allocators such as zbud or z3fold, zsmalloc currently lacks the writeback mechanism. This means that when the zswap pool is full, it will simply reject further allocations, and the pages will be written directly to swap. This series of patches implements writeback for zsmalloc. When the zswap pool becomes full, zsmalloc will attempt to evict all the compressed objects in the least-recently used zspages. There are 6 patches in this series: Johannes Weiner (2): zswap: fix writeback lock ordering for zsmalloc zpool: clean out dead code Nhat Pham (4): zsmalloc: Consolidate zs_pool's migrate_lock and size_class's locks zsmalloc: Add a LRU to zs_pool to keep track of zspages in LRU order zsmalloc: Add zpool_ops field to zs_pool to store evict handlers zsmalloc: Implement writeback mechanism for zsmalloc mm/z3fold.c | 36 +----- mm/zbud.c | 32 +---- mm/zpool.c | 10 +- mm/zsmalloc.c | 334 ++++++++++++++++++++++++++++++++++++++++---------- mm/zswap.c | 37 +++--- 5 files changed, 303 insertions(+), 146 deletions(-) --- 2.30.2