From patchwork Tue Apr 11 09:36:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liu Shixin X-Patchwork-Id: 13207214 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 DFAA1C7619A for ; Tue, 11 Apr 2023 08:46:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7583528005B; Tue, 11 Apr 2023 04:46:37 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 708466B0115; Tue, 11 Apr 2023 04:46:37 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5F7D128005B; Tue, 11 Apr 2023 04:46:37 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 4EE5A6B0114 for ; Tue, 11 Apr 2023 04:46:37 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 1597A80C59 for ; Tue, 11 Apr 2023 08:46:37 +0000 (UTC) X-FDA: 80668479234.10.E6B75DC Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf23.hostedemail.com (Postfix) with ESMTP id EA762140004 for ; Tue, 11 Apr 2023 08:46:34 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf23.hostedemail.com: domain of liushixin2@huawei.com designates 45.249.212.187 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=1681202795; 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=je03xyokmlBWxYFl2DZYYHgj8uutzvGf5209nikV5zw=; b=Z9YEwXSO4hZl2anwVxboj5jVBuJyVwE/tjHetWxrLu0H/XWpqswuXEYrJtoR6aIBMAT6VY XuErPwiLEF1P3yKN9Lt2pujyOzeO5c1POcD/m64t8UOomBhh6DyfnCbQV+aRuyErKYK+wT x+ame+lKFqktWO60vE3IUVxLrSDFJ4s= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf23.hostedemail.com: domain of liushixin2@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=liushixin2@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1681202795; a=rsa-sha256; cv=none; b=xGAM2x+7b3zKlJW7LxDKSPVU1IL6JfZ65vKuM+4Grt1Q8WRPok7+zVbj17UlogkPe2BNb8 RfYYzsz3YAH4KHX0Y6AaY4iezd0UyqUlKHwSwqxT4AjnAdnzIqzewJAI7ahPUOknloS8nZ iPyf494mdOnmlw4A7kYDODkeAqKTQso= Received: from dggpemm100009.china.huawei.com (unknown [172.30.72.54]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4PwfYJ4cSqznVXH; Tue, 11 Apr 2023 16:45:08 +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.23; Tue, 11 Apr 2023 16:46:30 +0800 From: Liu Shixin To: Seth Jennings , Dan Streetman , Vitaly Wool , Andrew Morton , Nathan Chancellor , Christoph Hellwig CC: , , Liu Shixin Subject: [PATCH -next v9 0/3] Delay the initialization of zswap Date: Tue, 11 Apr 2023 17:36:29 +0800 Message-ID: <20230411093632.822290-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: dggems701-chm.china.huawei.com (10.3.19.178) To dggpemm100009.china.huawei.com (7.185.36.113) X-CFilter-Loop: Reflected X-Rspamd-Queue-Id: EA762140004 X-Rspamd-Server: rspam09 X-Rspam-User: X-Stat-Signature: m9ajra47s5mxth91ybmye4gguycjxaey X-HE-Tag: 1681202794-731776 X-HE-Meta: U2FsdGVkX18xkAEarOsbAbq0N2O8QWGmOvc9/dCCoKrO6MwwxQPHW/rw1haeWd3yb38WKjTlOa8+W0/uq0pmBs9/j5QEmGmneBJwKKOD23pbrTGeTWgj6mQYO8M6GfhW0HXNKlmGkj+p7eTvaYJ7rXWXnQdRZNDUSaYqvlUhr9bVgZimw1ku2z+34mWYW/v40OIu0l8SYyQsVbRCTXUJ+MusaMsrnFoo7SnZCJOh25Rlun85lznPSY7qvJ3k1CgId1k45nkjTDnD97jam7IA2ctZSiqtVvnnfo+42pd1VVBPtAPjnLHbn4OiS9asFQj9H0L90VT4oySK0dduRyNiHnTwYKA5+EEJRYOoF0zpoMRbQnbBOezhM6LgLBUUtNhTcj2GjFwxijCUBbGL2mlZXXca+VtK9R3vBjkkBJ9cACPwwUvRnTh8XSABVtB6eUDrNAiFqCuB0EFbCi2AWtAfkw3vZIOoQHdojttBrZmXtVH2gSuJpB5kT01MDfKJN/zgE1ZSDJgZbBQhfxdEahIR8lljstu2NT4PRAMq3pxqe80vznJWazScnUsANXpIDuBMY632YnWKIdBRZpwHs7VElA0lGfOeeVbIU3fB6Bf/lmFyisVBsSLRVNftGMUtLAbmWq5WJxgbxq/qZAbfnoWF7b1Amd8wph/2F4Y1ITPANmTXOTOKt169oYO04vcwfjPV/c1bkNzTqY+Uft0LT9f1avG77kZuNVU0Dl5S9y/YgrHk4nmW994mTnDs9f2de95ZsFLBWHIpC0TL85OdyQsPdA8t9/8MQrxF4ENl3gVl/aTgnpDXiQwp/LN2ez1O6D8ruQA4EsQX1L2WAP0DEgGi8fCYkz6QaQm8mIRW3fkRoII229SQBJBzk4/g9A75+l6bg+pO00qqDJ5BJHGs9qicj2XOlyIdgvshCJXxnZpxPy30NkrJgXiBbmQrQuF72NrlzcELgu0V0jZeos0mVCE xQfTpmib HHRDL9b9Q+/rfDhvEjKAgksEWH/6Lqnu1setM0C4pPsnlgQpZxHuU37l+5UQYNM+LryN5/OqhVupX1ebCB7AM2n4M3f1YtPcAuhYfrdjGKzjyukayXPq7LguAuKK/+aB1KoRmJArI+G7yCog= 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. v8->v9: Fix some pattern problem suggested by Christoph. v7->v8: Do some cleanup. And remove the second patch in v7 which is unrelated to the initialization of zswap. 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 (3): mm/zswap: remove zswap_entry_cache_{create,destroy} helper function mm/zswap: replace zswap_init_{started/failed} with zswap_init_state mm/zswap: delay the initialization of zswap mm/zswap.c | 122 +++++++++++++++++++++++++++++++++-------------------- 1 file changed, 77 insertions(+), 45 deletions(-)