linux-mips.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Huang Pei <huangpei@loongson.cn>,
	Thomas Bogendoerfer <tsbogend@alpha.franken.de>,
	Sasha Levin <sashal@kernel.org>,
	linux-mips@vger.kernel.org
Subject: [PATCH AUTOSEL 5.13 139/189] MIPS: add PMD table accounting into MIPS'pmd_alloc_one
Date: Tue,  6 Jul 2021 07:13:19 -0400	[thread overview]
Message-ID: <20210706111409.2058071-139-sashal@kernel.org> (raw)
In-Reply-To: <20210706111409.2058071-1-sashal@kernel.org>

From: Huang Pei <huangpei@loongson.cn>

[ Upstream commit ed914d48b6a1040d1039d371b56273d422c0081e ]

This fixes Page Table accounting bug.

MIPS is the ONLY arch just defining __HAVE_ARCH_PMD_ALLOC_ONE alone.
Since commit b2b29d6d011944 (mm: account PMD tables like PTE tables),
"pmd_free" in asm-generic with PMD table accounting and "pmd_alloc_one"
in MIPS without PMD table accounting causes PageTable accounting number
negative, which read by global_zone_page_state(), always returns 0.

Signed-off-by: Huang Pei <huangpei@loongson.cn>
Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 arch/mips/include/asm/pgalloc.h | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/arch/mips/include/asm/pgalloc.h b/arch/mips/include/asm/pgalloc.h
index 8b18424b3120..d0cf997b4ba8 100644
--- a/arch/mips/include/asm/pgalloc.h
+++ b/arch/mips/include/asm/pgalloc.h
@@ -59,11 +59,15 @@ do {							\
 
 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address)
 {
-	pmd_t *pmd;
+	pmd_t *pmd = NULL;
+	struct page *pg;
 
-	pmd = (pmd_t *) __get_free_pages(GFP_KERNEL, PMD_ORDER);
-	if (pmd)
+	pg = alloc_pages(GFP_KERNEL | __GFP_ACCOUNT, PMD_ORDER);
+	if (pg) {
+		pgtable_pmd_page_ctor(pg);
+		pmd = (pmd_t *)page_address(pg);
 		pmd_init((unsigned long)pmd, (unsigned long)invalid_pte_table);
+	}
 	return pmd;
 }
 
-- 
2.30.2


  parent reply	other threads:[~2021-07-06 11:18 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20210706111409.2058071-1-sashal@kernel.org>
2021-07-06 11:11 ` [PATCH AUTOSEL 5.13 019/189] MIPS: Loongson64: Fix build error 'secondary_kexec_args' undeclared under !SMP Sasha Levin
2021-07-06 11:11 ` [PATCH AUTOSEL 5.13 020/189] hugetlb: clear huge pte during flush function on mips platform Sasha Levin
2021-07-06 11:12 ` [PATCH AUTOSEL 5.13 064/189] MIPS: cpu-probe: Fix FPU detection on Ingenic JZ4760(B) Sasha Levin
2021-07-06 11:12 ` [PATCH AUTOSEL 5.13 065/189] MIPS: ingenic: Select CPU_SUPPORTS_CPUFREQ && MIPS_EXTERNAL_TIMER Sasha Levin
2021-07-06 11:12 ` [PATCH AUTOSEL 5.13 097/189] net: sgi: ioc3-eth: check return value after calling platform_get_resource() Sasha Levin
2021-07-06 11:13 ` Sasha Levin [this message]
2021-07-06 11:13 ` [PATCH AUTOSEL 5.13 167/189] net: retrieve netns cookie via getsocketopt Sasha Levin
2021-07-06 11:14 ` [PATCH AUTOSEL 5.13 187/189] MIPS: loongsoon64: Reserve memory below starting pfn to prevent Oops Sasha Levin
2021-07-06 11:14 ` [PATCH AUTOSEL 5.13 188/189] MIPS: set mips32r5 for virt extensions Sasha Levin
2021-07-06 11:14 ` [PATCH AUTOSEL 5.13 189/189] MIPS: CI20: Reduce clocksource to 750 kHz Sasha Levin

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=20210706111409.2058071-139-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=huangpei@loongson.cn \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=tsbogend@alpha.franken.de \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).