From patchwork Sat Aug 27 10:45:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liu Shixin X-Patchwork-Id: 12956960 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 F3676C0502C for ; Sat, 27 Aug 2022 10:11:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 12F996B0075; Sat, 27 Aug 2022 06:11:43 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0DD9F6B0074; Sat, 27 Aug 2022 06:11:43 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EC69E940007; Sat, 27 Aug 2022 06:11:42 -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 DA2E66B0073 for ; Sat, 27 Aug 2022 06:11:42 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id B384F160410 for ; Sat, 27 Aug 2022 10:11:42 +0000 (UTC) X-FDA: 79844956044.21.5FA420E Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by imf27.hostedemail.com (Postfix) with ESMTP id E4B9440027 for ; Sat, 27 Aug 2022 10:11:40 +0000 (UTC) Received: from dggpemm500020.china.huawei.com (unknown [172.30.72.53]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4MFC7l50fVz1N7Z8; Sat, 27 Aug 2022 18:08:03 +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; Sat, 27 Aug 2022 18:11:37 +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; Sat, 27 Aug 2022 18:11:36 +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 v3 0/5] Delay the initializaton of zswap Date: Sat, 27 Aug 2022 18:45:55 +0800 Message-ID: <20220827104600.1813214-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: dggems705-chm.china.huawei.com (10.3.19.182) To dggpemm100009.china.huawei.com (7.185.36.113) X-CFilter-Loop: Reflected ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=none; spf=pass (imf27.hostedemail.com: domain of liushixin2@huawei.com designates 45.249.212.255 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=1661595102; a=rsa-sha256; cv=none; b=DEbMIko/9+KGQqjXJSihQiXeVDK29W7meDKzy4sUSq2wWFHryqF6ytUEGTtzwJzdB+urvH qJLBOdbPltW/cODJ0EJlERVI1YZTPbAeMWfJ1yi8/BuYeCzBsoHHHYECVBC1HqmswwOsbe +GoEBj4aqOUqFtlYa2czFqTlpjSStOY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1661595102; 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=k0posIr2rzx+UGJbMeuJ21xBGTnEY5Us1ZLG8sJQ3Kg=; b=yRyyT1LADEjQAyfMIvWERyKdImOS9szRtA1k/cgNsLSa7HuArE+Gu2gQCthIzBGdi3jxc0 QE0agSay1H0mby0BEr8GhwBd1SFjprClHoWSBBbDNSFlLiGYQytc8+e5HIsf/YtMh0ONDS As3SOVnOieHl5FAX9tIsUMbgBKTaOjE= X-Rspam-User: X-Stat-Signature: wjxzufnhkaaebmaszky7quqygcigbfkp X-Rspamd-Queue-Id: E4B9440027 Authentication-Results: imf27.hostedemail.com; dkim=none; spf=pass (imf27.hostedemail.com: domain of liushixin2@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=liushixin2@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com X-Rspamd-Server: rspam09 X-HE-Tag: 1661595100-303043 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. 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): frontswap: skip frontswap_ops init if zswap init failed. frontswap: invoke ops->init for online swap device in 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 | 50 +++++++++++++++++++++++++- mm/swapfile.c | 4 +-- mm/zswap.c | 77 ++++++++++++++++++++++++++++++---------- 4 files changed, 111 insertions(+), 22 deletions(-)