From patchwork Thu Sep 15 03:49:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liu Shixin X-Patchwork-Id: 12976805 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 A3E32ECAAD3 for ; Thu, 15 Sep 2022 03:16:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 25C858D0005; Wed, 14 Sep 2022 23:16:15 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 20CB48D0003; Wed, 14 Sep 2022 23:16:15 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 00FF98D0005; Wed, 14 Sep 2022 23:16:14 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id E7ED98D0003 for ; Wed, 14 Sep 2022 23:16:14 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id CFAE5401E6 for ; Thu, 15 Sep 2022 03:16:14 +0000 (UTC) X-FDA: 79912856268.08.7ED483C Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf02.hostedemail.com (Postfix) with ESMTP id 51D3E800B3 for ; Thu, 15 Sep 2022 03:16:14 +0000 (UTC) Received: from dggpemm500022.china.huawei.com (unknown [172.30.72.55]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4MSj0L60j5zNmK3; Thu, 15 Sep 2022 11:11:30 +0800 (CST) Received: from dggpemm100009.china.huawei.com (7.185.36.113) by dggpemm500022.china.huawei.com (7.185.36.162) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Thu, 15 Sep 2022 11:16:06 +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; Thu, 15 Sep 2022 11:16:05 +0800 From: Liu Shixin To: Seth Jennings , Dan Streetman , Vitaly Wool , Andrew Morton , Nathan Chancellor , "Christoph Hellwig" CC: , , Liu Shixin , Kefeng Wang Subject: [PATCH v5 0/5] Delay the initializaton of zswap Date: Thu, 15 Sep 2022 11:49:58 +0800 Message-ID: <20220915035003.3347466-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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1663211774; a=rsa-sha256; cv=none; b=pEyY5Jy0lljEMJoxgADwukAtL5WsVpvhxHdYmo2kYm8JmkOGXmbfbrN8bx0PYXeF1yPotF nqoLgc825aH47DlkuVpuYep8ZqgHbTBcVrPnBqCSJ58ppVDuzl1AGLGZr+ucb0PEHizsBF QcQ24rS/DxhsBdE1W7AOZ7+wzmZwDAw= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf02.hostedemail.com: domain of liushixin2@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=liushixin2@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1663211774; 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=xEDOvvoJsh5qS8P0XRi3clUSEVkv7joRL3JwFAvZa0Y=; b=GLMxF37+AZpfluvpIjwcPH0S3xmko78Ofj/t+NZA2fj9bD1RC+oXWzyUQEx85kZJYt1hhf aIBcF43Bgq+PNVfXupFDw3TFyiXtkXfVwXo+UCLwkXdNhYiCbJW+ViH1MAxWczUrkr5WFR ob0hdHRTakparkbI5+PJuOKwpf6YwEA= Authentication-Results: imf02.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf02.hostedemail.com: domain of liushixin2@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=liushixin2@huawei.com X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 51D3E800B3 X-Stat-Signature: aj4dy8uqps4uuu684h9p1hy5d4zkhhm1 X-Rspam-User: X-HE-Tag: 1663211774-863301 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. v4->v5: Rebase on next-20220913, the previous first patch is superseded by patch ("frontswap: don't call ->init if no ops are registered"). 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 (5): 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/swapfile.h | 2 ++ mm/frontswap.c | 42 ++++++++++++++++++++++ mm/swapfile.c | 4 +-- mm/zswap.c | 77 ++++++++++++++++++++++++++++++---------- 4 files changed, 104 insertions(+), 21 deletions(-)