From: Huang Pei <huangpei@loongson.cn>
To: Thomas Bogendoerfer <tsbogend@alpha.franken.de>, ambrosehua@gmail.com
Cc: Bibo Mao <maobibo@loongson.cn>,
linux-mips@vger.kernel.org, Jiaxun Yang <jiaxun.yang@flygoat.com>,
Paul Burton <paulburton@kernel.org>,
Li Xuefeng <lixuefeng@loongson.cn>,
Yang Tiezhu <yangtiezhu@loongson.cn>,
Gao Juxin <gaojuxin@loongson.cn>,
Huacai Chen <chenhuacai@loongson.cn>,
Jinyang He <hejinyang@loongson.cn>,
Joshua Kinard <kumba@gentoo.org>
Subject: [PATCH] MIPS: check return value of pgtable_pmd_page_ctor
Date: Wed, 21 Jul 2021 13:20:23 +0800 [thread overview]
Message-ID: <20210721052023.2111877-2-huangpei@loongson.cn> (raw)
In-Reply-To: <20210721052023.2111877-1-huangpei@loongson.cn>
+. According to Documentation/vm/split_page_table_lock, handle failure
of pgtable_pmd_page_ctor
+. Use GFP_KERNEL_ACCOUNT instead of GFP_KERNEL|__GFP_ACCOUNT
+. Adjust coding style
Reported-by: Joshua Kinard <kumba@gentoo.org>
Signed-off-by: Huang Pei <huangpei@loongson.cn>
---
arch/mips/include/asm/pgalloc.h | 17 +++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)
diff --git a/arch/mips/include/asm/pgalloc.h b/arch/mips/include/asm/pgalloc.h
index d0cf997b4ba8..139b4050259f 100644
--- a/arch/mips/include/asm/pgalloc.h
+++ b/arch/mips/include/asm/pgalloc.h
@@ -59,15 +59,20 @@ do { \
static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address)
{
- pmd_t *pmd = NULL;
+ pmd_t *pmd;
struct page *pg;
- 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);
+ pg = alloc_pages(GFP_KERNEL_ACCOUNT, PMD_ORDER);
+ if (!pg)
+ return NULL;
+
+ if (!pgtable_pmd_page_ctor(pg)) {
+ __free_pages(pg, PMD_ORDER);
+ return NULL;
}
+
+ pmd = (pmd_t *)page_address(pg);
+ pmd_init((unsigned long)pmd, (unsigned long)invalid_pte_table);
return pmd;
}
--
2.25.1
next prev parent reply other threads:[~2021-07-21 5:20 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-21 5:20 [PATCH V2]: check return value of pgtalbe_pmd_page_ctor Huang Pei
2021-07-21 5:20 ` Huang Pei [this message]
2021-07-21 9:03 ` [PATCH] MIPS: check return value of pgtable_pmd_page_ctor Thomas Bogendoerfer
-- strict thread matches above, loose matches on Subject: below --
2021-07-21 9:30 [PATCH V3]: " Huang Pei
2021-07-21 9:30 ` [PATCH] " Huang Pei
2021-07-24 23:05 ` Joshua Kinard
2021-08-05 9:46 ` Thomas Bogendoerfer
2021-07-21 3:43 Huang Pei
2021-07-21 4:23 ` Joshua Kinard
2021-07-21 8:13 ` Huang Pei
2021-07-24 23:18 ` Joshua Kinard
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=20210721052023.2111877-2-huangpei@loongson.cn \
--to=huangpei@loongson.cn \
--cc=ambrosehua@gmail.com \
--cc=chenhuacai@loongson.cn \
--cc=gaojuxin@loongson.cn \
--cc=hejinyang@loongson.cn \
--cc=jiaxun.yang@flygoat.com \
--cc=kumba@gentoo.org \
--cc=linux-mips@vger.kernel.org \
--cc=lixuefeng@loongson.cn \
--cc=maobibo@loongson.cn \
--cc=paulburton@kernel.org \
--cc=tsbogend@alpha.franken.de \
--cc=yangtiezhu@loongson.cn \
/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).