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 15761C433EF for ; Thu, 16 Dec 2021 09:00:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 590236B0074; Thu, 16 Dec 2021 04:00:39 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 53F8E6B007B; Thu, 16 Dec 2021 04:00:39 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 407836B007D; Thu, 16 Dec 2021 04:00:39 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0082.hostedemail.com [216.40.44.82]) by kanga.kvack.org (Postfix) with ESMTP id 2D1F66B0074 for ; Thu, 16 Dec 2021 04:00:39 -0500 (EST) Received: from smtpin12.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id DB7B38249980 for ; Thu, 16 Dec 2021 09:00:28 +0000 (UTC) X-FDA: 78923061336.12.B234020 Received: from mail-yb1-f176.google.com (mail-yb1-f176.google.com [209.85.219.176]) by imf01.hostedemail.com (Postfix) with ESMTP id 06C9240019 for ; Thu, 16 Dec 2021 09:00:22 +0000 (UTC) Received: by mail-yb1-f176.google.com with SMTP id 131so62707763ybc.7 for ; Thu, 16 Dec 2021 01:00:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=WiAKB8+SjEHwCrofH7QRr3IXwaMMb0ZhTdJq3Ay5yG0=; b=NOK4SKjLlQLEeCk+fjGPvW/EKp6l2LGZZ3es7Ku/x7nQVk8j/Y6ponIjNqpgkJ5RiI 9Avrdtg5IuI4x0vdDe77jFGybfTF2qTdWBkYNwKMVYKZAYySNnJAPMUq4cXfEFFBPwAv NPzcxfq4ei/ZL2rUnmcXlsEqZjdKq6q1nDBDjZLtY/Zgaks+zbTTGF/DIwFJaTp1phZU JmxF9zeIFA4yssejMVRMSPu/NADDgDX4RpcBxb1ub/KTPNO3p5s84t23yXVF3hCznJ3F zjQvJMH7edvHu97/bnom12TvQaYM6I1lFWK5Hd018gH207zKCsJDdRKO87GO0kuwIw9K aN5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=WiAKB8+SjEHwCrofH7QRr3IXwaMMb0ZhTdJq3Ay5yG0=; b=mEQ3P6bV/Dk3/4pvhrN5xwXvQdfUA5GCN9ECir8UTaJuTXT4Ngfjk89E8vBK8iPjlK eGCekHatqySX6Qd3jgYAKX1PTzWFz9qA3F/c22KgkcuL+h+ojMXhqNkIn/HytFhP6FO6 c3Nf99S0t73j2o29r6pMgyAHaSC0UrK30EkgwSSDynT1jJq0Z3X8PFoLy7qZh4/kR239 XzLM6yvhVRftlLvl3lEZ4/XwgPbeejF3uz4mdlUgRyPmQkGN6H8OhzP0Q9ZCZPkpTEaR nIy850RCq7pzuF8HCVkqhj/JxS0B18CWaCybFClHjuMA9iGNXZxrOkrd4ZxbgGkHEHJU RxrA== X-Gm-Message-State: AOAM530Vs6sEKUK7lzISko9PqfnHnufOPrjuSdo0+rGLH62/0o0MnCCZ gGQWEs+oGWnavvhbZAmLNSbpOWX2aN1dWnvH5RgswA== X-Google-Smtp-Source: ABdhPJxw6AO9QBub5R04urReUdcbGz/oXgL83sbrzvgDIJ85pqGGIndK8KFdfAhQro1W6X3q3jHmfpNGVDVfEsASicA= X-Received: by 2002:a25:d685:: with SMTP id n127mr11527577ybg.523.1639645225147; Thu, 16 Dec 2021 01:00:25 -0800 (PST) MIME-Version: 1.0 References: <20211215052651.89544-1-liuting.0x7c00@bytedance.com> In-Reply-To: <20211215052651.89544-1-liuting.0x7c00@bytedance.com> From: Muchun Song Date: Thu, 16 Dec 2021 16:59:44 +0800 Message-ID: Subject: Re: [PATCH] mm: make some vars and functions static or __init To: Ting Liu Cc: Andrew Morton , Linux Memory Management List , LKML , Vlastimil Babka , Shakeel Butt , Matthew Wilcox , sjpark@amazon.de Content-Type: text/plain; charset="UTF-8" X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 06C9240019 X-Stat-Signature: x3gtz439hxmrsj78nckp6qi3n7nabz1p Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=NOK4SKjL; spf=pass (imf01.hostedemail.com: domain of songmuchun@bytedance.com designates 209.85.219.176 as permitted sender) smtp.mailfrom=songmuchun@bytedance.com; dmarc=pass (policy=none) header.from=bytedance.com X-HE-Tag: 1639645222-997221 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 Wed, Dec 15, 2021 at 1:27 PM Ting Liu wrote: > > From: "liuting.0x7c00" > > "page_idle_ops" as a global var, but its scope of use within this > document. So it should be static. > "page_ext_ops" is a var used in the kernel initial phase. And other > functions are aslo used in the kernel initial phase. So they should be > __init or __initdata to reclaim memory. > > Signed-off-by: liuting.0x7c00 > --- > include/linux/page_idle.h | 1 - > mm/page_ext.c | 4 ++-- > mm/page_owner.c | 4 ++-- > 3 files changed, 4 insertions(+), 5 deletions(-) > > diff --git a/include/linux/page_idle.h b/include/linux/page_idle.h > index 83abf95e9fa7..4663dfed1293 100644 > --- a/include/linux/page_idle.h > +++ b/include/linux/page_idle.h > @@ -13,7 +13,6 @@ > * If there is not enough space to store Idle and Young bits in page flags, use > * page ext flags instead. > */ > -extern struct page_ext_operations page_idle_ops; > > static inline bool folio_test_young(struct folio *folio) > { > diff --git a/mm/page_ext.c b/mm/page_ext.c > index 6242afb24d84..2193e3f10e56 100644 > --- a/mm/page_ext.c > +++ b/mm/page_ext.c > @@ -63,12 +63,12 @@ static bool need_page_idle(void) Should need_page_idle be marked as __init? It is used in the initialization stage. > { > return true; > } > -struct page_ext_operations page_idle_ops = { > +static struct page_ext_operations page_idle_ops = { > .need = need_page_idle, > }; page_idle_ops is also used in the initialization stage. It also can be marked as __initdata. > #endif > > -static struct page_ext_operations *page_ext_ops[] = { > +static struct page_ext_operations *page_ext_ops[] __initdata = { > #ifdef CONFIG_PAGE_OWNER > &page_owner_ops, > #endif > diff --git a/mm/page_owner.c b/mm/page_owner.c > index 4f924957ce7a..5eea061bb1e5 100644 > --- a/mm/page_owner.c > +++ b/mm/page_owner.c > @@ -46,7 +46,7 @@ static int __init early_page_owner_param(char *buf) > } > early_param("page_owner", early_page_owner_param); > > -static bool need_page_owner(void) > +static __init bool need_page_owner(void) > { > return page_owner_enabled; > } > @@ -75,7 +75,7 @@ static noinline void register_early_stack(void) > early_handle = create_dummy_stack(); > } > > -static void init_page_owner(void) > +static __init void init_page_owner(void) > { > if (!page_owner_enabled) > return; > -- > 2.20.1 >