Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp1233846rwe; Thu, 25 Aug 2022 19:19:08 -0700 (PDT) X-Google-Smtp-Source: AA6agR6IOAt9SAQypUgMKki8x5sMenD9NUWUVYdpUPIQRF8ujsamrtwrxnXCjRV0bHkEG1+ne6Wk X-Received: by 2002:a17:902:c40a:b0:172:f3bf:de6d with SMTP id k10-20020a170902c40a00b00172f3bfde6dmr1590941plk.165.1661480348581; Thu, 25 Aug 2022 19:19:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661480348; cv=none; d=google.com; s=arc-20160816; b=GmRktV3C3HtBpI3RyM9uepfQNmEjEJe5gfsZQI7JcYGPUYPZSEkzw+AphtMO1XRZTz Z6K8o4G+WKfz/Z3uVeomsuI9xC8HJTSDhnOCIqhz2t4o/e030v0WZLVQOHStR70NNSS+ O6VU/QaOj5hLSE/TYy9AVRbERUcXEo3qAIr/VwHZQ5rKn5FbuFlwMxlp8exjYoVQKETF P9E3wIFkKnH2PamnHAIfIu74bZBXKUlhd92A7ias10L87oUbdJ9AYzIbTt1NJi4YsbWz oLY+VuzNEJFwL3gVLmaBy0AW+FQ6nD+UTtdwv5kHUppI8g+1qaOEN1d/0FhXNW6Ignt5 aXKg== 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 :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=g0885YFglb/T2kPa7xXTsH4kl3rm6tt39MaLubacM+c=; b=iaK8MiGzQwowc5kcsgzam0hj8ZgjVUwj67+1U8B2QH/qeT2zMDrP8EphAp7UibUJHY pgFqWOHFY+sKDxeNEaAQGHYyQLbdWDap15FxeSivcDHOfF3z1FLRImk9HH9ggdOPcEC0 0PvfRG8u1ktxLMu3tGjL1TrwU4JBbZRzCt+0L3dYlgDoCiJzMVmAeW+ACxBozzjwXeNu uB16621X9FzhuJWzVS6pjWfhSjLohCg0ydurh6QZ+Xzq9bMCbkK+SABWID2ZOf2zh+Ot 4N7w5AkMFKK/IRl+8ay/gHoSw33dy4v3fwfC954KbgSVdkHzq0OUS+GkGmaMxh3vC69w 1lSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=V8CpFKKN; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v8-20020a63b948000000b0042b1dbb67a0si619932pgo.77.2022.08.25.19.18.58; Thu, 25 Aug 2022 19:19:08 -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; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=V8CpFKKN; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244192AbiHZCBt (ORCPT + 99 others); Thu, 25 Aug 2022 22:01:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44556 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230259AbiHZCBs (ORCPT ); Thu, 25 Aug 2022 22:01:48 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AE951C8751 for ; Thu, 25 Aug 2022 19:01:47 -0700 (PDT) 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 dfw.source.kernel.org (Postfix) with ESMTPS id 4043861DEE for ; 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 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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: X-Mailing-List: linux-kernel@vger.kernel.org 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.