From: Huacai Chen <chenhuacai@loongson.cn>
To: Arnd Bergmann <arnd@arndb.de>, Huacai Chen <chenhuacai@kernel.org>
Cc: loongarch@lists.linux.dev, linux-arch@vger.kernel.org,
Xuefeng Li <lixuefeng@loongson.cn>, Guo Ren <guoren@kernel.org>,
Xuerui Wang <kernel@xen0n.name>,
Jiaxun Yang <jiaxun.yang@flygoat.com>,
Huacai Chen <chenhuacai@loongson.cn>
Subject: [PATCH] LoongArch: Fix sleeping in atomic context in setup_tlb_handler()
Date: Thu, 23 Jun 2022 10:52:15 +0800 [thread overview]
Message-ID: <20220623025215.1824726-1-chenhuacai@loongson.cn> (raw)
Since setup_tlb_handler() is executed in atomic context, we should use
GFP_ATOMIC instead of GFP_KERNEL to alloc pages. Otherwise we will get
a "sleeping in atomic context" error:
[ 0.013118] BUG: sleeping function called from invalid context at mm/page_alloc.c:5158
[ 0.013126] in_atomic(): 1, irqs_disabled(): 1, non_block: 0, pid: 0, name: swapper/1
[ 0.013131] CPU: 1 PID: 0 Comm: swapper/1 Not tainted 5.19-rc3+ #1008 1a223086d14d07967cc427f15d52139422271360
[ 0.013136] Hardware name: Loongson Loongson-3A5000-7A1000-1w-V0.1-CRB/Loongson-LS3A5000-7A1000-1w-EVB-V1.21, BIOS Loongson-UDK2018-V2.0.04082-beta7 04/27
[ 0.013140] Stack : 90000000015fc990 9000000100493c18 9000000000df3370 9000000100490000
[ 0.013151] 9000000100493b50 0000000000000000 9000000100493b58 9000000001417ef0
[ 0.013160] 900000000199e54e 0000000000000040 9000000100493c18 90000000015f7a98
[ 0.013168] ffffffffffffffff 6de72f8b42179d1e 9000000100403b80 90000000015f7890
[ 0.013176] 0000000000000001 00000000fffff175 9000000000eb9860 9000000001530b4b
[ 0.013184] 9000000000e99e60 0000000000000013 0000000006ecc000 0000000000000001
[ 0.013193] 90000000015f7a98 9000000001417ef0 0000000000000004 0000000000000000
[ 0.013201] 0000000000000cc0 0000000000000000 0000000000000001 90000000015fc990
[ 0.013209] 9000000000217e74 9000000001603b6b 9000000000208640 0000000000000000
[ 0.013217] 00000000000000b0 0000000000000004 0000000000000000 0000000000070000
[ 0.013225] ...
[ 0.013229] Call Trace:
[ 0.013230] [<9000000000208640>] show_stack+0x4c/0x14c
[ 0.013240] [<9000000000df3370>] dump_stack_lvl+0x70/0xac
[ 0.013246] [<9000000000270c8c>] ___might_sleep+0x104/0x124
[ 0.013253] [<9000000000477e84>] __alloc_pages+0x240/0x464
[ 0.013260] [<9000000000214214>] setup_tlb_handler+0x104/0x1e8
[ 0.013265] [<9000000000214324>] tlb_init+0x2c/0x3c
[ 0.013270] [<9000000000208b74>] per_cpu_trap_init+0xec/0x108
[ 0.013275] [<9000000000202850>] cpu_probe+0x400/0x8a4
[ 0.013279] [<900000000020d160>] start_secondary+0x5c/0x3d4
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
---
arch/loongarch/mm/tlb.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/loongarch/mm/tlb.c b/arch/loongarch/mm/tlb.c
index e272f8ac57d1..6d050973241c 100644
--- a/arch/loongarch/mm/tlb.c
+++ b/arch/loongarch/mm/tlb.c
@@ -281,7 +281,7 @@ void setup_tlb_handler(int cpu)
if (pcpu_handlers[cpu])
return;
- page = alloc_pages_node(cpu_to_node(cpu), GFP_KERNEL, get_order(vec_sz));
+ page = alloc_pages_node(cpu_to_node(cpu), GFP_ATOMIC, get_order(vec_sz));
if (!page)
return;
--
2.27.0
reply other threads:[~2022-06-23 2:50 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20220623025215.1824726-1-chenhuacai@loongson.cn \
--to=chenhuacai@loongson.cn \
--cc=arnd@arndb.de \
--cc=chenhuacai@kernel.org \
--cc=guoren@kernel.org \
--cc=jiaxun.yang@flygoat.com \
--cc=kernel@xen0n.name \
--cc=linux-arch@vger.kernel.org \
--cc=lixuefeng@loongson.cn \
--cc=loongarch@lists.linux.dev \
/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).