Message ID | 20230411093632.822290-1-liushixin2@huawei.com |
---|---|
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2440156vqo; Tue, 11 Apr 2023 02:30:11 -0700 (PDT) X-Google-Smtp-Source: AKy350ZCiDFF9cdYTSYMiZwRPbenXAOulNiSeK6U0OCpCuin9KKdOzJPCDsxHeKfjp48ZRrX/ko5 X-Received: by 2002:a17:907:98fb:b0:92f:33ca:c9a3 with SMTP id ke27-20020a17090798fb00b0092f33cac9a3mr1900483ejc.71.1681205411096; Tue, 11 Apr 2023 02:30:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681205411; cv=none; d=google.com; s=arc-20160816; b=B5rSF4t9XZC0QiArYdH4SmQ8AEpfMSvBfsWxrnogsNVGOUH6sf1tlopfkxlnua8Kl+ PzfamJvfxJ+Eh1Ry3+DlIQRFf4sPpxPSVgt0pX+5W4vFciqUwyHrfq/4AWnzNIqjIA6X oNi6tBZn/g8ILlEoxZikkp9Syh4CC1Egcyuybj0QTos9FICbLTcB8bl8+2cdO/W/Rk3q u/7oJaeTTEuCXCmFoBG9BWh+BK/8vJ5a1SJ4y0aqHJksFbIG04gj1LyBERyLM7huPogx OIoSxkFhM6NHTdRsT5W36uIuprzwBnYFAiE3qBQ8NMD6Pt0x4jta76BfaBA3a63sUDdO zsOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=je03xyokmlBWxYFl2DZYYHgj8uutzvGf5209nikV5zw=; b=fP/Q5yX+XBx878Sb0hu8U/8fXbpJ3ZB+rATOXizjh9W6XEkSR5hy0U5aiHrzXMbcdT j0gGqEJZ2b/HWXZ9uvQkywGY1GmgSvl4QAQty/UQW1e97CAqDObPtoevnxHLc2yAmaJK kU66KVjGD8i13suCuYBK5rQWyeS6OZqvFXPkRryT+SgEw0DpRFPVZytwj+yIItjRhnmh kpjadQFXMCTd5sqhhktMZnAPXxBYcZ1Bo/BdPzSWxdb15SXq2w0ZDtLV2rL4HKX181Fv mjl18BIvgq/I3GoWBIBwy4sX+7diOFRhmYN298aaQJWOn2TUSJhhYWD17OnR0N91rQOY +wuw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sy12-20020a1709076f0c00b0094c4dc0f295si26609ejc.442.2023.04.11.02.29.47; Tue, 11 Apr 2023 02:30:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230081AbjDKIqe (ORCPT <rfc822;yuanzuo1009@gmail.com> + 99 others); Tue, 11 Apr 2023 04:46:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37336 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229458AbjDKIqd (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 11 Apr 2023 04:46:33 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6649F121 for <linux-kernel@vger.kernel.org>; Tue, 11 Apr 2023 01:46:32 -0700 (PDT) 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 <liushixin2@huawei.com> To: Seth Jennings <sjenning@redhat.com>, Dan Streetman <ddstreet@ieee.org>, Vitaly Wool <vitaly.wool@konsulko.com>, Andrew Morton <akpm@linux-foundation.org>, Nathan Chancellor <nathan@kernel.org>, Christoph Hellwig <hch@lst.de> CC: <linux-kernel@vger.kernel.org>, <linux-mm@kvack.org>, Liu Shixin <liushixin2@huawei.com> 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 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII 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-Spam-Status: No, score=-2.3 required=5.0 tests=RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1762871644955315183?= X-GMAIL-MSGID: =?utf-8?q?1762871644955315183?= |
Series | Delay the initialization of zswap | |
Message
Liu Shixin
April 11, 2023, 9:36 a.m. UTC
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(-)
Comments
Hi Shixing, On Tue, Apr 11, 2023 at 05:36:29PM +0800, Liu Shixin wrote: > 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. Sorry I am late to this discussion. I notice you are already at V9. Anyway, I am curious how much of the 18MB was came from the zswap_pool alone and how much of it came from the other part of the initialization. If it is the zswap_pool alone, it means that we can have a smaller patch to get most of your 18M back. I also notice you move a lot of __init function back to normal functions. That would mean those functions wouldn't be able to drop after the initialization phase. That is another reason to move less of the initialization function. Chris
On 2023/5/4 8:11, Chris Li wrote: > Hi Shixing, > > On Tue, Apr 11, 2023 at 05:36:29PM +0800, Liu Shixin wrote: >> 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. > Sorry I am late to this discussion. I notice you are already at V9. > Anyway, I am curious how much of the 18MB was came from the zswap_pool > alone and how much of it came from the other part of the initialization. > > If it is the zswap_pool alone, it means that we can have a smaller patch > to get most of your 18M back. You're right, the most came from zswap_pool. > > I also notice you move a lot of __init function back to normal functions. > That would mean those functions wouldn't be able to drop after the > initialization phase. That is another reason to move less of the initialization > function. Thanks for your advice. I've thought about it before, but I thought there is less impact for the size of kernel, so I didn't do it. > > Chris > > . >
On Thu, May 04, 2023 at 03:11:05PM +0800, Liu Shixin wrote: > > > > If it is the zswap_pool alone, it means that we can have a smaller patch > > to get most of your 18M back. > You're right, the most came from zswap_pool. Thanks for the confirmation. > > I also notice you move a lot of __init function back to normal functions. > > That would mean those functions wouldn't be able to drop after the > > initialization phase. That is another reason to move less of the initialization > > function. > Thanks for your advice. I've thought about it before, but I thought there is less impact > for the size of kernel, so I didn't do it. Let's first agree on the hypothetical patch that only delaying zswap_pool would have the benefit over V9 on: - smaller patch, less invasive. - less kernel text area due to more __init function got free after initialization. If we can reach that agreement, then we can discuss how we can get there. I think there is a possibility that the delay initialization of zswap_pool can fall into the "zswap_has_pool = false" case, so you don't need to have the initialization mutex. Simpler. I have my selfish reason as well. I have a much larger pending patch against the zswap code so the smaller patch would mean less conflict for me. I am guilty of giving this feedback late. If you come up with a V10, I will be glad to review it. Or, if you prefer, I can come up with the smaller patch for you to review as well. What do you say? Chris
On 2023/5/4 22:53, Chris Li wrote: > On Thu, May 04, 2023 at 03:11:05PM +0800, Liu Shixin wrote: >>> If it is the zswap_pool alone, it means that we can have a smaller patch >>> to get most of your 18M back. >> You're right, the most came from zswap_pool. > Thanks for the confirmation. > >>> I also notice you move a lot of __init function back to normal functions. >>> That would mean those functions wouldn't be able to drop after the >>> initialization phase. That is another reason to move less of the initialization >>> function. >> Thanks for your advice. I've thought about it before, but I thought there is less impact >> for the size of kernel, so I didn't do it. > Let's first agree on the hypothetical patch that only delaying zswap_pool would > have the benefit over V9 on: > - smaller patch, less invasive. > - less kernel text area due to more __init function got free after initialization. > > If we can reach that agreement, then we can discuss how we can get there. > > I think there is a possibility that the delay initialization of zswap_pool > can fall into the "zswap_has_pool = false" case, so you don't need to have > the initialization mutex. Simpler. > > I have my selfish reason as well. I have a much larger pending patch against > the zswap code so the smaller patch would mean less conflict for me. > > I am guilty of giving this feedback late. If you come up with a V10, I will be glad > to review it. Or, if you prefer, I can come up with the smaller patch for you > to review as well. What do you say? You can add a pre-patch to modify it before your patch. Thanks. > > Chris > > . >
Hi Shixin, On Mon, May 08, 2023 at 09:37:23AM +0800, Liu Shixin wrote: > > I am guilty of giving this feedback late. If you come up with a V10, I will be glad > > to review it. Or, if you prefer, I can come up with the smaller patch for you > > to review as well. What do you say? > You can add a pre-patch to modify it before your patch. Thanks. Will do. I notice your patch has already been merged, that is the only way to move forward anyway. I will CC you for review when I send the patch out. Chris