From patchwork Mon Aug 29 13:22:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liu Shixin X-Patchwork-Id: 12957726 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 DD864ECAAD2 for ; Mon, 29 Aug 2022 12:48:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 35B92940009; Mon, 29 Aug 2022 08:48:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 30A74940008; Mon, 29 Aug 2022 08:48:40 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F3EFE940007; Mon, 29 Aug 2022 08:48:39 -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 D108A940008 for ; Mon, 29 Aug 2022 08:48:39 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id AFE59A0303 for ; Mon, 29 Aug 2022 12:48:39 +0000 (UTC) X-FDA: 79852609158.12.56B45ED Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf31.hostedemail.com (Postfix) with ESMTP id 084E220036 for ; Mon, 29 Aug 2022 12:48:38 +0000 (UTC) Received: from dggpemm500020.china.huawei.com (unknown [172.30.72.54]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4MGVVz3fFGzYd0m; Mon, 29 Aug 2022 20:44:11 +0800 (CST) Received: from dggpemm100009.china.huawei.com (7.185.36.113) by dggpemm500020.china.huawei.com (7.185.36.49) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Mon, 29 Aug 2022 20:48:33 +0800 Received: from huawei.com (10.175.113.32) by dggpemm100009.china.huawei.com (7.185.36.113) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Mon, 29 Aug 2022 20:48:33 +0800 From: Liu Shixin To: Seth Jennings , Dan Streetman , Vitaly Wool , Andrew Morton , Nathan Chancellor , "Christoph Hellwig" CC: , , Liu Shixin , Kefeng Wang Subject: [PATCH -next v4 0/6] Delay the initializaton of zswap Date: Mon, 29 Aug 2022 21:22:56 +0800 Message-ID: <20220829132302.3367054-1-liushixin2@huawei.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Originating-IP: [10.175.113.32] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpemm100009.china.huawei.com (7.185.36.113) X-CFilter-Loop: Reflected ARC-Authentication-Results: i=1; imf31.hostedemail.com; dkim=none; spf=pass (imf31.hostedemail.com: domain of liushixin2@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=liushixin2@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1661777319; a=rsa-sha256; cv=none; b=3cpMpFl7ajn6BTP/GyRirAStyDJ1FHAJh2eNJW/QcQRT+cy9GAz4s0XD/lCvQ8wLhROEF9 fZICtpDi0Xtl/52KmuD3v9JhwPz3UOuXI6F7bCH9K54YS2l7d7gYZ9fBX2JfM6dgJBmx55 e8LC384NMdTJ3s8pFZNMa4aqmXHlj6U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1661777319; 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-type: content-transfer-encoding:content-transfer-encoding:in-reply-to: references; bh=Bzs60Hpc3is6lp7YzGaH4IU3xzLub7mijgFqU5gppUA=; b=VI2YmhMwBy+VzazDc3Lvel7YulIIeQzPaEIoPvZHQ/A/R6NyWRe6zpRZGqUsw514L0seBT faDCe2QHQEA3oMZ+mZjZ1kWFliGxMhzANaMPOJkTTZKwvtlU/CT1vDTjPm8uDZiOXLk6nF gRUeY0w4PZQNO35AMVjgMv87IXWMSts= Authentication-Results: imf31.hostedemail.com; dkim=none; spf=pass (imf31.hostedemail.com: domain of liushixin2@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=liushixin2@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com X-Rspam-User: X-Stat-Signature: z64wtzmtsjqjqkinnkzybtejswocor45 X-Rspamd-Queue-Id: 084E220036 X-Rspamd-Server: rspam12 X-HE-Tag: 1661777318-186886 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: In the initialization of zswap, about 18MB memory will be allocated for zswap_pool. Since not all users use zswap, the memory may be wasted. Save the memory for these users by delaying the initialization of zswap to first enablement. v3->v4: Revert three patches to replace previous patch[1-2] suggested by Vitaly. v2->v3: Fix frontswap_ops NULL reported by Nathan and add init for online swap device in backend register. v1->v2: Change init_zswap to zswap_init suggested by Andrew. Liu Shixin (6): Revert "frontswap: remove support for multiple ops" Revert "mm: mark swap_lock and swap_active_head static" Revert "frontswap: simplify frontswap_register_ops" mm/zswap: replace zswap_init_{started/failed} with zswap_init_state mm/zswap: delay the initializaton of zswap until the first enablement mm/zswap: skip confusing print info include/linux/frontswap.h | 3 +- include/linux/swapfile.h | 2 + mm/frontswap.c | 91 +++++++++++++++++++++++++++++++++------ mm/swapfile.c | 4 +- mm/zswap.c | 85 +++++++++++++++++++++++++----------- 5 files changed, 145 insertions(+), 40 deletions(-)