From mboxrd@z Thu Jan 1 00:00:00 1970 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 ABA2AECAAA2 for ; Fri, 26 Aug 2022 02:01:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 03366940008; Thu, 25 Aug 2022 22:01:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id F2407940007; Thu, 25 Aug 2022 22:01:49 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DC5E4940008; Thu, 25 Aug 2022 22:01:49 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id C9477940007 for ; Thu, 25 Aug 2022 22:01:49 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 9638F120D26 for ; Fri, 26 Aug 2022 02:01:49 +0000 (UTC) X-FDA: 79840092738.28.79C316F Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf12.hostedemail.com (Postfix) with ESMTP id 3BA5E40018 for ; Fri, 26 Aug 2022 02:01:49 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id EE43BB82F67; Fri, 26 Aug 2022 02:01:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 67758C433C1; Fri, 26 Aug 2022 02:01:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1661479306; bh=4G/cK7OUMoRHnhqGTeJLjX2Y5vRMe8slDX1/cmfVkeY=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=V8CpFKKNELxxzF8fIpK3IzIyAi1AsgXz3i924nRm4BCubiECS+CJ8BCRrNEIYPwAI lUoL9swrT88hvd1jM5Z6BauMTpd9qAEc5YUSYpj2g3sYh2GY83mGUKYQicNUfKqF78 zfJTe/fQxANHNN7IgWOLuCM1mqQJXAMkrhNKzvVE= Date: Thu, 25 Aug 2022 19:01:45 -0700 From: Andrew Morton To: Liu Shixin Cc: Seth Jennings , Dan Streetman , Vitaly Wool , , Subject: Re: [PATCH -next 2/3] mm/zswap: delay the initializaton of zswap until the first enablement Message-Id: <20220825190145.b0fc3267e16705866660f947@linux-foundation.org> In-Reply-To: <20220825142037.3214152-3-liushixin2@huawei.com> References: <20220825142037.3214152-1-liushixin2@huawei.com> <20220825142037.3214152-3-liushixin2@huawei.com> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.33; x86_64-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1661479309; 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:in-reply-to:references:references:dkim-signature; bh=g0885YFglb/T2kPa7xXTsH4kl3rm6tt39MaLubacM+c=; b=7B3RQckGonTtxoarsZ9/otsX2PAi8C2bu7uK4ONqqUSyaXUkQnvLg6SSykloGv1vmhv9Rz zAKDx90ycrBG+u2wUu+d6+x9tQGVOPNGuDsXy8YkiBMulr3wFUwbIaGXNZ0RlZ91mlm9OX PW04sKEdHflJ08TXOyaMkRDHC1dP23U= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=V8CpFKKN; spf=pass (imf12.hostedemail.com: domain of akpm@linux-foundation.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1661479309; a=rsa-sha256; cv=none; b=gR2HGuvD2rBz4kvVhwUX+FrulNMrGjsvAYtuLo4pfMPeiTfA6NFQ0Z7OclbKl7IsmuDE1a LvuNQovCypH+8wgWmayVsu5TkVXoinataTC8aXg2MkD50OAIL1t209PLyD3eQ1BEF0kLdF Bm6yR9EKxZ0Z3bNGxYvNHGPUGJk79uE= Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=V8CpFKKN; spf=pass (imf12.hostedemail.com: domain of akpm@linux-foundation.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org; dmarc=none X-Rspam-User: X-Stat-Signature: s78aquy8fo1s3yio84q7zydap7hs657e X-Rspamd-Queue-Id: 3BA5E40018 X-Rspamd-Server: rspam03 X-HE-Tag: 1661479309-459375 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: On Thu, 25 Aug 2022 22:20:36 +0800 Liu Shixin wrote: > In the initialization of zswap, about 18MB memory will be allocated for > zswap_pool in my machine. 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. > > ... > > +static int __init init_zswap(void) > +{ > + /* skip init if zswap is disabled when system startup */ > + if (!zswap_enabled) > + return 0; > + return zswap_setup(); > +} > + I can't resist. --- a/mm/zswap.c~mm-zswap-delay-the-initializaton-of-zswap-until-the-first-enablement-fix +++ a/mm/zswap.c @@ -1556,7 +1556,7 @@ cache_fail: return -ENOMEM; } -static int __init init_zswap(void) +static int __init zswap_init(void) { /* skip init if zswap is disabled when system startup */ if (!zswap_enabled) @@ -1565,7 +1565,7 @@ static int __init init_zswap(void) } /* must be late so crypto has time to come up */ -late_initcall(init_zswap); +late_initcall(zswap_init); MODULE_LICENSE("GPL"); MODULE_AUTHOR("Seth Jennings "); It's the usual way and makes things more consistent.