From: Huang Pei <huangpei@loongson.cn>
To: Joshua Kinard <kumba@gentoo.org>
Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>,
ambrosehua@gmail.com, 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>
Subject: Re: [PATCH] MIPS: check return value of pgtable_pmd_page_ctor
Date: Wed, 21 Jul 2021 16:13:50 +0800 [thread overview]
Message-ID: <20210721081350.ygtezwksqfy6cbsq@ambrosehua-HP-xw6600-Workstation> (raw)
In-Reply-To: <d08a98c9-e696-57b0-5837-b8a640e156fa@gentoo.org>
On Wed, Jul 21, 2021 at 12:23:39AM -0400, Joshua Kinard wrote:
> On 7/20/2021 23:43, Huang Pei wrote:
> > +. 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
> >
> > Reported-by: Joshua Kinard <kumba@gentoo.org>
> > Signed-off-by: Huang Pei <huangpei@loongson.cn>
> > ---
> > arch/mips/include/asm/pgalloc.h | 12 ++++++++----
> > 1 file changed, 8 insertions(+), 4 deletions(-)
> >
> > diff --git a/arch/mips/include/asm/pgalloc.h b/arch/mips/include/asm/pgalloc.h
> > index d0cf997b4ba8..5c9597a6c60c 100644
> > --- a/arch/mips/include/asm/pgalloc.h
> > +++ b/arch/mips/include/asm/pgalloc.h
> > @@ -62,11 +62,15 @@ static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address)
> > pmd_t *pmd = NULL;
> > struct page *pg;
> >
> > - pg = alloc_pages(GFP_KERNEL | __GFP_ACCOUNT, PMD_ORDER);
> > + pg = alloc_pages(GFP_KERNEL_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);
> > + if(pgtable_pmd_page_ctor(pg)) {
> > + pmd = (pmd_t *)page_address(pg);
> > + pmd_init((unsigned long)pmd, (unsigned long)invalid_pte_table);
> > + } else {
> > + __free_pages(pg, PMD_ORDER);
> > + }
> > +
> > }
> > return pmd;
> > }
> >
> Instead of the nested if statements, why not go with something that looks more
> like what is in arch/x86/include/asm/pgalloc.h?
>
> Note, I don't have a full kernel tree in front of me at the moment, so this is
> just the refactored function of pmd_alloc_one:
>
> static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address)
> {
> pmd_t *pmd;
> struct page *page;
>
> page = alloc_pages(GFP_KERNEL_ACCOUNT, PMD_ORDER);
> if (!page)
> return NULL;
>
> if (!pgtable_pmd_page_ctor(page)) {
> __free_pages(page, PMD_ORDER);
> return NULL;
> }
>
> pmd = (pmd_t *)page_address(page);
> pmd_init((unsigned long)pmd, (unsigned long)invalid_pte_table);
>
> return pmd;
> }
>
Much more readable, V2 just resend, thank you!
PS:
Latest Gentoo/MIPS stage3 is only available for big endian, is there any
little endian stage3 available?
> --
> Joshua Kinard
> Gentoo/MIPS
> kumba@gentoo.org
> rsa6144/5C63F4E3F5C6C943 2015-04-27
> 177C 1972 1FB8 F254 BAD0 3E72 5C63 F4E3 F5C6 C943
>
> "The past tempts us, the present confuses us, the future frightens us. And
> our lives slip away, moment by moment, lost in that vast, terrible in-between."
>
> --Emperor Turhan, Centauri Republic
next prev parent reply other threads:[~2021-07-21 8:26 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-21 3:43 [PATCH] MIPS: check return value of pgtable_pmd_page_ctor Huang Pei
2021-07-21 4:23 ` Joshua Kinard
2021-07-21 8:13 ` Huang Pei [this message]
2021-07-24 23:18 ` Joshua Kinard
2021-07-21 5:20 [PATCH V2]: check return value of pgtalbe_pmd_page_ctor Huang Pei
2021-07-21 5:20 ` [PATCH] MIPS: check return value of pgtable_pmd_page_ctor Huang Pei
2021-07-21 9:03 ` Thomas Bogendoerfer
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
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=20210721081350.ygtezwksqfy6cbsq@ambrosehua-HP-xw6600-Workstation \
--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).