From patchwork Mon Apr 3 12:13:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liu Shixin X-Patchwork-Id: 13198065 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 2E5E9C761A6 for ; Mon, 3 Apr 2023 11:23:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B7FB86B0072; Mon, 3 Apr 2023 07:23:24 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B2FD76B0074; Mon, 3 Apr 2023 07:23:24 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A45986B0075; Mon, 3 Apr 2023 07:23:24 -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 9528D6B0072 for ; Mon, 3 Apr 2023 07:23:24 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 58638C085B for ; Mon, 3 Apr 2023 11:23:24 +0000 (UTC) X-FDA: 80639843928.30.D07E1CB Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf07.hostedemail.com (Postfix) with ESMTP id B7BF74000C for ; Mon, 3 Apr 2023 11:23:20 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf07.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=1680521002; 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=b4J1RkZFNn+HR6T4U6Y+WUvddZnJ0U0PI7FKC631Q5A=; b=fzpgUBAVySH2BotTFNEhehKshOU/d55bgLqj+PDtQ3geiLOANJLNJHNWPgB5iLqY6ePIjP Qg6JMBRDlvnm9R8HKRW480D319Zth1qyXm2czYG1bCZ5+95YefEhhNlN8h5IWvC7j4HID3 /xLxS+EYJ9gl6d2OVVKDDFR9DRFdH24= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf07.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=1680521002; a=rsa-sha256; cv=none; b=uRbTJmjDW8gJvvA2OwvJ0UkatH3OtIFYqSscr78CrVn/aZBhO/41IIJqAref5559behrz3 J3OK+6v6j+ggNyaNVavjVeMzeyIkFVzoZcpg/kkKsIlxQnbLrPcZomcgK9T/k/Ww3z1wOC NlkJCISdmtZ6/7ybLbE+LHI7N0S9Eco= Received: from dggpemm100009.china.huawei.com (unknown [172.30.72.57]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4PqpMX5QxQznZnC; Mon, 3 Apr 2023 19:19:52 +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; Mon, 3 Apr 2023 19:23:15 +0800 From: Liu Shixin To: Seth Jennings , Dan Streetman , Vitaly Wool , Andrew Morton , Nathan Chancellor , Christoph Hellwig CC: , , Liu Shixin Subject: [PATCH -next v8 0/3] Delay the initialization of zswap Date: Mon, 3 Apr 2023 20:13:15 +0800 Message-ID: <20230403121318.1876082-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: B7BF74000C X-Stat-Signature: xkbimiyoupp51kibj95yucyyap3zb6cr X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1680521000-438865 X-HE-Meta: U2FsdGVkX1+3RiZVyOMIRrosf3rM9CCaJpf9ZWtiCO/sNwoOYRfEQBec1L6+oPZGvBkcnz9rliYGq7FdN4Nbi5bAo79J5Ki0uo9d3KDIi/ClZ6m34akNX5/RGN0/GLnzQtd9vA8xTPtw8P9d3bp9m8Ci/ktUikP6f3UFL2+DUDawjc1RDq3vt5HU8At0gcbRXcPMrGjFneA+3X4GbDg7scQcj0vOyxqH1Cv/sc69e1ZbLTZOqSLF/2djmTASZHVyOKzZvbt3JHijM+pLeIAdhYRFmoCYDYcgjUR1fOnX/ZRk4o0DoM1IecCUoKNTxBnfbQB9wYLe4EEmKFA8SS2oqUd1yqgBjoU6uMEtNUIJMyvK8KhEJZJBEIRkKSWxcXRszHbHWtH8kkB47Jz3pRc7CAcOV852celv/ZxTCMEeJ5y8cFbB9PnnE3WPDvw/WI/SWrIJyEwZq6aN3lhrNEfffIeZlVe+RkmdIwGtaBpXd0lGl3IL8tc0nq+003eNX1DRNHJ1BIr492+wBfCLlRrfPHm4Sq9gYt++K4c0VPWkWmN6R494mvGDGt3m0HUbCS/2ChYDGyXYBEqVSJTmwII9fQa0nmbAJASO6UgLI7Kqab/Jp5OxX2nlMmwJkiqh+JD1Z7YIdBMMB7qRWqYO7cJ08a/P/WC6bOmkZfKSeowuvjK5Tu9s+vuWUxo6O0wA8AZ3uOOBHUZSVADzaGCfJVaznt0BBFCaLvB8Qo9dKzoJ+O1J+rxDfoJBxxecMcIo74ugJRUW1BPtWiJzi7cvSIAnp1DYo9BsqQiU1p9Nj5uqN5BzdvffYPWpZG1vELXaHy+CmraziKrjJza79MEfCXXq4269XXcn7g/8ZYAxQredeadYF9ZC2Yqvx/E8LU3xt3lN+LGWg5jV1PPx3eSCKUJMV25HEncHOPEsa+qIupuTDLAmEgGLjFWwDqDae2xnH62+7Bko7+UuiOaWtAACjes 5zmN5Nzg nmg82nOwan4CgctLzBzoA3BW7SF34OOT/yM5mNiMnec3DapMyG7mENRUkzj4EhCRo5Z1FsvzkoI4KsASM164xVlG0MASEyM8JrG1islRtdG2VoawyxAbI/onvYT64/DZHokciyD1IHV5l0rc= 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. 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 | 111 ++++++++++++++++++++++++++++++++--------------------- 1 file changed, 68 insertions(+), 43 deletions(-)