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 X-Spam-Level: X-Spam-Status: No, score=-12.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3B3C9C2B9F8 for ; Tue, 25 May 2021 08:33:25 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id ACFBD61419 for ; Tue, 25 May 2021 08:33:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org ACFBD61419 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 187B98D0002; Tue, 25 May 2021 04:33:24 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 138F36B0070; Tue, 25 May 2021 04:33:24 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id ECE628D0002; Tue, 25 May 2021 04:33:23 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0205.hostedemail.com [216.40.44.205]) by kanga.kvack.org (Postfix) with ESMTP id B67B86B006E for ; Tue, 25 May 2021 04:33:23 -0400 (EDT) Received: from smtpin20.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 58F5E9412 for ; Tue, 25 May 2021 08:33:23 +0000 (UTC) X-FDA: 78179089086.20.558836D Received: from mail-oi1-f173.google.com (mail-oi1-f173.google.com [209.85.167.173]) by imf20.hostedemail.com (Postfix) with ESMTP id 78E502C8 for ; Tue, 25 May 2021 08:33:15 +0000 (UTC) Received: by mail-oi1-f173.google.com with SMTP id d21so29532081oic.11 for ; Tue, 25 May 2021 01:33:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=kQM339tzjQDy+e5AN5k6Z5xiJOPOU4gvpnM5CS5cM88=; b=JnXSgdvulmBzN7d07UQq7gHEgu34LxEKQN4kUkXCH8P/NGiFTgMdXJkK2jUSS7faFK ZS99vgSWycL9iiTaejigFNXoTRCc9Jbmb/73grUf657bcbRyQBDF3Bj5PsZipq+E0LWc H1WHyK2swgeYi38zVS6eZMBttaeUl5YjKovF3PNlqjxxfVV3yFlzLIV0EfLOLLlBjbkK GHgazzdSD3fwiEwPjTm8kwT0hIIVtLrZXU4uMGt/CqjNKgf8JLS/YuXonCz7oLkL7rGM GDgBanmbuf+odNb4VYCvDS0/HIoAZViJ9mhlt83LTWt1yV1Ncq2HSrMBPE66n8+AURUA hsWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=kQM339tzjQDy+e5AN5k6Z5xiJOPOU4gvpnM5CS5cM88=; b=WRkOrGhJxC511kILLG9PM8/Ryqh/etZDyijW37CFKCiKRcPkuNZCysPQHoQ0ofiF+o OrXLyVE2Zr+2o3qujwxNdzMphgNaUhD6FCVLi9mweRAPbz3iWsVHY4Db9DLd1ydOtdab 912mApfyt+piw1G/WpCfBvG1EWwhlinRHczZwTTV2zb8mLnNWmriYVERWz374cP4+78K oD2LS+U8uoMNKOwxkwygiXzJ3MpIBCcEysbOFA/avzLsnRw35lzxNYPMP8s2yebQBqeC XTYIVM7TBRnkRa15uVL49DGKTmL6MNhaQZFEh0173yuDnQF06NnZWYYhT0cIUNanLb66 mZDw== X-Gm-Message-State: AOAM531Wx9NmYIxtK1TUg4ZNIfC41y6s3OJbPPJ/O3QpSHA/oN4vU36L K5Z4JGUfOEEnOdDpf93Q/eCvx7xH1bahACImR+U= X-Google-Smtp-Source: ABdhPJy5PRLwYjHdPHysnid5s45yudPto4P6iju+8j1kYEQT+qtTBEeb9BDdgu9zyJOYNedROnaE+6/eR/1aq79XTyM= X-Received: by 2002:a05:6808:1304:: with SMTP id y4mr2151876oiv.20.1621931602411; Tue, 25 May 2021 01:33:22 -0700 (PDT) MIME-Version: 1.0 References: <20210517112044.233138-1-aisheng.dong@nxp.com> <20210517112044.233138-5-aisheng.dong@nxp.com> In-Reply-To: From: Dong Aisheng Date: Tue, 25 May 2021 16:32:16 +0800 Message-ID: Subject: Re: [PATCH 4/5] mm: rename the global section array to mem_sections To: David Hildenbrand Cc: Dong Aisheng , linux-mm@kvack.org, open list , Andrew Morton , Dave Young , Baoquan He , Vivek Goyal , kexec@lists.infradead.org Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 78E502C8 Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=JnXSgdvu; spf=pass (imf20.hostedemail.com: domain of dongas86@gmail.com designates 209.85.167.173 as permitted sender) smtp.mailfrom=dongas86@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspamd-Server: rspam04 X-Stat-Signature: e6w81m5tco7wr58sd13b6e5ucoufk5zf X-HE-Tag: 1621931595-534476 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 Tue, May 25, 2021 at 3:55 PM David Hildenbrand wrote: > > On 17.05.21 13:20, Dong Aisheng wrote: > > In order to distinguish the struct mem_section for a better code > > readability and align with kernel doc [1] name below, change the > > global mem section name to 'mem_sections' from 'mem_section'. > > > > [1] Documentation/vm/memory-model.rst > > "The `mem_section` objects are arranged in a two-dimensional array > > called `mem_sections`." > > > > Cc: Andrew Morton > > Cc: Dave Young > > Cc: Baoquan He > > Cc: Vivek Goyal > > Cc: kexec@lists.infradead.org > > Signed-off-by: Dong Aisheng > > --- > > include/linux/mmzone.h | 10 +++++----- > > kernel/crash_core.c | 4 ++-- > > mm/sparse.c | 16 ++++++++-------- > > 3 files changed, 15 insertions(+), 15 deletions(-) > > > > diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h > > index fc23e36cb165..b348a06915c5 100644 > > --- a/include/linux/mmzone.h > > +++ b/include/linux/mmzone.h > > @@ -1297,9 +1297,9 @@ struct mem_section { > > #define SECTION_ROOT_MASK (SECTIONS_PER_ROOT - 1) > > > > #ifdef CONFIG_SPARSEMEM_EXTREME > > -extern struct mem_section **mem_section; > > +extern struct mem_section **mem_sections; > > #else > > -extern struct mem_section mem_section[NR_SECTION_ROOTS][SECTIONS_PER_ROOT]; > > +extern struct mem_section mem_sections[NR_SECTION_ROOTS][SECTIONS_PER_ROOT]; > > #endif > > > > static inline unsigned long *section_to_usemap(struct mem_section *ms) > > @@ -1310,12 +1310,12 @@ static inline unsigned long *section_to_usemap(struct mem_section *ms) > > static inline struct mem_section *__nr_to_section(unsigned long nr) > > { > > #ifdef CONFIG_SPARSEMEM_EXTREME > > - if (!mem_section) > > + if (!mem_sections) > > return NULL; > > #endif > > - if (!mem_section[SECTION_NR_TO_ROOT(nr)]) > > + if (!mem_sections[SECTION_NR_TO_ROOT(nr)]) > > return NULL; > > - return &mem_section[SECTION_NR_TO_ROOT(nr)][nr & SECTION_ROOT_MASK]; > > + return &mem_sections[SECTION_NR_TO_ROOT(nr)][nr & SECTION_ROOT_MASK]; > > } > > extern unsigned long __section_nr(struct mem_section *ms); > > extern size_t mem_section_usage_size(void); > > diff --git a/kernel/crash_core.c b/kernel/crash_core.c > > index 29cc15398ee4..fb1180d81b5a 100644 > > --- a/kernel/crash_core.c > > +++ b/kernel/crash_core.c > > @@ -414,8 +414,8 @@ static int __init crash_save_vmcoreinfo_init(void) > > VMCOREINFO_SYMBOL(contig_page_data); > > #endif > > #ifdef CONFIG_SPARSEMEM > > - VMCOREINFO_SYMBOL_ARRAY(mem_section); > > - VMCOREINFO_LENGTH(mem_section, NR_SECTION_ROOTS); > > + VMCOREINFO_SYMBOL_ARRAY(mem_sections); > > + VMCOREINFO_LENGTH(mem_sections, NR_SECTION_ROOTS); > > VMCOREINFO_STRUCT_SIZE(mem_section); > > VMCOREINFO_OFFSET(mem_section, section_mem_map); > > VMCOREINFO_NUMBER(MAX_PHYSMEM_BITS); > > diff --git a/mm/sparse.c b/mm/sparse.c > > index df4418c12f04..a96e7e65475f 100644 > > --- a/mm/sparse.c > > +++ b/mm/sparse.c > > @@ -24,12 +24,12 @@ > > * 1) mem_section - memory sections, mem_map's for valid memory > > */ > > #ifdef CONFIG_SPARSEMEM_EXTREME > > -struct mem_section **mem_section; > > +struct mem_section **mem_sections; > > #else > > -struct mem_section mem_section[NR_SECTION_ROOTS][SECTIONS_PER_ROOT] > > +struct mem_section mem_sections[NR_SECTION_ROOTS][SECTIONS_PER_ROOT] > > ____cacheline_internodealigned_in_smp; > > #endif > > -EXPORT_SYMBOL(mem_section); > > +EXPORT_SYMBOL(mem_sections); > > > > #ifdef NODE_NOT_IN_PAGE_FLAGS > > /* > > @@ -91,14 +91,14 @@ static int __meminit sparse_index_init(unsigned long section_nr, int nid) > > * > > * The mem_hotplug_lock resolves the apparent race below. > > */ > > - if (mem_section[root]) > > + if (mem_sections[root]) > > return 0; > > > > section = sparse_index_alloc(nid); > > if (!section) > > return -ENOMEM; > > > > - mem_section[root] = section; > > + mem_sections[root] = section; > > > > return 0; > > } > > @@ -131,7 +131,7 @@ unsigned long __section_nr(struct mem_section *ms) > > #else > > unsigned long __section_nr(struct mem_section *ms) > > { > > - return (unsigned long)(ms - mem_section[0]); > > + return (unsigned long)(ms - mem_sections[0]); > > } > > #endif > > > > @@ -286,8 +286,8 @@ static void __init memblocks_present(void) > > #ifdef CONFIG_SPARSEMEM_EXTREME > > size = sizeof(struct mem_section *) * NR_SECTION_ROOTS; > > align = 1 << (INTERNODE_CACHE_SHIFT); > > - mem_section = memblock_alloc(size, align); > > - if (!mem_section) > > + mem_sections = memblock_alloc(size, align); > > + if (!mem_sections) > > panic("%s: Failed to allocate %lu bytes align=0x%lx\n", > > __func__, size, align); > > #endif > > > > Smells like unnecessary code churn. I'd rather just fix the doc because > it doesn't really improve readability IMHO. > In practice I feel it does affect readability that the global mem_section pointer is mixed with struct mem_section names which results in: 1. hard to quickly jump between global mem_section operation in a single source file. e.g. by VIM hotkey of search 2. hard to quickly identify all global mem_section operations in global source files by tools, e.g. cscope, grep This does cause troubles if users want to quickly go through and understand the code. Regards Aisheng > Anyhow, just my 2 cents. > > -- > Thanks, > > David / dhildenb >