From patchwork Tue Nov 8 19:32:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nhat Pham X-Patchwork-Id: 13036772 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 B186AC433FE for ; Tue, 8 Nov 2022 19:32:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 32B4C6B0071; Tue, 8 Nov 2022 14:32:10 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 2DB256B0072; Tue, 8 Nov 2022 14:32:10 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1A4068E0001; Tue, 8 Nov 2022 14:32:10 -0500 (EST) 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 0AB366B0071 for ; Tue, 8 Nov 2022 14:32:10 -0500 (EST) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id DB8EB1C5C90 for ; Tue, 8 Nov 2022 19:32:09 +0000 (UTC) X-FDA: 80111270778.12.E72DDDC Received: from mail-pj1-f47.google.com (mail-pj1-f47.google.com [209.85.216.47]) by imf07.hostedemail.com (Postfix) with ESMTP id 5C9CE40008 for ; Tue, 8 Nov 2022 19:32:09 +0000 (UTC) Received: by mail-pj1-f47.google.com with SMTP id gw22so14722725pjb.3 for ; Tue, 08 Nov 2022 11:32:09 -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=/fmsZ6yPuBdWLDut9uV/WRXSBm+/VHvg2djO9W463cg=; b=IMAaWFuKFcdE6LFTCDhevmWnDnKjOGMzE+wgopbdHEH218c5ommJirHhEKylMJUDIA iT292IbLb/clBh8CvHU0ileiPa59zhyUrnHtX6crGjDqH+DjJ6GhxjVnsx1LrH9coV9N MlLh2PiPaQOEO+bvvvuYbcJNgnvihUrrTg1aOPXm/nH6Oj0VWECb312Ri9KUnPUFb17U CLqDGl257cKfAWwSThX/muWWmMAvghVvWhZ/cMKPaKOiwYViDzM2EL4a1fAch6c0WMdR 0nBwj91j0CYADx2/IOwtKuv263DON8uk9FwOqYrMQ/AQ0BEZ4Y/HO+jsNQzoBB1o0Q9c wvxg== 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=/fmsZ6yPuBdWLDut9uV/WRXSBm+/VHvg2djO9W463cg=; b=BpV5a3agREOTeFY892HU0VjDWSUOo9PljHAOL3FDyvvDRQ5cromdGHwC5pNG8UoZSR In2qVEkfDQ1E8/e76KowrikHv7MWKf2JXIqi9Gu+YsBNLmvvA6Fg0cH0x0Pwl79XeFzK Xyg4AApjWH7UPeTUW8CTe7Hw2ldutQresxg5RwUJfQzETCdvLyHtOmBGi5zvRzlEWRoN O0k0ADBVlDnRpX2zU7TjPLx7eeKW5E7u4kvB6aAD8rX2DD8Nshyio/1HCok8dY/tQrZ2 8tbYtMPNhFQwkl7UI0OuyLZ5fll0prlH005QbQHNLmYZZQ4DP4Q0T5kdo/8xadTXZy4u JOPQ== X-Gm-Message-State: ACrzQf1XbPOCy5uVU9SbfELw8IIqdDlnRp/Ic/A9ej+nrglUtRGJYo/P MtHlfxrfJK5OXYTR3cdb50w= X-Google-Smtp-Source: AMsMyM6T2QQzwBmkEJ7EbwneH7m8cOzAbxK9NTXlZ65s+1gH2SHBqnhSEb+xGz2GPHBRSJc3A5f/0Q== X-Received: by 2002:a17:90b:3705:b0:212:e2e5:c0c0 with SMTP id mg5-20020a17090b370500b00212e2e5c0c0mr59748756pjb.239.1667935928316; Tue, 08 Nov 2022 11:32:08 -0800 (PST) Received: from localhost (fwdproxy-prn-023.fbsv.net. [2a03:2880:ff:17::face:b00c]) by smtp.gmail.com with ESMTPSA id k4-20020a170902c40400b001869581f7ecsm7373877plk.116.2022.11.08.11.32.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Nov 2022 11:32:07 -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 v3 0/5] Implement writeback for zsmalloc Date: Tue, 8 Nov 2022 11:32:02 -0800 Message-Id: <20221108193207.3297327-1-nphamcs@gmail.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1667935929; 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=/fmsZ6yPuBdWLDut9uV/WRXSBm+/VHvg2djO9W463cg=; b=keWLbgJx/CTCDL0QdDNBsumAm2UKvYUzhXvxOws4YUuFNa2CtbuPSXhbfzY2QFpKyd0TSz YZmqxbFxdKi+HcyH1ZrJyzlHII4ral/DzNMYPTVJHsxxYZ5vvYI5EDhbfl5+sCKxbi0jsk BAdEreds2qlzQh5E4aCbk31pm4yMlbk= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=IMAaWFuK; spf=pass (imf07.hostedemail.com: domain of nphamcs@gmail.com designates 209.85.216.47 as permitted sender) smtp.mailfrom=nphamcs@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1667935929; a=rsa-sha256; cv=none; b=Wf6FZkBiTEf2jfBHQZRD/0U4Lu8d4pg55tZD9ELlVTkyIqzSt09wGraQqP12IerUZdktyB vUtHLhbT16wHj7KUaASh1g3jtM1aperi/xOYjMzuXPTZmAFsMqP2dRdnZb2Q8IzYfVLi0k acFYCK/g5QLZ0I0D/ul2yw65NXH1SE8= Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=IMAaWFuK; spf=pass (imf07.hostedemail.com: domain of nphamcs@gmail.com designates 209.85.216.47 as permitted sender) smtp.mailfrom=nphamcs@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspam-User: X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 5C9CE40008 X-Stat-Signature: z6zu75ptbxnf87njgkuy7qzfdg57p5ks X-HE-Tag: 1667935929-16403 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: Changelog: 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 5 patches in this series: Johannes Weiner (1): zswap: fix writeback lock ordering for zsmalloc 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 ops fields to zs_pool to store evict handlers zsmalloc: Implement writeback mechanism for zsmalloc mm/zsmalloc.c | 346 +++++++++++++++++++++++++++++++++++++++++--------- mm/zswap.c | 37 +++--- 2 files changed, 303 insertions(+), 80 deletions(-) Acked-by: Johannes Weiner --- 2.30.2