When the system boots up, in the dmesg logs we can see
the memory statistics along with total reserved as below.
Memory: 458840k/458840k available, 65448k reserved, 0K highmem
When CMA is enabled, still the total reserved memory remains the same.
However, the CMA memory is not considered as reserved.
But, when we see /proc/meminfo, the CMA memory is part of free memory.
This creates confusion.
This patch corrects the problem by properly substracting the CMA reserved
memory from the total reserved memory in dmesg logs.
Below is the dmesg snaphot from an arm based device with 512MB RAM and
12MB single CMA region.
Before this change:
Memory: 458840k/458840k available, 65448k reserved, 0K highmem
After this change:
Memory: 458840k/458840k available, 53160k reserved, 12288k cma-reserved, 0K highmem
Signed-off-by: Pintu Kumar <[email protected]>
Signed-off-by: Vishnu Pratap Singh <[email protected]>
---
include/linux/swap.h | 3 +++
mm/cma.c | 2 ++
mm/page_alloc.c | 8 ++++++++
3 files changed, 13 insertions(+)
diff --git a/include/linux/swap.h b/include/linux/swap.h
index 37a585b..beb84be 100644
--- a/include/linux/swap.h
+++ b/include/linux/swap.h
@@ -295,6 +295,9 @@ static inline void workingset_node_shadows_dec(struct radix_tree_node *node)
/* linux/mm/page_alloc.c */
extern unsigned long totalram_pages;
extern unsigned long totalreserve_pages;
+#ifdef CONFIG_CMA
+extern unsigned long totalcma_pages;
+#endif
extern unsigned long dirty_balance_reserve;
extern unsigned long nr_free_buffer_pages(void);
extern unsigned long nr_free_pagecache_pages(void);
diff --git a/mm/cma.c b/mm/cma.c
index 963bc4a..73fe7be 100644
--- a/mm/cma.c
+++ b/mm/cma.c
@@ -45,6 +45,7 @@ struct cma {
static struct cma cma_areas[MAX_CMA_AREAS];
static unsigned cma_area_count;
static DEFINE_MUTEX(cma_mutex);
+unsigned long totalcma_pages __read_mostly;
phys_addr_t cma_get_base(struct cma *cma)
{
@@ -288,6 +289,7 @@ int __init cma_declare_contiguous(phys_addr_t base,
if (ret)
goto err;
+ totalcma_pages += (size / PAGE_SIZE);
pr_info("Reserved %ld MiB at %08lx\n", (unsigned long)size / SZ_1M,
(unsigned long)base);
return 0;
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index dd73f9a..c6165ac 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -5521,6 +5521,9 @@ void __init mem_init_print_info(const char *str)
pr_info("Memory: %luK/%luK available "
"(%luK kernel code, %luK rwdata, %luK rodata, "
"%luK init, %luK bss, %luK reserved"
+#ifdef CONFIG_CMA
+ ", %luK cma-reserved"
+#endif
#ifdef CONFIG_HIGHMEM
", %luK highmem"
#endif
@@ -5528,7 +5531,12 @@ void __init mem_init_print_info(const char *str)
nr_free_pages() << (PAGE_SHIFT-10), physpages << (PAGE_SHIFT-10),
codesize >> 10, datasize >> 10, rosize >> 10,
(init_data_size + init_code_size) >> 10, bss_size >> 10,
+#ifdef CONFIG_CMA
+ (physpages - totalram_pages - totalcma_pages) << (PAGE_SHIFT-10),
+ totalcma_pages << (PAGE_SHIFT-10),
+#else
(physpages - totalram_pages) << (PAGE_SHIFT-10),
+#endif
#ifdef CONFIG_HIGHMEM
totalhigh_pages << (PAGE_SHIFT-10),
#endif
--
1.8.3.2
On Mon, Oct 20 2014, Pintu Kumar <[email protected]> wrote:
> When the system boots up, in the dmesg logs we can see
> the memory statistics along with total reserved as below.
> Memory: 458840k/458840k available, 65448k reserved, 0K highmem
>
> When CMA is enabled, still the total reserved memory remains the same.
> However, the CMA memory is not considered as reserved.
> But, when we see /proc/meminfo, the CMA memory is part of free memory.
> This creates confusion.
> This patch corrects the problem by properly substracting the CMA reserved
> memory from the total reserved memory in dmesg logs.
>
> Below is the dmesg snaphot from an arm based device with 512MB RAM and
> 12MB single CMA region.
>
> Before this change:
> Memory: 458840k/458840k available, 65448k reserved, 0K highmem
>
> After this change:
> Memory: 458840k/458840k available, 53160k reserved, 12288k cma-reserved, 0K highmem
>
> Signed-off-by: Pintu Kumar <[email protected]>
> Signed-off-by: Vishnu Pratap Singh <[email protected]>
Acked-by: Michal Nazarewicz <[email protected]>
> ---
> include/linux/swap.h | 3 +++
> mm/cma.c | 2 ++
> mm/page_alloc.c | 8 ++++++++
> 3 files changed, 13 insertions(+)
>
> diff --git a/include/linux/swap.h b/include/linux/swap.h
> index 37a585b..beb84be 100644
> --- a/include/linux/swap.h
> +++ b/include/linux/swap.h
> @@ -295,6 +295,9 @@ static inline void workingset_node_shadows_dec(struct radix_tree_node *node)
> /* linux/mm/page_alloc.c */
> extern unsigned long totalram_pages;
> extern unsigned long totalreserve_pages;
> +#ifdef CONFIG_CMA
> +extern unsigned long totalcma_pages;
> +#endif
> extern unsigned long dirty_balance_reserve;
> extern unsigned long nr_free_buffer_pages(void);
> extern unsigned long nr_free_pagecache_pages(void);
> diff --git a/mm/cma.c b/mm/cma.c
> index 963bc4a..73fe7be 100644
> --- a/mm/cma.c
> +++ b/mm/cma.c
> @@ -45,6 +45,7 @@ struct cma {
> static struct cma cma_areas[MAX_CMA_AREAS];
> static unsigned cma_area_count;
> static DEFINE_MUTEX(cma_mutex);
> +unsigned long totalcma_pages __read_mostly;
It's not __read_mostly.
>
> phys_addr_t cma_get_base(struct cma *cma)
> {
> @@ -288,6 +289,7 @@ int __init cma_declare_contiguous(phys_addr_t base,
> if (ret)
> goto err;
>
> + totalcma_pages += (size / PAGE_SIZE);
> pr_info("Reserved %ld MiB at %08lx\n", (unsigned long)size / SZ_1M,
> (unsigned long)base);
> return 0;
> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> index dd73f9a..c6165ac 100644
> --- a/mm/page_alloc.c
> +++ b/mm/page_alloc.c
> @@ -5521,6 +5521,9 @@ void __init mem_init_print_info(const char *str)
> pr_info("Memory: %luK/%luK available "
> "(%luK kernel code, %luK rwdata, %luK rodata, "
> "%luK init, %luK bss, %luK reserved"
> +#ifdef CONFIG_CMA
> + ", %luK cma-reserved"
> +#endif
> #ifdef CONFIG_HIGHMEM
> ", %luK highmem"
> #endif
> @@ -5528,7 +5531,12 @@ void __init mem_init_print_info(const char *str)
> nr_free_pages() << (PAGE_SHIFT-10), physpages << (PAGE_SHIFT-10),
> codesize >> 10, datasize >> 10, rosize >> 10,
> (init_data_size + init_code_size) >> 10, bss_size >> 10,
> +#ifdef CONFIG_CMA
> + (physpages - totalram_pages - totalcma_pages) << (PAGE_SHIFT-10),
> + totalcma_pages << (PAGE_SHIFT-10),
> +#else
> (physpages - totalram_pages) << (PAGE_SHIFT-10),
> +#endif
> #ifdef CONFIG_HIGHMEM
> totalhigh_pages << (PAGE_SHIFT-10),
> #endif
> --
> 1.8.3.2
>
--
Best regards, _ _
.o. | Liege of Serenely Enlightened Majesty of o' \,=./ `o
..o | Computer Science, Michał “mina86” Nazarewicz (o o)
ooo +--<[email protected]>--<xmpp:[email protected]>--ooO--(_)--Ooo--
On Mon, 20 Oct 2014 13:03:10 +0530 Pintu Kumar <[email protected]> wrote:
> When the system boots up, in the dmesg logs we can see
> the memory statistics along with total reserved as below.
> Memory: 458840k/458840k available, 65448k reserved, 0K highmem
>
> When CMA is enabled, still the total reserved memory remains the same.
> However, the CMA memory is not considered as reserved.
> But, when we see /proc/meminfo, the CMA memory is part of free memory.
> This creates confusion.
> This patch corrects the problem by properly substracting the CMA reserved
> memory from the total reserved memory in dmesg logs.
>
> Below is the dmesg snaphot from an arm based device with 512MB RAM and
> 12MB single CMA region.
>
> Before this change:
> Memory: 458840k/458840k available, 65448k reserved, 0K highmem
>
> After this change:
> Memory: 458840k/458840k available, 53160k reserved, 12288k cma-reserved, 0K highmem
>
> ...
>
> --- a/include/linux/swap.h
> +++ b/include/linux/swap.h
> @@ -295,6 +295,9 @@ static inline void workingset_node_shadows_dec(struct radix_tree_node *node)
> /* linux/mm/page_alloc.c */
> extern unsigned long totalram_pages;
> extern unsigned long totalreserve_pages;
> +#ifdef CONFIG_CMA
> +extern unsigned long totalcma_pages;
> +#endif
We don't actually need the ifdefs here - the kernel will compile OK
without them. This means that a programming error will result in a
link-time error rather than a compile-time error but that's a pretty
small cost to pay for keeping the header files neater.
> extern unsigned long dirty_balance_reserve;
> extern unsigned long nr_free_buffer_pages(void);
> extern unsigned long nr_free_pagecache_pages(void);
> diff --git a/mm/cma.c b/mm/cma.c
> index 963bc4a..73fe7be 100644
> --- a/mm/cma.c
> +++ b/mm/cma.c
> @@ -45,6 +45,7 @@ struct cma {
> static struct cma cma_areas[MAX_CMA_AREAS];
> static unsigned cma_area_count;
> static DEFINE_MUTEX(cma_mutex);
> +unsigned long totalcma_pages __read_mostly;
This could+should be __initdata.
> phys_addr_t cma_get_base(struct cma *cma)
> {
> @@ -288,6 +289,7 @@ int __init cma_declare_contiguous(phys_addr_t base,
> if (ret)
> goto err;
>
> + totalcma_pages += (size / PAGE_SIZE);
> pr_info("Reserved %ld MiB at %08lx\n", (unsigned long)size / SZ_1M,
> (unsigned long)base);
> return 0;
> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> index dd73f9a..c6165ac 100644
> --- a/mm/page_alloc.c
> +++ b/mm/page_alloc.c
> @@ -5521,6 +5521,9 @@ void __init mem_init_print_info(const char *str)
> pr_info("Memory: %luK/%luK available "
> "(%luK kernel code, %luK rwdata, %luK rodata, "
> "%luK init, %luK bss, %luK reserved"
> +#ifdef CONFIG_CMA
> + ", %luK cma-reserved"
> +#endif
> #ifdef CONFIG_HIGHMEM
> ", %luK highmem"
> #endif
> @@ -5528,7 +5531,12 @@ void __init mem_init_print_info(const char *str)
> nr_free_pages() << (PAGE_SHIFT-10), physpages << (PAGE_SHIFT-10),
> codesize >> 10, datasize >> 10, rosize >> 10,
> (init_data_size + init_code_size) >> 10, bss_size >> 10,
> +#ifdef CONFIG_CMA
> + (physpages - totalram_pages - totalcma_pages) << (PAGE_SHIFT-10),
> + totalcma_pages << (PAGE_SHIFT-10),
> +#else
> (physpages - totalram_pages) << (PAGE_SHIFT-10),
> +#endif
> #ifdef CONFIG_HIGHMEM
> totalhigh_pages << (PAGE_SHIFT-10),
> #endif
Do we really need any of the ifdefs? A non-CMA kernel will print "0K
cma-reserved" but is that harmful?
This is all __init code so the additional code bloat isn't a
significant issue.
2014-10-20 ???? 4:33, Pintu Kumar ?? ??:
> When the system boots up, in the dmesg logs we can see
> the memory statistics along with total reserved as below.
> Memory: 458840k/458840k available, 65448k reserved, 0K highmem
>
> When CMA is enabled, still the total reserved memory remains the same.
> However, the CMA memory is not considered as reserved.
> But, when we see /proc/meminfo, the CMA memory is part of free memory.
> This creates confusion.
> This patch corrects the problem by properly substracting the CMA reserved
> memory from the total reserved memory in dmesg logs.
>
> Below is the dmesg snaphot from an arm based device with 512MB RAM and
> 12MB single CMA region.
>
> Before this change:
> Memory: 458840k/458840k available, 65448k reserved, 0K highmem
>
> After this change:
> Memory: 458840k/458840k available, 53160k reserved, 12288k cma-reserved, 0K highmem
>
> Signed-off-by: Pintu Kumar <[email protected]>
> Signed-off-by: Vishnu Pratap Singh <[email protected]>
> ---
> include/linux/swap.h | 3 +++
> mm/cma.c | 2 ++
> mm/page_alloc.c | 8 ++++++++
> 3 files changed, 13 insertions(+)
>
> diff --git a/include/linux/swap.h b/include/linux/swap.h
> index 37a585b..beb84be 100644
> --- a/include/linux/swap.h
> +++ b/include/linux/swap.h
> @@ -295,6 +295,9 @@ static inline void workingset_node_shadows_dec(struct radix_tree_node *node)
> /* linux/mm/page_alloc.c */
> extern unsigned long totalram_pages;
> extern unsigned long totalreserve_pages;
> +#ifdef CONFIG_CMA
> +extern unsigned long totalcma_pages;
> +#endif
> extern unsigned long dirty_balance_reserve;
> extern unsigned long nr_free_buffer_pages(void);
> extern unsigned long nr_free_pagecache_pages(void);
> diff --git a/mm/cma.c b/mm/cma.c
> index 963bc4a..73fe7be 100644
> --- a/mm/cma.c
> +++ b/mm/cma.c
> @@ -45,6 +45,7 @@ struct cma {
> static struct cma cma_areas[MAX_CMA_AREAS];
> static unsigned cma_area_count;
> static DEFINE_MUTEX(cma_mutex);
> +unsigned long totalcma_pages __read_mostly;
I think __read_mostly is not good here.
Cma areas often are rare
but we cannot expect how many cma areas exists.
>
> phys_addr_t cma_get_base(struct cma *cma)
> {
> @@ -288,6 +289,7 @@ int __init cma_declare_contiguous(phys_addr_t base,
> if (ret)
> goto err;
>
> + totalcma_pages += (size / PAGE_SIZE);
> pr_info("Reserved %ld MiB at %08lx\n", (unsigned long)size / SZ_1M,
> (unsigned long)base);
> return 0;
> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> index dd73f9a..c6165ac 100644
> --- a/mm/page_alloc.c
> +++ b/mm/page_alloc.c
> @@ -5521,6 +5521,9 @@ void __init mem_init_print_info(const char *str)
> pr_info("Memory: %luK/%luK available "
> "(%luK kernel code, %luK rwdata, %luK rodata, "
> "%luK init, %luK bss, %luK reserved"
> +#ifdef CONFIG_CMA
> + ", %luK cma-reserved"
> +#endif
> #ifdef CONFIG_HIGHMEM
> ", %luK highmem"
> #endif
> @@ -5528,7 +5531,12 @@ void __init mem_init_print_info(const char *str)
> nr_free_pages() << (PAGE_SHIFT-10), physpages << (PAGE_SHIFT-10),
> codesize >> 10, datasize >> 10, rosize >> 10,
> (init_data_size + init_code_size) >> 10, bss_size >> 10,
> +#ifdef CONFIG_CMA
> + (physpages - totalram_pages - totalcma_pages) << (PAGE_SHIFT-10),
> + totalcma_pages << (PAGE_SHIFT-10),
> +#else
> (physpages - totalram_pages) << (PAGE_SHIFT-10),
> +#endif
> #ifdef CONFIG_HIGHMEM
> totalhigh_pages << (PAGE_SHIFT-10),
> #endif
>
I basically agree with your point.
But CMA feature is not popular yet, so memory develoers probably doesn't like this.
I'm not sure but I think there is a debugfs file for cma.
Can you use it?
Or what do you think about making another proc file to show cma area size and address?
For instance,
# cat /proc/cmainfo
CMATotal: 400kB
0x10000000 300kB
0x20000000 100kB
Hi,
----- Original Message -----
> From: Gioh Kim <[email protected]>
> To: Pintu Kumar <[email protected]>; [email protected];
[email protected]; [email protected]; [email protected];
[email protected]; [email protected]; [email protected];
[email protected]; [email protected]; [email protected]; aneesh.
[email protected]; [email protected]; [email protected];
[email protected]; [email protected]; [email protected]; linux-
[email protected]
> Cc: [email protected]; [email protected]; [email protected];
[email protected]; [email protected]; ?̰?ȣ <[email protected]>
> Sent: Tuesday, 21 October 2014 6:17 AM
> Subject: Re: [PATCH] mm: cma: split cma-reserved in dmesg log
>
>
>
> 2014-10-20 ???? 4:33, Pintu Kumar ?? ??:
>> When the system boots up, in the dmesg logs we can see
>> the memory statistics along with total reserved as below.
>> Memory: 458840k/458840k available, 65448k reserved, 0K highmem
>>
>> When CMA is enabled, still the total reserved memory remains the same.
>> However, the CMA memory is not considered as reserved.
>> But, when we see /proc/meminfo, the CMA memory is part of free memory.
>> This creates confusion.
>> This patch corrects the problem by properly substracting the CMA reserved
>> memory from the total reserved memory in dmesg logs.
>>
>> Below is the dmesg snaphot from an arm based device with 512MB RAM and
>> 12MB single CMA region.
>>
>> Before this change:
>> Memory: 458840k/458840k available, 65448k reserved, 0K highmem
>>
>> After this change:
>> Memory: 458840k/458840k available, 53160k reserved, 12288k cma-reserved,
0K
> highmem
>>
>> Signed-off-by: Pintu Kumar <[email protected]>
>> Signed-off-by: Vishnu Pratap Singh <[email protected]>
>> ---
>> include/linux/swap.h | 3 +++
>> mm/cma.c | 2 ++
>> mm/page_alloc.c | 8 ++++++++
>> 3 files changed, 13 insertions(+)
>>
>> diff --git a/include/linux/swap.h b/include/linux/swap.h
>> index 37a585b..beb84be 100644
>> --- a/include/linux/swap.h
>> +++ b/include/linux/swap.h
>> @@ -295,6 +295,9 @@ static inline void
workingset_node_shadows_dec(struct
> radix_tree_node *node)
>> /* linux/mm/page_alloc.c */
>> extern unsigned long totalram_pages;
>> extern unsigned long totalreserve_pages;
>> +#ifdef CONFIG_CMA
>> +extern unsigned long totalcma_pages;
>> +#endif
Ok, as per Andrew Morton comment, will remove CONFIG_CMA,
But then I need to put it under: include/linux/mm.h
In that case, it will solve the problem for CMA and non-CMA case.
Because, mm.h is already included in cma.c
>> extern unsigned long dirty_balance_reserve;
>> extern unsigned long nr_free_buffer_pages(void);
>> extern unsigned long nr_free_pagecache_pages(void);
>> diff --git a/mm/cma.c b/mm/cma.c
>> index 963bc4a..73fe7be 100644
>> --- a/mm/cma.c
>> +++ b/mm/cma.c
>> @@ -45,6 +45,7 @@ struct cma {
>> static struct cma cma_areas[MAX_CMA_AREAS];
>> static unsigned cma_area_count;
>> static DEFINE_MUTEX(cma_mutex);
>> +unsigned long totalcma_pages __read_mostly;
>
> I think __read_mostly is not good here.
> Cma areas often are rare
> but we cannot expect how many cma areas exists.
>
Firstly, I want to move this to mm/page_alloc.c, so that it can be visible
for non-CMA cases.
Next, the purpose this variable is not only during init time.
Just like totalram_pages, I wanted to retain this variable to use it to
populate the CMA info, during /proc/meminfo.
Like:
CMATotal: (using totalcma_pages)
CMAFree: (using NR_FREE_CMA_PAGES)
I will post these changes in the next patch series.
Please let me know your comments.
>>
>> phys_addr_t cma_get_base(struct cma *cma)
>> {
>> @@ -288,6 +289,7 @@ int __init cma_declare_contiguous(phys_addr_t base,
>> if (ret)
>> goto err;
>>
>> + totalcma_pages += (size / PAGE_SIZE);
>> pr_info("Reserved %ld MiB at %08lx\n", (unsigned
> long)size / SZ_1M,
>> (unsigned long)base);
>> return 0;
>> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
>> index dd73f9a..c6165ac 100644
>> --- a/mm/page_alloc.c
>> +++ b/mm/page_alloc.c
>> @@ -5521,6 +5521,9 @@ void __init mem_init_print_info(const char *str)
>> pr_info("Memory: %luK/%luK available "
>> "(%luK kernel code, %luK rwdata, %luK rodata, "
>> "%luK init, %luK bss, %luK reserved"
>> +#ifdef CONFIG_CMA
>> + ", %luK cma-reserved"
>> +#endif
>> #ifdef CONFIG_HIGHMEM
>> ", %luK highmem"
>> #endif
>> @@ -5528,7 +5531,12 @@ void __init mem_init_print_info(const char *str)
>> nr_free_pages() << (PAGE_SHIFT-10), physpages <<
> (PAGE_SHIFT-10),
>> codesize >> 10, datasize >> 10, rosize >>
> 10,
>> (init_data_size + init_code_size) >> 10, bss_size
>>> 10,
>> +#ifdef CONFIG_CMA
>> + (physpages - totalram_pages - totalcma_pages) <<
> (PAGE_SHIFT-10),
>> + totalcma_pages << (PAGE_SHIFT-10),
>> +#else
>> (physpages - totalram_pages) << (PAGE_SHIFT-10),
>> +#endif
>> #ifdef CONFIG_HIGHMEM
>> totalhigh_pages << (PAGE_SHIFT-10),
>> #endif
>>
>
> I basically agree with your point.
> But CMA feature is not popular yet, so memory develoers probably doesn't
> like this.
>
Ok agree. If we move totalcma_pages declaration to page_alloc.c and mm.h,
then we can get rid of CONFIG_CMA, to make it neat.
> I'm not sure but I think there is a debugfs file for cma.
> Can you use it?
>
As of now, I think there is no debugfs for cma.
However, we can make one if required.
> Or what do you think about making another proc file to show cma area size
and
> address?
> For instance,
>
> # cat /proc/cmainfo
> CMATotal: 400kB
> 0x10000000 300kB
> 0x20000000 100kB
>
I think this is not required.
For multiple CMA regions, this can be found under:
/sys/kernel/debug/memblock/reserved
However, as I said, we can populate this information under: /proc/meminfo
I think capturing it at one place will be better. For non-CMA cases, it
will be hidden.
Thus summary of CMA info can be seen in meminfo, and detailed information
can be seen in memblock/reserved.
Do, let me know if you have any other idea?
>
> --
> To unsubscribe, send a message with 'unsubscribe linux-mm' in
> the body to [email protected]. For more info on Linux MM,
> see: http://www.linux-mm.org/ .
> Don't email: <a href=mailto:"[email protected]">
> [email protected] </a>
>
2014-10-21 ???? 10:21, PINTU KUMAR ?? ??:
>
> Hi,
>
> ----- Original Message -----
>> From: Gioh Kim <[email protected]>
>> To: Pintu Kumar <[email protected]>; [email protected];
> [email protected]; [email protected]; [email protected];
> [email protected]; [email protected]; [email protected];
> [email protected]; [email protected]; [email protected]; aneesh.
> [email protected]; [email protected]; [email protected];
> [email protected]; [email protected]; [email protected]; linux-
> [email protected]
>> Cc: [email protected]; [email protected]; [email protected];
> [email protected]; [email protected]; ?̰?ȣ <[email protected]>
>> Sent: Tuesday, 21 October 2014 6:17 AM
>> Subject: Re: [PATCH] mm: cma: split cma-reserved in dmesg log
>>
>>
>>
>> 2014-10-20 ???? 4:33, Pintu Kumar ?? ??:
>>> When the system boots up, in the dmesg logs we can see
>>> the memory statistics along with total reserved as below.
>>> Memory: 458840k/458840k available, 65448k reserved, 0K highmem
>>>
>>> When CMA is enabled, still the total reserved memory remains the same.
>>> However, the CMA memory is not considered as reserved.
>>> But, when we see /proc/meminfo, the CMA memory is part of free memory.
>>> This creates confusion.
>>> This patch corrects the problem by properly substracting the CMA reserved
>>> memory from the total reserved memory in dmesg logs.
>>>
>>> Below is the dmesg snaphot from an arm based device with 512MB RAM and
>>> 12MB single CMA region.
>>>
>>> Before this change:
>>> Memory: 458840k/458840k available, 65448k reserved, 0K highmem
>>>
>>> After this change:
>>> Memory: 458840k/458840k available, 53160k reserved, 12288k cma-reserved,
> 0K
>> highmem
>>>
>>> Signed-off-by: Pintu Kumar <[email protected]>
>>> Signed-off-by: Vishnu Pratap Singh <[email protected]>
>>> ---
>>> include/linux/swap.h | 3 +++
>>> mm/cma.c | 2 ++
>>> mm/page_alloc.c | 8 ++++++++
>>> 3 files changed, 13 insertions(+)
>>>
>>> diff --git a/include/linux/swap.h b/include/linux/swap.h
>>> index 37a585b..beb84be 100644
>>> --- a/include/linux/swap.h
>>> +++ b/include/linux/swap.h
>>> @@ -295,6 +295,9 @@ static inline void
> workingset_node_shadows_dec(struct
>> radix_tree_node *node)
>>> /* linux/mm/page_alloc.c */
>>> extern unsigned long totalram_pages;
>>> extern unsigned long totalreserve_pages;
>>> +#ifdef CONFIG_CMA
>>> +extern unsigned long totalcma_pages;
>>> +#endif
>
> Ok, as per Andrew Morton comment, will remove CONFIG_CMA,
> But then I need to put it under: include/linux/mm.h
> In that case, it will solve the problem for CMA and non-CMA case.
> Because, mm.h is already included in cma.c
>
>>> extern unsigned long dirty_balance_reserve;
>>> extern unsigned long nr_free_buffer_pages(void);
>>> extern unsigned long nr_free_pagecache_pages(void);
>>> diff --git a/mm/cma.c b/mm/cma.c
>>> index 963bc4a..73fe7be 100644
>>> --- a/mm/cma.c
>>> +++ b/mm/cma.c
>>> @@ -45,6 +45,7 @@ struct cma {
>>> static struct cma cma_areas[MAX_CMA_AREAS];
>>> static unsigned cma_area_count;
>>> static DEFINE_MUTEX(cma_mutex);
>>> +unsigned long totalcma_pages __read_mostly;
>>
>> I think __read_mostly is not good here.
>> Cma areas often are rare
>> but we cannot expect how many cma areas exists.
>>
>
> Firstly, I want to move this to mm/page_alloc.c, so that it can be visible
> for non-CMA cases.
> Next, the purpose this variable is not only during init time.
> Just like totalram_pages, I wanted to retain this variable to use it to
> populate the CMA info, during /proc/meminfo.
> Like:
> CMATotal: (using totalcma_pages)
> CMAFree: (using NR_FREE_CMA_PAGES)
> I will post these changes in the next patch series.
> Please let me know your comments.
>
>>>
>>> phys_addr_t cma_get_base(struct cma *cma)
>>> {
>>> @@ -288,6 +289,7 @@ int __init cma_declare_contiguous(phys_addr_t base,
>>> if (ret)
>>> goto err;
>>>
>>> + totalcma_pages += (size / PAGE_SIZE);
>>> pr_info("Reserved %ld MiB at %08lx\n", (unsigned
>> long)size / SZ_1M,
>>> (unsigned long)base);
>>> return 0;
>>> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
>>> index dd73f9a..c6165ac 100644
>>> --- a/mm/page_alloc.c
>>> +++ b/mm/page_alloc.c
>>> @@ -5521,6 +5521,9 @@ void __init mem_init_print_info(const char *str)
>>> pr_info("Memory: %luK/%luK available "
>>> "(%luK kernel code, %luK rwdata, %luK rodata, "
>>> "%luK init, %luK bss, %luK reserved"
>>> +#ifdef CONFIG_CMA
>>> + ", %luK cma-reserved"
>>> +#endif
>>> #ifdef CONFIG_HIGHMEM
>>> ", %luK highmem"
>>> #endif
>>> @@ -5528,7 +5531,12 @@ void __init mem_init_print_info(const char *str)
>>> nr_free_pages() << (PAGE_SHIFT-10), physpages <<
>> (PAGE_SHIFT-10),
>>> codesize >> 10, datasize >> 10, rosize >>
>> 10,
>>> (init_data_size + init_code_size) >> 10, bss_size
>>>> 10,
>>> +#ifdef CONFIG_CMA
>>> + (physpages - totalram_pages - totalcma_pages) <<
>> (PAGE_SHIFT-10),
>>> + totalcma_pages << (PAGE_SHIFT-10),
>>> +#else
>>> (physpages - totalram_pages) << (PAGE_SHIFT-10),
>>> +#endif
>>> #ifdef CONFIG_HIGHMEM
>>> totalhigh_pages << (PAGE_SHIFT-10),
>>> #endif
>>>
>>
>> I basically agree with your point.
>> But CMA feature is not popular yet, so memory develoers probably doesn't
>> like this.
>>
>
> Ok agree. If we move totalcma_pages declaration to page_alloc.c and mm.h,
> then we can get rid of CONFIG_CMA, to make it neat.
>
>
>> I'm not sure but I think there is a debugfs file for cma.
>> Can you use it?
>>
>
> As of now, I think there is no debugfs for cma.
> However, we can make one if required.
>
>> Or what do you think about making another proc file to show cma area size
> and
>> address?
>> For instance,
>>
>> # cat /proc/cmainfo
>> CMATotal: 400kB
>> 0x10000000 300kB
>> 0x20000000 100kB
>>
>
> I think this is not required.
> For multiple CMA regions, this can be found under:
> /sys/kernel/debug/memblock/reserved
I'm sorry. I didn't know it.
> However, as I said, we can populate this information under: /proc/meminfo
> I think capturing it at one place will be better. For non-CMA cases, it
> will be hidden.
> Thus summary of CMA info can be seen in meminfo, and detailed information
> can be seen in memblock/reserved.
I agree with you.
I'm looking forward to your next patch.
> Do, let me know if you have any other idea?
>
>>
>> --
>> To unsubscribe, send a message with 'unsubscribe linux-mm' in
>> the body to [email protected]. For more info on Linux MM,
>> see: http://www.linux-mm.org/ .
>> Don't email: <a href=mailto:"[email protected]">
>> [email protected] </a>
>>
>
>
When the system boots up, in the dmesg logs we can see
the memory statistics along with total reserved as below.
Memory: 458840k/458840k available, 65448k reserved, 0K highmem
When CMA is enabled, still the total reserved memory remains the same.
However, the CMA memory is not considered as reserved.
But, when we see /proc/meminfo, the CMA memory is part of free memory.
This creates confusion.
This patch corrects the problem by properly subtracting the CMA reserved
memory from the total reserved memory in dmesg logs.
Below is the dmesg snapshot from an arm based device with 512MB RAM and
12MB single CMA region.
Before this change:
Memory: 458840k/458840k available, 65448k reserved, 0K highmem
After this change:
Memory: 458840k/458840k available, 53160k reserved, 12288k cma-reserved, 0K highmem
Signed-off-by: Pintu Kumar <[email protected]>
Signed-off-by: Vishnu Pratap Singh <[email protected]>
---
v2: Moved totalcma_pages extern declaration to linux/cma.h
Removed CONFIG_CMA while show cma-reserved, from page_alloc.c
Moved totalcma_pages declaration to page_alloc.c, so that if will be visible
in non-CMA cases.
include/linux/cma.h | 1 +
mm/cma.c | 1 +
mm/page_alloc.c | 6 ++++--
3 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/include/linux/cma.h b/include/linux/cma.h
index 0430ed0..0b75896 100644
--- a/include/linux/cma.h
+++ b/include/linux/cma.h
@@ -15,6 +15,7 @@
struct cma;
+extern unsigned long totalcma_pages;
extern phys_addr_t cma_get_base(struct cma *cma);
extern unsigned long cma_get_size(struct cma *cma);
diff --git a/mm/cma.c b/mm/cma.c
index 963bc4a..8435762 100644
--- a/mm/cma.c
+++ b/mm/cma.c
@@ -288,6 +288,7 @@ int __init cma_declare_contiguous(phys_addr_t base,
if (ret)
goto err;
+ totalcma_pages += (size / PAGE_SIZE);
pr_info("Reserved %ld MiB at %08lx\n", (unsigned long)size / SZ_1M,
(unsigned long)base);
return 0;
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index dd73f9a..ababbd8 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -110,6 +110,7 @@ static DEFINE_SPINLOCK(managed_page_count_lock);
unsigned long totalram_pages __read_mostly;
unsigned long totalreserve_pages __read_mostly;
+unsigned long totalcma_pages __read_mostly;
/*
* When calculating the number of globally allowed dirty pages, there
* is a certain number of per-zone reserves that should not be
@@ -5520,7 +5521,7 @@ void __init mem_init_print_info(const char *str)
pr_info("Memory: %luK/%luK available "
"(%luK kernel code, %luK rwdata, %luK rodata, "
- "%luK init, %luK bss, %luK reserved"
+ "%luK init, %luK bss, %luK reserved, %luK cma-reserved"
#ifdef CONFIG_HIGHMEM
", %luK highmem"
#endif
@@ -5528,7 +5529,8 @@ void __init mem_init_print_info(const char *str)
nr_free_pages() << (PAGE_SHIFT-10), physpages << (PAGE_SHIFT-10),
codesize >> 10, datasize >> 10, rosize >> 10,
(init_data_size + init_code_size) >> 10, bss_size >> 10,
- (physpages - totalram_pages) << (PAGE_SHIFT-10),
+ (physpages - totalram_pages - totalcma_pages) << (PAGE_SHIFT-10),
+ totalcma_pages << (PAGE_SHIFT-10),
#ifdef CONFIG_HIGHMEM
totalhigh_pages << (PAGE_SHIFT-10),
#endif
--
1.7.9.5
This patch include CMA info (CMATotal, CMAFree) in /proc/meminfo.
Currently, in a CMA enabled system, if somebody wants to know the
total CMA size declared, there is no way to tell, other than the dmesg
or /var/log/messages logs.
With this patch we are showing the CMA info as part of meminfo, so that
it can be determined at any point of time.
This will be populated only when CMA is enabled.
Below is the sample output from a ARM based device with RAM:512MB and CMA:16MB.
MemTotal: 471172 kB
MemFree: 111712 kB
MemAvailable: 271172 kB
.
.
.
CmaTotal: 16384 kB
CmaFree: 6144 kB
This patch also fix below checkpatch errors that were found during these changes.
ERROR: space required after that ',' (ctx:ExV)
199: FILE: fs/proc/meminfo.c:199:
+ ,atomic_long_read(&num_poisoned_pages) << (PAGE_SHIFT - 10)
^
ERROR: space required after that ',' (ctx:ExV)
202: FILE: fs/proc/meminfo.c:202:
+ ,K(global_page_state(NR_ANON_TRANSPARENT_HUGEPAGES) *
^
ERROR: space required after that ',' (ctx:ExV)
206: FILE: fs/proc/meminfo.c:206:
+ ,K(totalcma_pages)
^
total: 3 errors, 0 warnings, 2 checks, 236 lines checked
Signed-off-by: Pintu Kumar <[email protected]>
Signed-off-by: Vishnu Pratap Singh <[email protected]>
---
fs/proc/meminfo.c | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/fs/proc/meminfo.c b/fs/proc/meminfo.c
index aa1eee0..d3ebf2e 100644
--- a/fs/proc/meminfo.c
+++ b/fs/proc/meminfo.c
@@ -12,6 +12,9 @@
#include <linux/vmstat.h>
#include <linux/atomic.h>
#include <linux/vmalloc.h>
+#ifdef CONFIG_CMA
+#include <linux/cma.h>
+#endif
#include <asm/page.h>
#include <asm/pgtable.h>
#include "internal.h"
@@ -138,6 +141,10 @@ static int meminfo_proc_show(struct seq_file *m, void *v)
#ifdef CONFIG_TRANSPARENT_HUGEPAGE
"AnonHugePages: %8lu kB\n"
#endif
+#ifdef CONFIG_CMA
+ "CmaTotal: %8lu kB\n"
+ "CmaFree: %8lu kB\n"
+#endif
,
K(i.totalram),
K(i.freeram),
@@ -187,12 +194,16 @@ static int meminfo_proc_show(struct seq_file *m, void *v)
vmi.used >> 10,
vmi.largest_chunk >> 10
#ifdef CONFIG_MEMORY_FAILURE
- ,atomic_long_read(&num_poisoned_pages) << (PAGE_SHIFT - 10)
+ , atomic_long_read(&num_poisoned_pages) << (PAGE_SHIFT - 10)
#endif
#ifdef CONFIG_TRANSPARENT_HUGEPAGE
- ,K(global_page_state(NR_ANON_TRANSPARENT_HUGEPAGES) *
+ , K(global_page_state(NR_ANON_TRANSPARENT_HUGEPAGES) *
HPAGE_PMD_NR)
#endif
+#ifdef CONFIG_CMA
+ , K(totalcma_pages)
+ , K(global_page_state(NR_FREE_CMA_PAGES))
+#endif
);
hugetlb_report_meminfo(m);
--
1.7.9.5
On Wed, 22 Oct 2014 19:36:35 +0530 Pintu Kumar <[email protected]> wrote:
> This patch include CMA info (CMATotal, CMAFree) in /proc/meminfo.
> Currently, in a CMA enabled system, if somebody wants to know the
> total CMA size declared, there is no way to tell, other than the dmesg
> or /var/log/messages logs.
> With this patch we are showing the CMA info as part of meminfo, so that
> it can be determined at any point of time.
> This will be populated only when CMA is enabled.
Fair enough.
We should be pretty careful about what we put in meminfo - it's the
top-level, most-important procfs file and I expect that quite a lot of
userspace reads it with some frequency. We don't want to clutter it
up. /proc/vmstat is a suitable place for the less important info which
is more kernel developer oriented.
But CMATotal and CMAFree do pass the "should be in meminfo" test, IMO.
2014-10-22 ???? 11:06, Pintu Kumar ?? ??:
> This patch include CMA info (CMATotal, CMAFree) in /proc/meminfo.
> Currently, in a CMA enabled system, if somebody wants to know the
> total CMA size declared, there is no way to tell, other than the dmesg
> or /var/log/messages logs.
> With this patch we are showing the CMA info as part of meminfo, so that
> it can be determined at any point of time.
> This will be populated only when CMA is enabled.
>
> Below is the sample output from a ARM based device with RAM:512MB and CMA:16MB.
>
> MemTotal: 471172 kB
> MemFree: 111712 kB
> MemAvailable: 271172 kB
> .
> .
> .
> CmaTotal: 16384 kB
> CmaFree: 6144 kB
>
> This patch also fix below checkpatch errors that were found during these changes.
Why don't you split patch for it?
I think there's a rule not to mix separate patchs.
>
> ERROR: space required after that ',' (ctx:ExV)
> 199: FILE: fs/proc/meminfo.c:199:
> + ,atomic_long_read(&num_poisoned_pages) << (PAGE_SHIFT - 10)
> ^
>
> ERROR: space required after that ',' (ctx:ExV)
> 202: FILE: fs/proc/meminfo.c:202:
> + ,K(global_page_state(NR_ANON_TRANSPARENT_HUGEPAGES) *
> ^
>
> ERROR: space required after that ',' (ctx:ExV)
> 206: FILE: fs/proc/meminfo.c:206:
> + ,K(totalcma_pages)
> ^
>
> total: 3 errors, 0 warnings, 2 checks, 236 lines checked
>
> Signed-off-by: Pintu Kumar <[email protected]>
> Signed-off-by: Vishnu Pratap Singh <[email protected]>
> ---
> fs/proc/meminfo.c | 15 +++++++++++++--
> 1 file changed, 13 insertions(+), 2 deletions(-)
>
> diff --git a/fs/proc/meminfo.c b/fs/proc/meminfo.c
> index aa1eee0..d3ebf2e 100644
> --- a/fs/proc/meminfo.c
> +++ b/fs/proc/meminfo.c
> @@ -12,6 +12,9 @@
> #include <linux/vmstat.h>
> #include <linux/atomic.h>
> #include <linux/vmalloc.h>
> +#ifdef CONFIG_CMA
> +#include <linux/cma.h>
> +#endif
> #include <asm/page.h>
> #include <asm/pgtable.h>
> #include "internal.h"
> @@ -138,6 +141,10 @@ static int meminfo_proc_show(struct seq_file *m, void *v)
> #ifdef CONFIG_TRANSPARENT_HUGEPAGE
> "AnonHugePages: %8lu kB\n"
> #endif
> +#ifdef CONFIG_CMA
> + "CmaTotal: %8lu kB\n"
> + "CmaFree: %8lu kB\n"
> +#endif
> ,
> K(i.totalram),
> K(i.freeram),
> @@ -187,12 +194,16 @@ static int meminfo_proc_show(struct seq_file *m, void *v)
> vmi.used >> 10,
> vmi.largest_chunk >> 10
> #ifdef CONFIG_MEMORY_FAILURE
> - ,atomic_long_read(&num_poisoned_pages) << (PAGE_SHIFT - 10)
> + , atomic_long_read(&num_poisoned_pages) << (PAGE_SHIFT - 10)
> #endif
> #ifdef CONFIG_TRANSPARENT_HUGEPAGE
> - ,K(global_page_state(NR_ANON_TRANSPARENT_HUGEPAGES) *
> + , K(global_page_state(NR_ANON_TRANSPARENT_HUGEPAGES) *
> HPAGE_PMD_NR)
> #endif
> +#ifdef CONFIG_CMA
> + , K(totalcma_pages)
> + , K(global_page_state(NR_FREE_CMA_PAGES))
> +#endif
> );
Just for sure, are zoneinfo and pagetypeinfo not suitable?
I don't know HOTPLUG feature so I'm just asking for sure.
Does HOTPLUG not need printing message like this?
Thanks a lot.
>
> hugetlb_report_meminfo(m);
>
On Wed, Oct 22 2014, Pintu Kumar wrote:
> When the system boots up, in the dmesg logs we can see
> the memory statistics along with total reserved as below.
> Memory: 458840k/458840k available, 65448k reserved, 0K highmem
>
> When CMA is enabled, still the total reserved memory remains the same.
> However, the CMA memory is not considered as reserved.
> But, when we see /proc/meminfo, the CMA memory is part of free memory.
> This creates confusion.
> This patch corrects the problem by properly subtracting the CMA reserved
> memory from the total reserved memory in dmesg logs.
>
> Below is the dmesg snapshot from an arm based device with 512MB RAM and
> 12MB single CMA region.
>
> Before this change:
> Memory: 458840k/458840k available, 65448k reserved, 0K highmem
>
> After this change:
> Memory: 458840k/458840k available, 53160k reserved, 12288k cma-reserved, 0K highmem
>
> Signed-off-by: Pintu Kumar <[email protected]>
> Signed-off-by: Vishnu Pratap Singh <[email protected]>
Acked-by: Michal Nazarewicz <[email protected]>
I'm not sure how Andrew would think about it, and I don't have strong
feelings, but I would consider a few changes:
> ---
> v2: Moved totalcma_pages extern declaration to linux/cma.h
> Removed CONFIG_CMA while show cma-reserved, from page_alloc.c
> Moved totalcma_pages declaration to page_alloc.c, so that if will be visible
> in non-CMA cases.
> include/linux/cma.h | 1 +
> mm/cma.c | 1 +
> mm/page_alloc.c | 6 ++++--
> 3 files changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/include/linux/cma.h b/include/linux/cma.h
> index 0430ed0..0b75896 100644
> --- a/include/linux/cma.h
> +++ b/include/linux/cma.h
> @@ -15,6 +15,7 @@
>
> struct cma;
>
> +extern unsigned long totalcma_pages;
+#ifdef CONFIG_CMA
+extern unsigned long totalcma_pages;
+#else
+# define totalcma_pages 0UL
+#endif
> extern phys_addr_t cma_get_base(struct cma *cma);
> extern unsigned long cma_get_size(struct cma *cma);
>
> diff --git a/mm/cma.c b/mm/cma.c
> index 963bc4a..8435762 100644
> --- a/mm/cma.c
> +++ b/mm/cma.c
> @@ -288,6 +288,7 @@ int __init cma_declare_contiguous(phys_addr_t base,
> if (ret)
> goto err;
>
> + totalcma_pages += (size / PAGE_SIZE);
> pr_info("Reserved %ld MiB at %08lx\n", (unsigned long)size / SZ_1M,
> (unsigned long)base);
> return 0;
> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> index dd73f9a..ababbd8 100644
> --- a/mm/page_alloc.c
> +++ b/mm/page_alloc.c
> @@ -110,6 +110,7 @@ static DEFINE_SPINLOCK(managed_page_count_lock);
>
> unsigned long totalram_pages __read_mostly;
> unsigned long totalreserve_pages __read_mostly;
> +unsigned long totalcma_pages __read_mostly;
Move this to cma.c.
> /*
> * When calculating the number of globally allowed dirty pages, there
> * is a certain number of per-zone reserves that should not be
> @@ -5520,7 +5521,7 @@ void __init mem_init_print_info(const char *str)
>
> pr_info("Memory: %luK/%luK available "
> "(%luK kernel code, %luK rwdata, %luK rodata, "
> - "%luK init, %luK bss, %luK reserved"
> + "%luK init, %luK bss, %luK reserved, %luK cma-reserved"
> #ifdef CONFIG_HIGHMEM
> ", %luK highmem"
> #endif
> @@ -5528,7 +5529,8 @@ void __init mem_init_print_info(const char *str)
> nr_free_pages() << (PAGE_SHIFT-10), physpages << (PAGE_SHIFT-10),
> codesize >> 10, datasize >> 10, rosize >> 10,
> (init_data_size + init_code_size) >> 10, bss_size >> 10,
> - (physpages - totalram_pages) << (PAGE_SHIFT-10),
> + (physpages - totalram_pages - totalcma_pages) << (PAGE_SHIFT-10),
> + totalcma_pages << (PAGE_SHIFT-10),
> #ifdef CONFIG_HIGHMEM
> totalhigh_pages << (PAGE_SHIFT-10),
> #endif
> --
> 1.7.9.5
>
--
Best regards, _ _
.o. | Liege of Serenely Enlightened Majesty of o' \,=./ `o
..o | Computer Science, Michał “mina86” Nazarewicz (o o)
ooo +--<[email protected]>--<xmpp:[email protected]>--ooO--(_)--Ooo--
Hi,
----- Original Message -----
> From: Gioh Kim <[email protected]>
> To: Pintu Kumar <[email protected]>; [email protected];
[email protected]; [email protected]; [email protected];
[email protected]; [email protected];
[email protected]; [email protected];
[email protected]; [email protected]; [email protected];
[email protected]; [email protected]; [email protected]; hannes@cmpxchg.
org; [email protected]; [email protected]; [email protected];
[email protected]
> Cc: [email protected]; [email protected]; [email protected];
[email protected]; [email protected]
> Sent: Thursday, 23 October 2014 5:49 AM
> Subject: Re: [PATCH v2 2/2] fs: proc: Include cma info in proc/meminfo
>
>
>
> 2014-10-22 ???? 11:06, Pintu Kumar ?? ??:
>> This patch include CMA info (CMATotal, CMAFree) in /proc/meminfo.
>> Currently, in a CMA enabled system, if somebody wants to know the
>> total CMA size declared, there is no way to tell, other than the dmesg
>> or /var/log/messages logs.
>> With this patch we are showing the CMA info as part of meminfo, so that
>> it can be determined at any point of time.
>> This will be populated only when CMA is enabled.
>>
>> Below is the sample output from a ARM based device with RAM:512MB and
> CMA:16MB.
>>
>> MemTotal: 471172 kB
>> MemFree: 111712 kB
>> MemAvailable: 271172 kB
>> .
>> .
>> .
>> CmaTotal: 16384 kB
>> CmaFree: 6144 kB
>>
>> This patch also fix below checkpatch errors that were found during these
> changes.
>
> Why don't you split patch for it?
> I think there's a rule not to mix separate patchs.
>
Last time when we submitted separate patches for checkpatch errors, it was
suggested to
Include these kinds of fixes along with some meaningful patches together.
So, we included it in same patch.
>>
>> ERROR: space required after that ',' (ctx:ExV)
>> 199: FILE: fs/proc/meminfo.c:199:
>> + ,atomic_long_read(&num_poisoned_pages) << (PAGE_SHIFT -
> 10)
>> ^
>>
>> ERROR: space required after that ',' (ctx:ExV)
>> 202: FILE: fs/proc/meminfo.c:202:
>> + ,K(global_page_state(NR_ANON_TRANSPARENT_HUGEPAGES) *
>> ^
>>
>> ERROR: space required after that ',' (ctx:ExV)
>> 206: FILE: fs/proc/meminfo.c:206:
>> + ,K(totalcma_pages)
>> ^
>>
>> total: 3 errors, 0 warnings, 2 checks, 236 lines checked
>>
>> Signed-off-by: Pintu Kumar <[email protected]>
>> Signed-off-by: Vishnu Pratap Singh <[email protected]>
>> ---
>> fs/proc/meminfo.c | 15 +++++++++++++--
>> 1 file changed, 13 insertions(+), 2 deletions(-)
>>
>> diff --git a/fs/proc/meminfo.c b/fs/proc/meminfo.c
>> index aa1eee0..d3ebf2e 100644
>> --- a/fs/proc/meminfo.c
>> +++ b/fs/proc/meminfo.c
>> @@ -12,6 +12,9 @@
>> #include <linux/vmstat.h>
>> #include <linux/atomic.h>
>> #include <linux/vmalloc.h>
>> +#ifdef CONFIG_CMA
>> +#include <linux/cma.h>
>> +#endif
>> #include <asm/page.h>
>> #include <asm/pgtable.h>
>> #include "internal.h"
>> @@ -138,6 +141,10 @@ static int meminfo_proc_show(struct seq_file *m,
void
> *v)
>> #ifdef CONFIG_TRANSPARENT_HUGEPAGE
>> "AnonHugePages: %8lu kB\n"
>> #endif
>> +#ifdef CONFIG_CMA
>> + "CmaTotal: %8lu kB\n"
>> + "CmaFree: %8lu kB\n"
>> +#endif
>> ,
>> K(i.totalram),
>> K(i.freeram),
>> @@ -187,12 +194,16 @@ static int meminfo_proc_show(struct seq_file *m,
void
> *v)
>> vmi.used >> 10,
>> vmi.largest_chunk >> 10
>> #ifdef CONFIG_MEMORY_FAILURE
>> - ,atomic_long_read(&num_poisoned_pages) << (PAGE_SHIFT -
> 10)
>> + , atomic_long_read(&num_poisoned_pages) << (PAGE_SHIFT -
> 10)
>> #endif
>> #ifdef CONFIG_TRANSPARENT_HUGEPAGE
>> - ,K(global_page_state(NR_ANON_TRANSPARENT_HUGEPAGES) *
>> + , K(global_page_state(NR_ANON_TRANSPARENT_HUGEPAGES) *
>> HPAGE_PMD_NR)
>> #endif
>> +#ifdef CONFIG_CMA
>> + , K(totalcma_pages)
>> + , K(global_page_state(NR_FREE_CMA_PAGES))
>> +#endif
>> );
>
> Just for sure, are zoneinfo and pagetypeinfo not suitable?
>
I think zoneinfo shows only current free cma pages.
Same is the case with vmstat.
# cat /proc/zoneinfo | grep cma
nr_free_cma 2560
# cat /proc/vmstat | grep cma
nr_free_cma 2560
> I don't know HOTPLUG feature so I'm just asking for sure.
> Does HOTPLUG not need printing message like this?
>
Sorry, I am also not sure what hotplug feature you are referring to.
> Thanks a lot.
>
>
>>
>> hugetlb_report_meminfo(m);
>>
>
> --
> To unsubscribe, send a message with 'unsubscribe linux-mm' in
> the body to [email protected]. For more info on Linux MM,
> see: http://www.linux-mm.org/ .
> Don't email: <a href=mailto:"[email protected]">
> [email protected] </a>
>
2014-10-24 ???? 5:57, PINTU KUMAR ?? ??:
> Hi,
>
> ----- Original Message -----
>> From: Gioh Kim <[email protected]>
>> To: Pintu Kumar <[email protected]>; [email protected];
> [email protected]; [email protected]; [email protected];
> [email protected]; [email protected];
> [email protected]; [email protected];
> [email protected]; [email protected]; [email protected];
> [email protected]; [email protected]; [email protected]; hannes@cmpxchg.
> org; [email protected]; [email protected]; [email protected];
> [email protected]
>> Cc: [email protected]; [email protected]; [email protected];
> [email protected]; [email protected]
>> Sent: Thursday, 23 October 2014 5:49 AM
>> Subject: Re: [PATCH v2 2/2] fs: proc: Include cma info in proc/meminfo
>>
>>
>>
>> 2014-10-22 ???? 11:06, Pintu Kumar ?? ??:
>>> This patch include CMA info (CMATotal, CMAFree) in /proc/meminfo.
>>> Currently, in a CMA enabled system, if somebody wants to know the
>>> total CMA size declared, there is no way to tell, other than the dmesg
>>> or /var/log/messages logs.
>>> With this patch we are showing the CMA info as part of meminfo, so that
>>> it can be determined at any point of time.
>>> This will be populated only when CMA is enabled.
>>>
>>> Below is the sample output from a ARM based device with RAM:512MB and
>> CMA:16MB.
>>>
>>> MemTotal: 471172 kB
>>> MemFree: 111712 kB
>>> MemAvailable: 271172 kB
>>> .
>>> .
>>> .
>>> CmaTotal: 16384 kB
>>> CmaFree: 6144 kB
>>>
>>> This patch also fix below checkpatch errors that were found during these
>> changes.
>>
>> Why don't you split patch for it?
>> I think there's a rule not to mix separate patchs.
>>
>
> Last time when we submitted separate patches for checkpatch errors, it was
> suggested to
> Include these kinds of fixes along with some meaningful patches together.
> So, we included it in same patch.
>
>>>
>>> ERROR: space required after that ',' (ctx:ExV)
>>> 199: FILE: fs/proc/meminfo.c:199:
>>> + ,atomic_long_read(&num_poisoned_pages) << (PAGE_SHIFT -
>> 10)
>>> ^
>>>
>>> ERROR: space required after that ',' (ctx:ExV)
>>> 202: FILE: fs/proc/meminfo.c:202:
>>> + ,K(global_page_state(NR_ANON_TRANSPARENT_HUGEPAGES) *
>>> ^
>>>
>>> ERROR: space required after that ',' (ctx:ExV)
>>> 206: FILE: fs/proc/meminfo.c:206:
>>> + ,K(totalcma_pages)
>>> ^
>>>
>>> total: 3 errors, 0 warnings, 2 checks, 236 lines checked
>>>
>>> Signed-off-by: Pintu Kumar <[email protected]>
>>> Signed-off-by: Vishnu Pratap Singh <[email protected]>
>>> ---
>>> fs/proc/meminfo.c | 15 +++++++++++++--
>>> 1 file changed, 13 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/fs/proc/meminfo.c b/fs/proc/meminfo.c
>>> index aa1eee0..d3ebf2e 100644
>>> --- a/fs/proc/meminfo.c
>>> +++ b/fs/proc/meminfo.c
>>> @@ -12,6 +12,9 @@
>>> #include <linux/vmstat.h>
>>> #include <linux/atomic.h>
>>> #include <linux/vmalloc.h>
>>> +#ifdef CONFIG_CMA
>>> +#include <linux/cma.h>
>>> +#endif
>>> #include <asm/page.h>
>>> #include <asm/pgtable.h>
>>> #include "internal.h"
>>> @@ -138,6 +141,10 @@ static int meminfo_proc_show(struct seq_file *m,
> void
>> *v)
>>> #ifdef CONFIG_TRANSPARENT_HUGEPAGE
>>> "AnonHugePages: %8lu kB\n"
>>> #endif
>>> +#ifdef CONFIG_CMA
>>> + "CmaTotal: %8lu kB\n"
>>> + "CmaFree: %8lu kB\n"
>>> +#endif
>>> ,
>>> K(i.totalram),
>>> K(i.freeram),
>>> @@ -187,12 +194,16 @@ static int meminfo_proc_show(struct seq_file *m,
> void
>> *v)
>>> vmi.used >> 10,
>>> vmi.largest_chunk >> 10
>>> #ifdef CONFIG_MEMORY_FAILURE
>>> - ,atomic_long_read(&num_poisoned_pages) << (PAGE_SHIFT -
>> 10)
>>> + , atomic_long_read(&num_poisoned_pages) << (PAGE_SHIFT -
>> 10)
>>> #endif
>>> #ifdef CONFIG_TRANSPARENT_HUGEPAGE
>>> - ,K(global_page_state(NR_ANON_TRANSPARENT_HUGEPAGES) *
>>> + , K(global_page_state(NR_ANON_TRANSPARENT_HUGEPAGES) *
>>> HPAGE_PMD_NR)
>>> #endif
>>> +#ifdef CONFIG_CMA
>>> + , K(totalcma_pages)
>>> + , K(global_page_state(NR_FREE_CMA_PAGES))
>>> +#endif
>>> );
>>
>> Just for sure, are zoneinfo and pagetypeinfo not suitable?
>>
>
> I think zoneinfo shows only current free cma pages.
> Same is the case with vmstat.
> # cat /proc/zoneinfo | grep cma
> nr_free_cma 2560
> # cat /proc/vmstat | grep cma
> nr_free_cma 2560
We could add a line to show total cma pages like following and add it all.
# cat /proc/zoneinfo | grep cma
nr_total_cma XXXX
nr_free_cma 2560
Yes. each zone can have cma area and it is annoying to add it all.
But IMO it is rare and not difficult.
And I think it'd better that zoneinfo has nr_total_cma line.
I think you already considered my thoughts and choosed /proc/meminfo for a certain reason.
Why is /proc/meminfo better?
Andrew already accepted it. I'm not against your idea. Just curious.
>
>> I don't know HOTPLUG feature so I'm just asking for sure.
>> Does HOTPLUG not need printing message like this?
>>
>
> Sorry, I am also not sure what hotplug feature you are referring to.
I mean "memory hotplug" feature.
Forget it ;-)
>
>> Thanks a lot.
>>
>>
>>>
>>> hugetlb_report_meminfo(m);
>>>
>>
>> --
>> To unsubscribe, send a message with 'unsubscribe linux-mm' in
>> the body to [email protected]. For more info on Linux MM,
>> see: http://www.linux-mm.org/ .
>> Don't email: <a href=mailto:"[email protected]">
>> [email protected] </a>
>>
>
>
----- Original Message -----
> From: Michal Nazarewicz <[email protected]>
> To: Pintu Kumar <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
> Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
> Sent: Thursday, 23 October 2014 10:31 PM
> Subject: Re: [PATCH v2 1/2] mm: cma: split cma-reserved in dmesg log
>
> On Wed, Oct 22 2014, Pintu Kumar wrote:
>> When the system boots up, in the dmesg logs we can see
>> the memory statistics along with total reserved as below.
>> Memory: 458840k/458840k available, 65448k reserved, 0K highmem
>>
>> When CMA is enabled, still the total reserved memory remains the same.
>> However, the CMA memory is not considered as reserved.
>> But, when we see /proc/meminfo, the CMA memory is part of free memory.
>> This creates confusion.
>> This patch corrects the problem by properly subtracting the CMA reserved
>> memory from the total reserved memory in dmesg logs.
>>
>> Below is the dmesg snapshot from an arm based device with 512MB RAM and
>> 12MB single CMA region.
>>
>> Before this change:
>> Memory: 458840k/458840k available, 65448k reserved, 0K highmem
>>
>> After this change:
>> Memory: 458840k/458840k available, 53160k reserved, 12288k cma-reserved, 0K
> highmem
>>
>> Signed-off-by: Pintu Kumar <[email protected]>
>> Signed-off-by: Vishnu Pratap Singh <[email protected]>
>
> Acked-by: Michal Nazarewicz <[email protected]>
>
>
> I'm not sure how Andrew would think about it, and I don't have strong
> feelings, but I would consider a few changes:
>
>> ---
>> v2: Moved totalcma_pages extern declaration to linux/cma.h
>> Removed CONFIG_CMA while show cma-reserved, from page_alloc.c
>> Moved totalcma_pages declaration to page_alloc.c, so that if will be
> visible
>> in non-CMA cases.
>> include/linux/cma.h | 1 +
>> mm/cma.c | 1 +
>> mm/page_alloc.c | 6 ++++--
>> 3 files changed, 6 insertions(+), 2 deletions(-)
>>
>> diff --git a/include/linux/cma.h b/include/linux/cma.h
>> index 0430ed0..0b75896 100644
>> --- a/include/linux/cma.h
>> +++ b/include/linux/cma.h
>> @@ -15,6 +15,7 @@
>>
>> struct cma;
>>
>> +extern unsigned long totalcma_pages;
>
> +#ifdef CONFIG_CMA
> +extern unsigned long totalcma_pages;
> +#else
> +# define totalcma_pages 0UL
> +#endif
>
>> extern phys_addr_t cma_get_base(struct cma *cma);
>> extern unsigned long cma_get_size(struct cma *cma);
>>
>> diff --git a/mm/cma.c b/mm/cma.c
>> index 963bc4a..8435762 100644
>> --- a/mm/cma.c
>> +++ b/mm/cma.c
>> @@ -288,6 +288,7 @@ int __init cma_declare_contiguous(phys_addr_t base,
>> if (ret)
>> goto err;
>>
>> + totalcma_pages += (size / PAGE_SIZE);
>> pr_info("Reserved %ld MiB at %08lx\n", (unsigned
> long)size / SZ_1M,
>> (unsigned long)base);
>> return 0;
>> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
>> index dd73f9a..ababbd8 100644
>> --- a/mm/page_alloc.c
>> +++ b/mm/page_alloc.c
>> @@ -110,6 +110,7 @@ static DEFINE_SPINLOCK(managed_page_count_lock);
>>
>> unsigned long totalram_pages __read_mostly;
>> unsigned long totalreserve_pages __read_mostly;
>> +unsigned long totalcma_pages __read_mostly;
>
> Move this to cma.c.
>
In our earlier patch (first version), we added it in cmc.c itself.
But, Andrew wanted this variable to be visible in non-CMA case as well to avoid build error, when we use
this variable in mem_init_print_info, without CONFIG_CMA.
So, we moved it to page_alloc.c
>> /*
>> * When calculating the number of globally allowed dirty pages, there
>> * is a certain number of per-zone reserves that should not be
>> @@ -5520,7 +5521,7 @@ void __init mem_init_print_info(const char *str)
>>
>> pr_info("Memory: %luK/%luK available "
>> "(%luK kernel code, %luK rwdata, %luK rodata, "
>> - "%luK init, %luK bss, %luK reserved"
>> + "%luK init, %luK bss, %luK reserved, %luK
> cma-reserved"
>> #ifdef CONFIG_HIGHMEM
>> ", %luK highmem"
>> #endif
>> @@ -5528,7 +5529,8 @@ void __init mem_init_print_info(const char *str)
>> nr_free_pages() << (PAGE_SHIFT-10), physpages <<
> (PAGE_SHIFT-10),
>> codesize >> 10, datasize >> 10, rosize >> 10,
>> (init_data_size + init_code_size) >> 10, bss_size
>>> 10,
>> - (physpages - totalram_pages) << (PAGE_SHIFT-10),
>> + (physpages - totalram_pages - totalcma_pages) <<
> (PAGE_SHIFT-10),
>> + totalcma_pages << (PAGE_SHIFT-10),
>> #ifdef CONFIG_HIGHMEM
>> totalhigh_pages << (PAGE_SHIFT-10),
>> #endif
>> --
>> 1.7.9.5
>>
>
> --
> Best regards, _ _
> .o. | Liege of Serenely Enlightened Majesty of o' \,=./ `o
> ..o | Computer Science, Michał “mina86” Nazarewicz (o o)
> ooo +--<[email protected]>--<xmpp:[email protected]>--ooO--(_)--Ooo--
>
> --
> To unsubscribe, send a message with 'unsubscribe linux-mm' in
> the body to [email protected]. For more info on Linux MM,
> see: http://www.linux-mm.org/ .
> Don't email: <a href=mailto:"[email protected]">
> [email protected] </a>
>
----- Original Message -----
> From: Gioh Kim <[email protected]>
> To: PINTU KUMAR <[email protected]>; [email protected];
[email protected]; [email protected]; [email protected];
[email protected]; [email protected];
[email protected]; [email protected];
[email protected]; [email protected]; [email protected];
[email protected]; [email protected]; [email protected]; hannes@cmpxchg.
org; [email protected]; [email protected]; [email protected];
[email protected]
> Cc: [email protected]; [email protected]; [email protected];
[email protected]; [email protected]
> Sent: Friday, 24 October 2014 3:40 PM
> Subject: Re: [PATCH v2 2/2] fs: proc: Include cma info in proc/meminfo
>
>
>
> 2014-10-24 ???? 5:57, PINTU KUMAR ?? ??:
>> Hi,
>>
>> ----- Original Message -----
>>> From: Gioh Kim <[email protected]>
>>> To: Pintu Kumar <[email protected]>; [email protected];
>> [email protected]; [email protected]; [email protected];
>> [email protected]; [email protected];
>> [email protected]; [email protected];
>> [email protected]; [email protected];
[email protected];
>> [email protected]; [email protected]; [email protected];
> hannes@cmpxchg.
>> org; [email protected]; [email protected]; linux-
[email protected];
>> [email protected]
>>> Cc: [email protected]; [email protected]; [email protected];
>> [email protected]; [email protected]
>>> Sent: Thursday, 23 October 2014 5:49 AM
>>> Subject: Re: [PATCH v2 2/2] fs: proc: Include cma info in proc/meminfo
>>>
>>>
>>>
>>> 2014-10-22 ???? 11:06, Pintu Kumar ?? ??:
>>>> This patch include CMA info (CMATotal, CMAFree) in /proc/meminfo.
>>>> Currently, in a CMA enabled system, if somebody wants to know the
>>>> total CMA size declared, there is no way to tell, other than the
> dmesg
>>>> or /var/log/messages logs.
>>>> With this patch we are showing the CMA info as part of meminfo, so
> that
>>>> it can be determined at any point of time.
>>>> This will be populated only when CMA is enabled.
>>>>
>>>> Below is the sample output from a ARM based device with RAM:512MB
> and
>>> CMA:16MB.
>>>>
>>>> MemTotal: 471172 kB
>>>> MemFree: 111712 kB
>>>> MemAvailable: 271172 kB
>>>> .
>>>> .
>>>> .
>>>> CmaTotal: 16384 kB
>>>> CmaFree: 6144 kB
>>>>
>>>> This patch also fix below checkpatch errors that were found during
> these
>>> changes.
>>>
>>> Why don't you split patch for it?
>>> I think there's a rule not to mix separate patchs.
>>>
>>
>> Last time when we submitted separate patches for checkpatch errors, it
was
>> suggested to
>> Include these kinds of fixes along with some meaningful patches together.
>> So, we included it in same patch.
>>
>>>>
>>>> ERROR: space required after that ',' (ctx:ExV)
>>>> 199: FILE: fs/proc/meminfo.c:199:
>>>> + ,atomic_long_read(&num_poisoned_pages) <<
> (PAGE_SHIFT -
>>> 10)
>>>> ^
>>>>
>>>> ERROR: space required after that ',' (ctx:ExV)
>>>> 202: FILE: fs/proc/meminfo.c:202:
>>>> + ,K(global_page_state(NR_ANON_TRANSPARENT_HUGEPAGES) *
>>>> ^
>>>>
>>>> ERROR: space required after that ',' (ctx:ExV)
>>>> 206: FILE: fs/proc/meminfo.c:206:
>>>> + ,K(totalcma_pages)
>>>> ^
>>>>
>>>> total: 3 errors, 0 warnings, 2 checks, 236 lines checked
>>>>
>>>> Signed-off-by: Pintu Kumar <[email protected]>
>>>> Signed-off-by: Vishnu Pratap Singh <[email protected]>
>>>> ---
>>>> fs/proc/meminfo.c | 15 +++++++++++++--
>>>> 1 file changed, 13 insertions(+), 2 deletions(-)
>>>>
>>>> diff --git a/fs/proc/meminfo.c b/fs/proc/meminfo.c
>>>> index aa1eee0..d3ebf2e 100644
>>>> --- a/fs/proc/meminfo.c
>>>> +++ b/fs/proc/meminfo.c
>>>> @@ -12,6 +12,9 @@
>>>> #include <linux/vmstat.h>
>>>> #include <linux/atomic.h>
>>>> #include <linux/vmalloc.h>
>>>> +#ifdef CONFIG_CMA
>>>> +#include <linux/cma.h>
>>>> +#endif
>>>> #include <asm/page.h>
>>>> #include <asm/pgtable.h>
>>>> #include "internal.h"
>>>> @@ -138,6 +141,10 @@ static int meminfo_proc_show(struct seq_file
> *m,
>> void
>>> *v)
>>>> #ifdef CONFIG_TRANSPARENT_HUGEPAGE
>>>> "AnonHugePages: %8lu kB\n"
>>>> #endif
>>>> +#ifdef CONFIG_CMA
>>>> + "CmaTotal: %8lu kB\n"
>>>> + "CmaFree: %8lu kB\n"
>>>> +#endif
>>>> ,
>>>> K(i.totalram),
>>>> K(i.freeram),
>>>> @@ -187,12 +194,16 @@ static int meminfo_proc_show(struct seq_file
> *m,
>> void
>>> *v)
>>>> vmi.used >> 10,
>>>> vmi.largest_chunk >> 10
>>>> #ifdef CONFIG_MEMORY_FAILURE
>>>> - ,atomic_long_read(&num_poisoned_pages) <<
> (PAGE_SHIFT -
>>> 10)
>>>> + , atomic_long_read(&num_poisoned_pages) <<
> (PAGE_SHIFT -
>>> 10)
>>>> #endif
>>>> #ifdef CONFIG_TRANSPARENT_HUGEPAGE
>>>> - ,K(global_page_state(NR_ANON_TRANSPARENT_HUGEPAGES) *
>>>> + , K(global_page_state(NR_ANON_TRANSPARENT_HUGEPAGES) *
>>>> HPAGE_PMD_NR)
>>>> #endif
>>>> +#ifdef CONFIG_CMA
>>>> + , K(totalcma_pages)
>>>> + , K(global_page_state(NR_FREE_CMA_PAGES))
>>>> +#endif
>>>> );
>>>
>>> Just for sure, are zoneinfo and pagetypeinfo not suitable?
>>>
>>
>> I think zoneinfo shows only current free cma pages.
>> Same is the case with vmstat.
>> # cat /proc/zoneinfo | grep cma
>> nr_free_cma 2560
>> # cat /proc/vmstat | grep cma
>> nr_free_cma 2560
>
> We could add a line to show total cma pages like following and add it all.
> # cat /proc/zoneinfo | grep cma
> nr_total_cma XXXX
> nr_free_cma 2560
>
> Yes. each zone can have cma area and it is annoying to add it all.
> But IMO it is rare and not difficult.
> And I think it'd better that zoneinfo has nr_total_cma line.
>
> I think you already considered my thoughts and choosed /proc/meminfo for
a
> certain reason.
> Why is /proc/meminfo better?
>
We already had a plan to include CMA info in meminfo, but first we wanted
to have totalcma_pages available.
So, we developed it as second patch, if first is accepted.
We have chosen meminfo, because, we thought it's better to capture all
information at one place.
We have a tool where we capture free/cached/swap memory info, along with
CMA info.
So, reading from single proc entry it is better.
And I am sure there will be many other user space tool like that, and it
will be easy to integrate CMA info to them.
For example; we can integrate CMA info in "free" command, if required.
Also, when we saw /proc/meminfo, we saw that other similar fields are also
present here.
Such as;
SwapTotal: 0 kB
SwapFree: 0 kB
VmallocTotal: 499712 kB
VmallocUsed: 31576 kB
> Andrew already accepted it. I'm not against your idea. Just curious.
>
>>
>>> I don't know HOTPLUG feature so I'm just asking for sure.
>>> Does HOTPLUG not need printing message like this?
>>>
>>
>> Sorry, I am also not sure what hotplug feature you are referring to.
>
> I mean "memory hotplug" feature.
> Forget it ;-)
>
>>
>>> Thanks a lot.
>>>
>>>
>>>>
>>>> hugetlb_report_meminfo(m);
>>>>
>>>
>>> --
>>> To unsubscribe, send a message with 'unsubscribe linux-mm' in
>>> the body to [email protected]. For more info on Linux MM,
>>> see: http://www.linux-mm.org/ .
>>> Don't email: <a href=mailto:"[email protected]">
>>> [email protected] </a>
>
>>>
>>
>>
>
> --
> To unsubscribe, send a message with 'unsubscribe linux-mm' in
> the body to [email protected]. For more info on Linux MM,
> see: http://www.linux-mm.org/ .
> Don't email: <a href=mailto:"[email protected]">
> [email protected] </a>
>
On Wed, Oct 22 2014, Pintu Kumar <[email protected]> wrote:
> This patch include CMA info (CMATotal, CMAFree) in /proc/meminfo.
> Currently, in a CMA enabled system, if somebody wants to know the
> total CMA size declared, there is no way to tell, other than the dmesg
> or /var/log/messages logs.
> With this patch we are showing the CMA info as part of meminfo, so that
> it can be determined at any point of time.
> This will be populated only when CMA is enabled.
>
> Below is the sample output from a ARM based device with RAM:512MB and CMA:16MB.
>
> MemTotal: 471172 kB
> MemFree: 111712 kB
> MemAvailable: 271172 kB
> .
> .
> .
> CmaTotal: 16384 kB
> CmaFree: 6144 kB
>
> This patch also fix below checkpatch errors that were found during these changes.
As already mentioned, this should be in separate patch.
>
> ERROR: space required after that ',' (ctx:ExV)
> 199: FILE: fs/proc/meminfo.c:199:
> + ,atomic_long_read(&num_poisoned_pages) << (PAGE_SHIFT - 10)
> ^
>
> ERROR: space required after that ',' (ctx:ExV)
> 202: FILE: fs/proc/meminfo.c:202:
> + ,K(global_page_state(NR_ANON_TRANSPARENT_HUGEPAGES) *
> ^
>
> ERROR: space required after that ',' (ctx:ExV)
> 206: FILE: fs/proc/meminfo.c:206:
> + ,K(totalcma_pages)
> ^
>
> total: 3 errors, 0 warnings, 2 checks, 236 lines checked
>
> Signed-off-by: Pintu Kumar <[email protected]>
> Signed-off-by: Vishnu Pratap Singh <[email protected]>
Acked-by: Michal Nazarewicz <[email protected]>
> ---
> fs/proc/meminfo.c | 15 +++++++++++++--
> 1 file changed, 13 insertions(+), 2 deletions(-)
>
> diff --git a/fs/proc/meminfo.c b/fs/proc/meminfo.c
> index aa1eee0..d3ebf2e 100644
> --- a/fs/proc/meminfo.c
> +++ b/fs/proc/meminfo.c
> @@ -12,6 +12,9 @@
> #include <linux/vmstat.h>
> #include <linux/atomic.h>
> #include <linux/vmalloc.h>
> +#ifdef CONFIG_CMA
> +#include <linux/cma.h>
> +#endif
> #include <asm/page.h>
> #include <asm/pgtable.h>
> #include "internal.h"
> @@ -138,6 +141,10 @@ static int meminfo_proc_show(struct seq_file *m, void *v)
> #ifdef CONFIG_TRANSPARENT_HUGEPAGE
> "AnonHugePages: %8lu kB\n"
> #endif
> +#ifdef CONFIG_CMA
> + "CmaTotal: %8lu kB\n"
> + "CmaFree: %8lu kB\n"
> +#endif
> ,
> K(i.totalram),
> K(i.freeram),
> @@ -187,12 +194,16 @@ static int meminfo_proc_show(struct seq_file *m, void *v)
> vmi.used >> 10,
> vmi.largest_chunk >> 10
> #ifdef CONFIG_MEMORY_FAILURE
> - ,atomic_long_read(&num_poisoned_pages) << (PAGE_SHIFT - 10)
> + , atomic_long_read(&num_poisoned_pages) << (PAGE_SHIFT - 10)
> #endif
> #ifdef CONFIG_TRANSPARENT_HUGEPAGE
> - ,K(global_page_state(NR_ANON_TRANSPARENT_HUGEPAGES) *
> + , K(global_page_state(NR_ANON_TRANSPARENT_HUGEPAGES) *
> HPAGE_PMD_NR)
> #endif
> +#ifdef CONFIG_CMA
> + , K(totalcma_pages)
> + , K(global_page_state(NR_FREE_CMA_PAGES))
> +#endif
> );
>
> hugetlb_report_meminfo(m);
> --
> 1.7.9.5
>
--
Best regards, _ _
.o. | Liege of Serenely Enlightened Majesty of o' \,=./ `o
..o | Computer Science, Michał “mina86” Nazarewicz (o o)
ooo +--<[email protected]>--<xmpp:[email protected]>--ooO--(_)--Ooo--
>> On Wed, Oct 22 2014, Pintu Kumar wrote:
>>> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
>>> index dd73f9a..ababbd8 100644
>>> --- a/mm/page_alloc.c
>>> +++ b/mm/page_alloc.c
>>> @@ -110,6 +110,7 @@ static DEFINE_SPINLOCK(managed_page_count_lock);
>>>
>>> unsigned long totalram_pages __read_mostly;
>>> unsigned long totalreserve_pages __read_mostly;
>>> +unsigned long totalcma_pages __read_mostly;
>>
>> Move this to cma.c.
On Fri, Oct 24 2014, PINTU KUMAR <[email protected]> wrote:
> In our earlier patch (first version), we added it in cmc.c itself.
> But, Andrew wanted this variable to be visible in non-CMA case as well to avoid build error, when we use
> this variable in mem_init_print_info, without CONFIG_CMA.
> So, we moved it to page_alloc.c
If you add
+#ifdef CONFIG_CMA
+extern unsigned long totalcma_pages;
+#else
+# define totalcma_pages 0UL
+#endif
to linux/cma.h the variable will get replaced with a constant zero if
!CONFIG_CMA.
--
Best regards, _ _
.o. | Liege of Serenely Enlightened Majesty of o' \,=./ `o
..o | Computer Science, Michał “mina86” Nazarewicz (o o)
ooo +--<[email protected]>--<xmpp:[email protected]>--ooO--(_)--Ooo--
On Fri, 24 Oct 2014 18:31:21 +0200 Michal Nazarewicz <[email protected]> wrote:
> On Wed, Oct 22 2014, Pintu Kumar <[email protected]> wrote:
> > This patch include CMA info (CMATotal, CMAFree) in /proc/meminfo.
> > Currently, in a CMA enabled system, if somebody wants to know the
> > total CMA size declared, there is no way to tell, other than the dmesg
> > or /var/log/messages logs.
> > With this patch we are showing the CMA info as part of meminfo, so that
> > it can be determined at any point of time.
> > This will be populated only when CMA is enabled.
> >
> > Below is the sample output from a ARM based device with RAM:512MB and CMA:16MB.
> >
> > MemTotal: 471172 kB
> > MemFree: 111712 kB
> > MemAvailable: 271172 kB
> > .
> > .
> > .
> > CmaTotal: 16384 kB
> > CmaFree: 6144 kB
> >
> > This patch also fix below checkpatch errors that were found during these changes.
>
> As already mentioned, this should be in separate patch.
Yes, in theory. But a couple of little whitespace fixes aren't really
worth a resend. As long as they don't make the patch harder to read
and to backport I usually just let them through.
On Wed, 22 Oct 2014, Pintu Kumar wrote:
> diff --git a/include/linux/cma.h b/include/linux/cma.h
> index 0430ed0..0b75896 100644
> --- a/include/linux/cma.h
> +++ b/include/linux/cma.h
> @@ -15,6 +15,7 @@
>
> struct cma;
>
> +extern unsigned long totalcma_pages;
> extern phys_addr_t cma_get_base(struct cma *cma);
> extern unsigned long cma_get_size(struct cma *cma);
>
> diff --git a/mm/cma.c b/mm/cma.c
> index 963bc4a..8435762 100644
> --- a/mm/cma.c
> +++ b/mm/cma.c
> @@ -288,6 +288,7 @@ int __init cma_declare_contiguous(phys_addr_t base,
> if (ret)
> goto err;
>
> + totalcma_pages += (size / PAGE_SIZE);
> pr_info("Reserved %ld MiB at %08lx\n", (unsigned long)size / SZ_1M,
> (unsigned long)base);
> return 0;
> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> index dd73f9a..ababbd8 100644
> --- a/mm/page_alloc.c
> +++ b/mm/page_alloc.c
> @@ -110,6 +110,7 @@ static DEFINE_SPINLOCK(managed_page_count_lock);
>
> unsigned long totalram_pages __read_mostly;
> unsigned long totalreserve_pages __read_mostly;
> +unsigned long totalcma_pages __read_mostly;
Shouldn't this be __initdata instead?
> /*
> * When calculating the number of globally allowed dirty pages, there
> * is a certain number of per-zone reserves that should not be
> @@ -5520,7 +5521,7 @@ void __init mem_init_print_info(const char *str)
>
> pr_info("Memory: %luK/%luK available "
> "(%luK kernel code, %luK rwdata, %luK rodata, "
> - "%luK init, %luK bss, %luK reserved"
> + "%luK init, %luK bss, %luK reserved, %luK cma-reserved"
> #ifdef CONFIG_HIGHMEM
> ", %luK highmem"
> #endif
> @@ -5528,7 +5529,8 @@ void __init mem_init_print_info(const char *str)
> nr_free_pages() << (PAGE_SHIFT-10), physpages << (PAGE_SHIFT-10),
> codesize >> 10, datasize >> 10, rosize >> 10,
> (init_data_size + init_code_size) >> 10, bss_size >> 10,
> - (physpages - totalram_pages) << (PAGE_SHIFT-10),
> + (physpages - totalram_pages - totalcma_pages) << (PAGE_SHIFT-10),
> + totalcma_pages << (PAGE_SHIFT-10),
> #ifdef CONFIG_HIGHMEM
> totalhigh_pages << (PAGE_SHIFT-10),
> #endif
> -----Original Message-----
> From: David Rientjes [mailto:[email protected]]
> Sent: Tuesday, November 04, 2014 5:27 AM
> To: Pintu Kumar
> Cc: [email protected]; [email protected]; [email protected];
> [email protected]; [email protected];
> [email protected]; [email protected];
> [email protected]; [email protected];
> [email protected]; [email protected]; [email protected];
> [email protected]; [email protected]; [email protected]; [email protected];
> [email protected]; [email protected]; [email protected];
> [email protected]; [email protected]; [email protected];
> [email protected]; [email protected]
> Subject: Re: [PATCH v2 1/2] mm: cma: split cma-reserved in dmesg log
>
> On Wed, 22 Oct 2014, Pintu Kumar wrote:
>
> > diff --git a/include/linux/cma.h b/include/linux/cma.h index
> > 0430ed0..0b75896 100644
> > --- a/include/linux/cma.h
> > +++ b/include/linux/cma.h
> > @@ -15,6 +15,7 @@
> >
> > struct cma;
> >
> > +extern unsigned long totalcma_pages;
> > extern phys_addr_t cma_get_base(struct cma *cma); extern unsigned
> > long cma_get_size(struct cma *cma);
> >
> > diff --git a/mm/cma.c b/mm/cma.c
> > index 963bc4a..8435762 100644
> > --- a/mm/cma.c
> > +++ b/mm/cma.c
> > @@ -288,6 +288,7 @@ int __init cma_declare_contiguous(phys_addr_t base,
> > if (ret)
> > goto err;
> >
> > + totalcma_pages += (size / PAGE_SIZE);
> > pr_info("Reserved %ld MiB at %08lx\n", (unsigned long)size / SZ_1M,
> > (unsigned long)base);
> > return 0;
> > diff --git a/mm/page_alloc.c b/mm/page_alloc.c index dd73f9a..ababbd8
> > 100644
> > --- a/mm/page_alloc.c
> > +++ b/mm/page_alloc.c
> > @@ -110,6 +110,7 @@ static DEFINE_SPINLOCK(managed_page_count_lock);
> >
> > unsigned long totalram_pages __read_mostly; unsigned long
> > totalreserve_pages __read_mostly;
> > +unsigned long totalcma_pages __read_mostly;
>
> Shouldn't this be __initdata instead?
>
No, we wanted to retain this variable for later use.
We wanted to use this to print CMA info in /proc/meminfo.
Please see the next patch for this set.
[PATCH v2 2/2] fs: proc: Include cma info in proc/meminfo
> > /*
> > * When calculating the number of globally allowed dirty pages, there
> > * is a certain number of per-zone reserves that should not be @@
> > -5520,7 +5521,7 @@ void __init mem_init_print_info(const char *str)
> >
> > pr_info("Memory: %luK/%luK available "
> > "(%luK kernel code, %luK rwdata, %luK rodata, "
> > - "%luK init, %luK bss, %luK reserved"
> > + "%luK init, %luK bss, %luK reserved, %luK cma-reserved"
> > #ifdef CONFIG_HIGHMEM
> > ", %luK highmem"
> > #endif
> > @@ -5528,7 +5529,8 @@ void __init mem_init_print_info(const char *str)
> > nr_free_pages() << (PAGE_SHIFT-10), physpages << (PAGE_SHIFT-10),
> > codesize >> 10, datasize >> 10, rosize >> 10,
> > (init_data_size + init_code_size) >> 10, bss_size >> 10,
> > - (physpages - totalram_pages) << (PAGE_SHIFT-10),
> > + (physpages - totalram_pages - totalcma_pages) << (PAGE_SHIFT-10),
> > + totalcma_pages << (PAGE_SHIFT-10),
> > #ifdef CONFIG_HIGHMEM
> > totalhigh_pages << (PAGE_SHIFT-10), #endif