From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from jpms-ob01.noc.sony.co.jp (jpms-ob01.noc.sony.co.jp [211.125.140.164]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CA7A334B1A0 for ; Wed, 19 Nov 2025 10:32:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=211.125.140.164 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763548351; cv=none; b=J05eU40I0s0PWMzp0Ij/nwBceuLvWHY3Jy8KwnCeL4T7TKozm7BH9tm+K8DdR9p++ElAAbAGvKxIGKWYbKJ++lXsrNE0B9RoKe8VzmF/OjQWlvrze7viplA0FtcIYCuDiCFNAhzuDTf4n5VbiNWEHz6Im0IJXvSQ7sw3y9Q9Wtw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763548351; c=relaxed/simple; bh=YwcgvRq7sKABmFrolD4GOIcOwtUbtNeZd6OCwSXZKEA=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=QW5W703iDfSLSaad76/asqNMgWYSFp5NvRdYjyWdmHL35wTnWRV5OeebxXqhS7/u6H/UjOhg1uHvnwI493tbutuJq2ItXvhWo2r42StkyJRVow1fQJGJus3p+0gU5r4Cgpv2475DNj4Gae8R2MegX+qndrS8bLkayg/A66hzC+o= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sony.com; spf=pass smtp.mailfrom=sony.com; dkim=pass (2048-bit key) header.d=sony.com header.i=@sony.com header.b=ekuSt7wD; arc=none smtp.client-ip=211.125.140.164 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sony.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sony.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sony.com header.i=@sony.com header.b="ekuSt7wD" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sony.com; s=s1jp; t=1763548347; x=1795084347; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=uzRHkHiQ/5Ktbw+6OB5aM+ShN8QvWJL/EmF5cUXiUqg=; b=ekuSt7wDGBzxtS1Tgir0enhsLNzgdEUdZ82kazGOjAck/XVyi9izHDjd bjcLOLGSxs5dkcEJjuPHrmmDalIanABctszKNSFjRjTu4XdorGacXzo2w /gnVVOMa6jU9Paey04kpk0aD9VuoHanIqIxK0LTzdnFD0Hpk0hsII/2Tu rS8E/bFoi2AhlzAiDEoti0UpcguRcqZ6CnuBVEnXr2HlKen2zgIeVP7n0 Gg54pb5iv3uSwVLgJ1PcoEVxGwCNMDSDnvJuwLBXmjkj6X9/FFY3x32Hg fVkC6eJKjsoRP0aSm8Xa+peqZUgUfFWklo2h/gQ3LjfeMbG+jQ1hrXAIh A==; Received: from unknown (HELO jpmta-ob1.noc.sony.co.jp) ([IPv6:2001:cf8:0:6e7::6]) by jpms-ob01.noc.sony.co.jp with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Nov 2025 19:32:26 +0900 X-IronPort-AV: E=Sophos;i="6.19,227,1754924400"; d="scan'208";a="580762207" Received: from unknown (HELO asagi) ([43.11.56.84]) by jpmta-ob1.noc.sony.co.jp with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Nov 2025 19:32:27 +0900 Date: Wed, 19 Nov 2025 19:33:57 +0900 From: Yohei Kojima To: Dave Hansen , Andy Lutomirski , Peter Zijlstra , Thomas Gleixner , Ingo Molnar , Borislav Petkov , x86@kernel.org, "H. Peter Anvin" Cc: linux-kernel@vger.kernel.org, Yohei Kojima Subject: Re: [PATCH] x86/mm: Fix {split,collapse}_page_count to use PTRS_PER_PMD if necessary Message-ID: References: <3d8bca84657d8b22a007a052258be1fb2a7c917d.1763531142.git.Yohei.Kojima@sony.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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 >