From: zhongjiang@huawei.com (zhong jiang)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] arm64: calculate the various pages number to show
Date: Thu, 26 Nov 2015 23:05:32 +0800 [thread overview]
Message-ID: <56571FBC.2020300@huawei.com> (raw)
In-Reply-To: <20151125150448.GD12434@leverpostej>
On 2015/11/25 23:04, Mark Rutland wrote:
> On Wed, Nov 25, 2015 at 09:41:12PM +0800, zhongjiang wrote:
>> This patch add the interface to show the number of 4KB or 64KB page,
>> aims to statistics the number of different types of pages.
>
> What is this useful for? Why do we want it?
>
> What does it account for, just the swapper?
>
The patch is wirtten when I was in backport set_memory_ro. It can be used to
detect whether there is a large page spliting and merging. large page will
significantly reduce the TLB miss, and improve the system performance.
>> Signed-off-by: zhongjiang <zhongjiang@huawei.com>
>> ---
>> arch/arm64/include/asm/pgtable-types.h | 24 ++++++++++++++++++++++++
>> arch/arm64/mm/mmu.c | 28 ++++++++++++++++++++++++++++
>> arch/arm64/mm/pageattr.c | 31 +++++++++++++++++++++++++++++++
>> 3 files changed, 83 insertions(+), 0 deletions(-)
>>
>> diff --git a/arch/arm64/include/asm/pgtable-types.h b/arch/arm64/include/asm/pgtable-types.h
>> index 2b1bd7e..aa52546 100644
>> --- a/arch/arm64/include/asm/pgtable-types.h
>> +++ b/arch/arm64/include/asm/pgtable-types.h
>> @@ -86,6 +86,30 @@ typedef pteval_t pgprot_t;
>>
>> #endif /* STRICT_MM_TYPECHECKS */
>>
>> +struct seq_file;
>> +extern void arch_report_meminfo(struct seq_file *m);
>> +
>> +enum pg_level {
>> + PG_LEVEL_NONE,
>> +#ifdef CONFIG_ARM64_4K_PAGES
>> + PG_LEVEL_4K,
>> + PG_LEVEL_2M,
>> + PG_LEVEL_1G,
>> +#else
>> + PG_LEVEL_64K,
>> + PG_LEVEL_512M,
>> +#endif
>> + PG_LEVEL_NUM
>> +};
>
> This doesn't account for 16K pages, and it means each call site has to
> handle the various page sizes directly.
>
> It would be better to simply count PTE/PMD/PUD/PGD, then handle the size
> conversion at the end when logging.
>
yes, now I only consider the 4kb and 64kb. if the patch is approved ,I will
improve it.
each call site need two different varialbes to statistics, aiming to distinguish
diffent pages. I think it will no more simple.
>> @@ -85,6 +86,11 @@ void split_pmd(pmd_t *pmd, pte_t *pte)
>> set_pte(pte, pfn_pte(pfn, prot));
>> pfn++;
>> } while (pte++, i++, i < PTRS_PER_PTE);
>> +#ifdef CONFIG_ARM64_4K_PAGES
>> + split_page_count(PG_LEVEL_2M);
>> +#else
>> + split_page_count(PG_LEVEL_512M);
>> +#endif
>> }
>
> e.g. here you'd just count PG_LEVEL_PMD, which would work regardless of
> page size.
>
>> diff --git a/arch/arm64/mm/pageattr.c b/arch/arm64/mm/pageattr.c
>> index 7a5ff11..c1888b9 100644
>> --- a/arch/arm64/mm/pageattr.c
>> +++ b/arch/arm64/mm/pageattr.c
>> @@ -15,12 +15,43 @@
>> #include <linux/module.h>
>> #include <linux/sched.h>
>>
>> +#include <linux/seq_file.h>
>> #include <asm/pgalloc.h>
>> #include <asm/pgtable.h>
>> #include <asm/tlbflush.h>
>>
>> #include "mm.h"
>>
>> +static unsigned long direct_pages_count[PG_LEVEL_NUM];
>
> This doesn't match reality by the time we start executing the kernel,
> given we created page tables in head.S.
>
>> +
>> +void update_page_count(int level, unsigned long pages)
>> +{
>> + direct_pages_count[level] += pages;
>> +}
>> +
>> +void split_page_count(int level)
>> +{
>> + direct_pages_count[level]--;
>> + direct_pages_count[level-1] += PTRS_PER_PTE;
>> +}
>> +
>> +void arch_report_meminfo(struct seq_file *m)
>> +{
>> +#ifdef CONFIG_ARM64_4K_PAGES
>> + seq_printf(m, "DirectMap4k: %8lu kB\n",
>> + direct_pages_count[PG_LEVEL_4K] << 2);
>> + seq_printf(m, "DirectMap2M: %8lu kB\n",
>> + direct_pages_count[PG_LEVEL_2M] << 11);
>> + seq_printf(m, "DirectMap1G: %8lu kB\n",
>> + direct_pages_count[PG_LEVEL_1G] << 20);
>> +#else
>> + seq_printf(m, "DirectMap64k: %8lu kB\n",
>> + direct_pages_count[PG_LEVEL_64K] << 6);
>> + seq_printf(m, "DirectMap512M: %8lu kB\n",
>> + direct_pages_count[PG_LEVEL_512M] << 19);
>> +#endif
>> +}
>
> You could dynamuically determine the sizes here for each field, and not
> have to have #ifdefs.>
I don't understand what you mean. I think it can be more readable and operability.
Thanks
zhongjiang
> That all said, I don't see what this is useful for, and it looks very
> fragile.
>
> Thanks,
> Mark.
>
> .
>
WARNING: multiple messages have this Message-ID (diff)
From: zhong jiang <zhongjiang@huawei.com>
To: Mark Rutland <mark.rutland@arm.com>
Cc: <catalin.marinas@arm.com>, <will.deacon@arm.com>,
<lauraa@codeaurora.org>, <qiuxishi@huawei.com>,
<linux-arm-kernel@lists.infradead.org>,
<linux-kernel@vger.kernel.org>, <guohanjun@huawei.com>
Subject: Re: [PATCH] arm64: calculate the various pages number to show
Date: Thu, 26 Nov 2015 23:05:32 +0800 [thread overview]
Message-ID: <56571FBC.2020300@huawei.com> (raw)
In-Reply-To: <20151125150448.GD12434@leverpostej>
On 2015/11/25 23:04, Mark Rutland wrote:
> On Wed, Nov 25, 2015 at 09:41:12PM +0800, zhongjiang wrote:
>> This patch add the interface to show the number of 4KB or 64KB page,
>> aims to statistics the number of different types of pages.
>
> What is this useful for? Why do we want it?
>
> What does it account for, just the swapper?
>
The patch is wirtten when I was in backport set_memory_ro. It can be used to
detect whether there is a large page spliting and merging. large page will
significantly reduce the TLB miss, and improve the system performance.
>> Signed-off-by: zhongjiang <zhongjiang@huawei.com>
>> ---
>> arch/arm64/include/asm/pgtable-types.h | 24 ++++++++++++++++++++++++
>> arch/arm64/mm/mmu.c | 28 ++++++++++++++++++++++++++++
>> arch/arm64/mm/pageattr.c | 31 +++++++++++++++++++++++++++++++
>> 3 files changed, 83 insertions(+), 0 deletions(-)
>>
>> diff --git a/arch/arm64/include/asm/pgtable-types.h b/arch/arm64/include/asm/pgtable-types.h
>> index 2b1bd7e..aa52546 100644
>> --- a/arch/arm64/include/asm/pgtable-types.h
>> +++ b/arch/arm64/include/asm/pgtable-types.h
>> @@ -86,6 +86,30 @@ typedef pteval_t pgprot_t;
>>
>> #endif /* STRICT_MM_TYPECHECKS */
>>
>> +struct seq_file;
>> +extern void arch_report_meminfo(struct seq_file *m);
>> +
>> +enum pg_level {
>> + PG_LEVEL_NONE,
>> +#ifdef CONFIG_ARM64_4K_PAGES
>> + PG_LEVEL_4K,
>> + PG_LEVEL_2M,
>> + PG_LEVEL_1G,
>> +#else
>> + PG_LEVEL_64K,
>> + PG_LEVEL_512M,
>> +#endif
>> + PG_LEVEL_NUM
>> +};
>
> This doesn't account for 16K pages, and it means each call site has to
> handle the various page sizes directly.
>
> It would be better to simply count PTE/PMD/PUD/PGD, then handle the size
> conversion at the end when logging.
>
yes, now I only consider the 4kb and 64kb. if the patch is approved ,I will
improve it.
each call site need two different varialbes to statistics, aiming to distinguish
diffent pages. I think it will no more simple.
>> @@ -85,6 +86,11 @@ void split_pmd(pmd_t *pmd, pte_t *pte)
>> set_pte(pte, pfn_pte(pfn, prot));
>> pfn++;
>> } while (pte++, i++, i < PTRS_PER_PTE);
>> +#ifdef CONFIG_ARM64_4K_PAGES
>> + split_page_count(PG_LEVEL_2M);
>> +#else
>> + split_page_count(PG_LEVEL_512M);
>> +#endif
>> }
>
> e.g. here you'd just count PG_LEVEL_PMD, which would work regardless of
> page size.
>
>> diff --git a/arch/arm64/mm/pageattr.c b/arch/arm64/mm/pageattr.c
>> index 7a5ff11..c1888b9 100644
>> --- a/arch/arm64/mm/pageattr.c
>> +++ b/arch/arm64/mm/pageattr.c
>> @@ -15,12 +15,43 @@
>> #include <linux/module.h>
>> #include <linux/sched.h>
>>
>> +#include <linux/seq_file.h>
>> #include <asm/pgalloc.h>
>> #include <asm/pgtable.h>
>> #include <asm/tlbflush.h>
>>
>> #include "mm.h"
>>
>> +static unsigned long direct_pages_count[PG_LEVEL_NUM];
>
> This doesn't match reality by the time we start executing the kernel,
> given we created page tables in head.S.
>
>> +
>> +void update_page_count(int level, unsigned long pages)
>> +{
>> + direct_pages_count[level] += pages;
>> +}
>> +
>> +void split_page_count(int level)
>> +{
>> + direct_pages_count[level]--;
>> + direct_pages_count[level-1] += PTRS_PER_PTE;
>> +}
>> +
>> +void arch_report_meminfo(struct seq_file *m)
>> +{
>> +#ifdef CONFIG_ARM64_4K_PAGES
>> + seq_printf(m, "DirectMap4k: %8lu kB\n",
>> + direct_pages_count[PG_LEVEL_4K] << 2);
>> + seq_printf(m, "DirectMap2M: %8lu kB\n",
>> + direct_pages_count[PG_LEVEL_2M] << 11);
>> + seq_printf(m, "DirectMap1G: %8lu kB\n",
>> + direct_pages_count[PG_LEVEL_1G] << 20);
>> +#else
>> + seq_printf(m, "DirectMap64k: %8lu kB\n",
>> + direct_pages_count[PG_LEVEL_64K] << 6);
>> + seq_printf(m, "DirectMap512M: %8lu kB\n",
>> + direct_pages_count[PG_LEVEL_512M] << 19);
>> +#endif
>> +}
>
> You could dynamuically determine the sizes here for each field, and not
> have to have #ifdefs.>
I don't understand what you mean. I think it can be more readable and operability.
Thanks
zhongjiang
> That all said, I don't see what this is useful for, and it looks very
> fragile.
>
> Thanks,
> Mark.
>
> .
>
next prev parent reply other threads:[~2015-11-26 15:05 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-25 13:41 [PATCH] arm64: calculate the various pages number to show zhongjiang
2015-11-25 13:41 ` zhongjiang
2015-11-25 15:04 ` Mark Rutland
2015-11-25 15:04 ` Mark Rutland
2015-11-26 15:05 ` zhong jiang [this message]
2015-11-26 15:05 ` zhong jiang
2015-11-26 15:49 ` Mark Rutland
2015-11-26 15:49 ` Mark Rutland
2015-11-27 1:52 ` Xishi Qiu
2015-11-27 1:52 ` Xishi Qiu
2015-12-03 18:22 ` Mark Rutland
2015-12-03 18:22 ` Mark Rutland
2015-11-27 8:40 ` zhong jiang
2015-11-27 8:40 ` zhong jiang
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=56571FBC.2020300@huawei.com \
--to=zhongjiang@huawei.com \
--cc=linux-arm-kernel@lists.infradead.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.