From: Anshuman Khandual <khandual@linux.vnet.ibm.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] mm: Move definition of 'zone_names' array into mmzone.h
Date: Fri, 02 Sep 2016 09:59:12 +0530 [thread overview]
Message-ID: <57C90018.70507@linux.vnet.ibm.com> (raw)
In-Reply-To: <20160831141033.8f617b6000bf129bbc40bda7@linux-foundation.org>
On 09/01/2016 02:40 AM, Andrew Morton wrote:
> On Wed, 31 Aug 2016 08:55:49 +0530 Anshuman Khandual <khandual@linux.vnet.ibm.com> wrote:
>
>> zone_names[] is used to identify any zone given it's index which
>> can be used in many other places. So moving the definition into
>> include/linux/mmzone.h for broader access.
>>
>> ...
>>
>> --- a/include/linux/mmzone.h
>> +++ b/include/linux/mmzone.h
>> @@ -341,6 +341,23 @@ enum zone_type {
>>
>> };
>>
>> +static char * const zone_names[__MAX_NR_ZONES] = {
>> +#ifdef CONFIG_ZONE_DMA
>> + "DMA",
>> +#endif
>> +#ifdef CONFIG_ZONE_DMA32
>> + "DMA32",
>> +#endif
>> + "Normal",
>> +#ifdef CONFIG_HIGHMEM
>> + "HighMem",
>> +#endif
>> + "Movable",
>> +#ifdef CONFIG_ZONE_DEVICE
>> + "Device",
>> +#endif
>> +};
>> +
>> #ifndef __GENERATING_BOUNDS_H
>>
>> struct zone {
>> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
>> index 3fbe73a..8e2261c 100644
>> --- a/mm/page_alloc.c
>> +++ b/mm/page_alloc.c
>> @@ -207,23 +207,6 @@ int sysctl_lowmem_reserve_ratio[MAX_NR_ZONES-1] = {
>>
>> EXPORT_SYMBOL(totalram_pages);
>>
>> -static char * const zone_names[MAX_NR_ZONES] = {
>> -#ifdef CONFIG_ZONE_DMA
>> - "DMA",
>> -#endif
>> -#ifdef CONFIG_ZONE_DMA32
>> - "DMA32",
>> -#endif
>> - "Normal",
>> -#ifdef CONFIG_HIGHMEM
>> - "HighMem",
>> -#endif
>> - "Movable",
>> -#ifdef CONFIG_ZONE_DEVICE
>> - "Device",
>> -#endif
>> -};
>> -
>> char * const migratetype_names[MIGRATE_TYPES] = {
>> "Unmovable",
>> "Movable",
>
> This is worrisome. On some (ancient) compilers, this will produce a
> copy of that array into each compilation unit which includes mmzone.h.
>
> On smarter compilers, it will produce a copy of the array in each
> compilation unit which *uses* zone_names[].
>
> On even smarter compilers (and linkers!), only one copy of zone_names[]
> will exist in vmlinux.
>
> I don't know if gcc is an "even smarter compiler" and I didn't check,
> and I didn't check which gcc versions are even smarter. I'd rather not
> have to ;) It is risky.
>
> So, let's just make it non-static and add a declaration into mmzone.h,
> please.
>
I understand your concern, will change it.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
WARNING: multiple messages have this Message-ID (diff)
From: Anshuman Khandual <khandual@linux.vnet.ibm.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] mm: Move definition of 'zone_names' array into mmzone.h
Date: Fri, 02 Sep 2016 09:59:12 +0530 [thread overview]
Message-ID: <57C90018.70507@linux.vnet.ibm.com> (raw)
In-Reply-To: <20160831141033.8f617b6000bf129bbc40bda7@linux-foundation.org>
On 09/01/2016 02:40 AM, Andrew Morton wrote:
> On Wed, 31 Aug 2016 08:55:49 +0530 Anshuman Khandual <khandual@linux.vnet.ibm.com> wrote:
>
>> zone_names[] is used to identify any zone given it's index which
>> can be used in many other places. So moving the definition into
>> include/linux/mmzone.h for broader access.
>>
>> ...
>>
>> --- a/include/linux/mmzone.h
>> +++ b/include/linux/mmzone.h
>> @@ -341,6 +341,23 @@ enum zone_type {
>>
>> };
>>
>> +static char * const zone_names[__MAX_NR_ZONES] = {
>> +#ifdef CONFIG_ZONE_DMA
>> + "DMA",
>> +#endif
>> +#ifdef CONFIG_ZONE_DMA32
>> + "DMA32",
>> +#endif
>> + "Normal",
>> +#ifdef CONFIG_HIGHMEM
>> + "HighMem",
>> +#endif
>> + "Movable",
>> +#ifdef CONFIG_ZONE_DEVICE
>> + "Device",
>> +#endif
>> +};
>> +
>> #ifndef __GENERATING_BOUNDS_H
>>
>> struct zone {
>> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
>> index 3fbe73a..8e2261c 100644
>> --- a/mm/page_alloc.c
>> +++ b/mm/page_alloc.c
>> @@ -207,23 +207,6 @@ int sysctl_lowmem_reserve_ratio[MAX_NR_ZONES-1] = {
>>
>> EXPORT_SYMBOL(totalram_pages);
>>
>> -static char * const zone_names[MAX_NR_ZONES] = {
>> -#ifdef CONFIG_ZONE_DMA
>> - "DMA",
>> -#endif
>> -#ifdef CONFIG_ZONE_DMA32
>> - "DMA32",
>> -#endif
>> - "Normal",
>> -#ifdef CONFIG_HIGHMEM
>> - "HighMem",
>> -#endif
>> - "Movable",
>> -#ifdef CONFIG_ZONE_DEVICE
>> - "Device",
>> -#endif
>> -};
>> -
>> char * const migratetype_names[MIGRATE_TYPES] = {
>> "Unmovable",
>> "Movable",
>
> This is worrisome. On some (ancient) compilers, this will produce a
> copy of that array into each compilation unit which includes mmzone.h.
>
> On smarter compilers, it will produce a copy of the array in each
> compilation unit which *uses* zone_names[].
>
> On even smarter compilers (and linkers!), only one copy of zone_names[]
> will exist in vmlinux.
>
> I don't know if gcc is an "even smarter compiler" and I didn't check,
> and I didn't check which gcc versions are even smarter. I'd rather not
> have to ;) It is risky.
>
> So, let's just make it non-static and add a declaration into mmzone.h,
> please.
>
I understand your concern, will change it.
next prev parent reply other threads:[~2016-09-02 4:29 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-31 3:25 [PATCH 1/2] mm: Move definition of 'zone_names' array into mmzone.h Anshuman Khandual
2016-08-31 3:25 ` Anshuman Khandual
2016-08-31 3:25 ` [PATCH 2/2] mm: Add sysfs interface to dump each node's zonelist information Anshuman Khandual
2016-08-31 3:25 ` Anshuman Khandual
2016-08-31 21:12 ` Andrew Morton
2016-08-31 21:12 ` Andrew Morton
2016-09-02 4:34 ` Anshuman Khandual
2016-09-02 4:34 ` Anshuman Khandual
2016-08-31 21:10 ` [PATCH 1/2] mm: Move definition of 'zone_names' array into mmzone.h Andrew Morton
2016-08-31 21:10 ` Andrew Morton
2016-09-02 4:29 ` Anshuman Khandual [this message]
2016-09-02 4:29 ` Anshuman Khandual
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=57C90018.70507@linux.vnet.ibm.com \
--to=khandual@linux.vnet.ibm.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.