All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yohei Kojima <yohei.kojima@sony.com>
To: Dave Hansen <dave.hansen@linux.intel.com>,
	Andy Lutomirski <luto@kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
	x86@kernel.org, "H. Peter Anvin" <hpa@zytor.com>
Cc: linux-kernel@vger.kernel.org, Yohei Kojima <yohei.kojima@sony.com>
Subject: Re: [PATCH] x86/mm: Fix {split,collapse}_page_count to use PTRS_PER_PMD if necessary
Date: Wed, 19 Nov 2025 19:33:57 +0900	[thread overview]
Message-ID: <aR2dFUuHXTP8P1W2@asagi> (raw)
In-Reply-To: <3d8bca84657d8b22a007a052258be1fb2a7c917d.1763531142.git.Yohei.Kojima@sony.com>

On Wed, Nov 19, 2025 at 02:46:19PM +0900, Yohei Kojima wrote:
> Before this commit, split_page_count() and collapse_page_count() updated
> direct_pages_count using PTRS_PER_PTE constant. However, these functions
> should use PTRS_PER_PMD if 1G page is splitted into 2M pages and vice
> versa because 2M direct pages are managed by PMD.
> 
> This commit fixes {split,collapse}_page_count() to use PTRS_PER_PMD in
> such cases. The basic behavior of these functions are unchanged because
> x86's 1G page split and collapse are currently only supported on 64-bit
> environment where PTRS_PER_PTE and PTRS_PER_PMD are both 512.

I'm sorry I forgot adding Signed-off-by line and I resent the patch with
Signed-off-by line. The new patch is as follows:

https://lore.kernel.org/all/1ed1400d08a3de2d14f944a36efc9b84f9ca6f42.1763546758.git.yohei.kojima@sony.com/

Thank you,
Yohei Kojima

> ---
>  arch/x86/mm/pat/set_memory.c | 20 ++++++++++++--------
>  1 file changed, 12 insertions(+), 8 deletions(-)
> 
> diff --git a/arch/x86/mm/pat/set_memory.c b/arch/x86/mm/pat/set_memory.c
> index 970981893c9b..aa6fa4894edb 100644
> --- a/arch/x86/mm/pat/set_memory.c
> +++ b/arch/x86/mm/pat/set_memory.c
> @@ -97,25 +97,29 @@ static void split_page_count(int level)
>  		return;
>  
>  	direct_pages_count[level]--;
> -	if (system_state == SYSTEM_RUNNING) {
> -		if (level == PG_LEVEL_2M)
> +	if (level == PG_LEVEL_2M) {
> +		if (system_state == SYSTEM_RUNNING)
>  			count_vm_event(DIRECT_MAP_LEVEL2_SPLIT);
> -		else if (level == PG_LEVEL_1G)
> +		direct_pages_count[PG_LEVEL_4K] += PTRS_PER_PTE;
> +	} else if (level == PG_LEVEL_1G) {
> +		if (system_state == SYSTEM_RUNNING)
>  			count_vm_event(DIRECT_MAP_LEVEL3_SPLIT);
> +		direct_pages_count[PG_LEVEL_2M] += PTRS_PER_PMD;
>  	}
> -	direct_pages_count[level - 1] += PTRS_PER_PTE;
>  }
>  
>  static void collapse_page_count(int level)
>  {
>  	direct_pages_count[level]++;
> -	if (system_state == SYSTEM_RUNNING) {
> -		if (level == PG_LEVEL_2M)
> +	if (level == PG_LEVEL_2M) {
> +		if (system_state == SYSTEM_RUNNING)
>  			count_vm_event(DIRECT_MAP_LEVEL2_COLLAPSE);
> -		else if (level == PG_LEVEL_1G)
> +		direct_pages_count[PG_LEVEL_4K] -= PTRS_PER_PTE;
> +	} else if (level == PG_LEVEL_1G) {
> +		if (system_state == SYSTEM_RUNNING)
>  			count_vm_event(DIRECT_MAP_LEVEL3_COLLAPSE);
> +		direct_pages_count[PG_LEVEL_2M] -= PTRS_PER_PMD;
>  	}
> -	direct_pages_count[level - 1] -= PTRS_PER_PTE;
>  }
>  
>  void arch_report_meminfo(struct seq_file *m)
> -- 
> 2.43.0
> 

      reply	other threads:[~2025-11-19 10:32 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-19  5:46 [PATCH] x86/mm: Fix {split,collapse}_page_count to use PTRS_PER_PMD if necessary Yohei Kojima
2025-11-19 10:33 ` Yohei Kojima [this message]

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=aR2dFUuHXTP8P1W2@asagi \
    --to=yohei.kojima@sony.com \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.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.