From patchwork Sat Mar 25 07:14:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liu Shixin X-Patchwork-Id: 13187624 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 1B402C6FD1F for ; Sat, 25 Mar 2023 06:24:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7C5656B0087; Sat, 25 Mar 2023 02:24:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 77532900003; Sat, 25 Mar 2023 02:24:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3F417900002; Sat, 25 Mar 2023 02:24:31 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 0E9F26B0088 for ; Sat, 25 Mar 2023 02:24:31 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id D45D6400FD for ; Sat, 25 Mar 2023 06:24:30 +0000 (UTC) X-FDA: 80606431500.16.AEB67D0 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by imf21.hostedemail.com (Postfix) with ESMTP id 770A71C0004 for ; Sat, 25 Mar 2023 06:24:28 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf21.hostedemail.com: domain of liushixin2@huawei.com designates 45.249.212.189 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=1679725469; 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=YqRJjmGqyFTC/0k/czhpubg7zFqQ7v4LwXzVttNzS/o=; b=AIHjtQBMw+ynAlXodctBrgRVeoic/7Bl5qT4BQo0al/2zbY0F1zIxnrfVz1qRwTb+c/e4y UnH8TiDuuTJ0an6gmybYewSzFjtEsNvkeH2372cUtHzqyweG7z4SFblVEtj5aC6ICd8o8e 9E+SzLRx4fYxiBjIBtexp59r9jQWX58= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf21.hostedemail.com: domain of liushixin2@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=liushixin2@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1679725469; a=rsa-sha256; cv=none; b=MQFThj7vke1KH77hyhZZrAmmRlYChtyWwPqvwsAlNeSntxAFqZNvRPzbVjHcoUCIxWUKvJ k7j9KSTuTZg7MQGzyTGdMPn5qVasSFXNiryb6scPkzp92DKh5FrHPfaYJKSXwn8UZ4hZC7 Y9fW82H60XtT4wzoUOneSqA5df7hBJI= Received: from dggpemm100009.china.huawei.com (unknown [172.30.72.56]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4Pk8DF1KNjzKmMW; Sat, 25 Mar 2023 14:23:57 +0800 (CST) 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.2507.21; Sat, 25 Mar 2023 14:24:21 +0800 From: Liu Shixin To: Seth Jennings , Dan Streetman , Vitaly Wool , Andrew Morton , Nathan Chancellor , Christoph Hellwig CC: , , Liu Shixin Subject: [PATCH -next v7 0/4] Delay the initialization of zswap Date: Sat, 25 Mar 2023 15:14:16 +0800 Message-ID: <20230325071420.2246461-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 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 770A71C0004 X-Rspam-User: X-Stat-Signature: trj6uf93in7pnw6zgx4nn5dqayc9577e X-HE-Tag: 1679725468-938812 X-HE-Meta: U2FsdGVkX1/PJHTfYBrK4WhlDsc2in8xOd5KK1Ksctkl2peiFk2WfM6j2c8uSk8+F9AJdTms04e4NRKtRpLp+flWkoMQPJSI28J7puyBS9ZiawOkCLZtg09m4ettWPyufvYvH8yJHw66c4fgKYTL5qfc22sw4wraheoO4cRPKUhCvvW33Bp6fIxt45n2BoHFmkN4WE+8krTr7k4xJfc+YNH7k8jNREYV8jSQoRReOxuKn/VscNzhYcVjyJuFQRRNyaR2mOx6m1+/TVdAho3zRWpU6gXpBo5E5YGF0wAvaQJdtbfw6UEATcQnEbTC2Dp4BobsWtf8lxfylT1KlqL9EB2y+mVUQk8n/DeUZ3mROmBcjQMB2J4jXWQXEPxMtkgRrjm/DgMqZHWUjqu8SMldRLjkDcIi0tfx5sRUD7MUgnTPrIknuEih0bqKnknep8w1yOggSjVgc5jZdkRV1jxwgNy5yUZZBwl0eepEoR3x9Iaynk0JcAMqMked49mHNHedOtYUs++yeQzLuA1tniS7Cvy/wuOEfR+Ct6JNXIJ8PpHaFYx0SICfcBDIwfVDBwLGjyOuckRR3LYBU4PxffkGMeiy5ak5o3N22Iqf0gYjuKOZxs48Lr0Z6LCgVyRMeI3Dx5Oewx41OhkqP+a29i4f69FXyHCe8omQJ7TCG+E1Ea+fByhwmeyYv+7vgh9xLMLfLIzJMH0vDc00BdpVm81dp8c6PLa9UiFBNu1btvQCE5yK1L89Lc+kFfvWxmb1MPxLQjLhh3ODlF876ViNFK1qYsyH/ZhhSZpiXunkhIBXcaMy5OUHuuwpCfkaYmrphgGWLl3KrRLPuwKvu0+79LBTYJaIDtydN3h0Sw8I/0iELwMqfn2a9OYWLIhn9ieiESq7OvsxZS7nxCxSNs63jeyhuEhpAA7u26md0YWXlIfjQfywSOVWVcNJaavMQ94LauT3yJJsg4+NRVQc3Ix36Ik CxrkGZet RBdqSiOe9MwiQgXhmytzDeB8I0Xl9O7GNGJblpG1GMg+q+Bvmf9xbEeFeTVBKAzK8qUogOGDy6sUwSY6h6wG5leWvnF5oOyx2fBqQx2FKJJIAiY8JCUfcB1BOD9dfpgHWThN0y2Vq67S3tgg= 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 some users may not use zswap, the zswap_pool is wasted. Save memory by delaying the initialization of zswap until enabled. v6->v7: Add two new patch[1,3] to cleanup the code. And cover zswap_init_* parameter by zswap_init_lock to protect against conflicts. v5->v6: Simplify the code and delete the patches about frontswap suggested by Christoph. Liu Shixin (4): mm/zswap: remove zswap_entry_cache_{create,destroy} helper function mm/zswap: skip invalid or unchanged parameter mm/zswap: replace zswap_init_{started/failed} with zswap_init_state mm/zswap: delay the initializaton of zswap mm/zswap.c | 94 +++++++++++++++++++++++++++++++++++------------------- 1 file changed, 61 insertions(+), 33 deletions(-)