]>
Commit | Line | Data |
---|---|---|
f5edbeaf GKH |
1 | From 2bf753e64b4a702e27ce26ff520c59563c62f96b Mon Sep 17 00:00:00 2001 |
2 | From: Kai Shen <shenkai8@huawei.com> | |
3 | Date: Mon, 13 May 2019 17:15:37 -0700 | |
4 | Subject: mm/hugetlb.c: don't put_page in lock of hugetlb_lock | |
5 | ||
6 | From: Kai Shen <shenkai8@huawei.com> | |
7 | ||
8 | commit 2bf753e64b4a702e27ce26ff520c59563c62f96b upstream. | |
9 | ||
10 | spinlock recursion happened when do LTP test: | |
11 | #!/bin/bash | |
12 | ./runltp -p -f hugetlb & | |
13 | ./runltp -p -f hugetlb & | |
14 | ./runltp -p -f hugetlb & | |
15 | ./runltp -p -f hugetlb & | |
16 | ./runltp -p -f hugetlb & | |
17 | ||
18 | The dtor returned by get_compound_page_dtor in __put_compound_page may be | |
19 | the function of free_huge_page which will lock the hugetlb_lock, so don't | |
20 | put_page in lock of hugetlb_lock. | |
21 | ||
22 | BUG: spinlock recursion on CPU#0, hugemmap05/1079 | |
23 | lock: hugetlb_lock+0x0/0x18, .magic: dead4ead, .owner: hugemmap05/1079, .owner_cpu: 0 | |
24 | Call trace: | |
25 | dump_backtrace+0x0/0x198 | |
26 | show_stack+0x24/0x30 | |
27 | dump_stack+0xa4/0xcc | |
28 | spin_dump+0x84/0xa8 | |
29 | do_raw_spin_lock+0xd0/0x108 | |
30 | _raw_spin_lock+0x20/0x30 | |
31 | free_huge_page+0x9c/0x260 | |
32 | __put_compound_page+0x44/0x50 | |
33 | __put_page+0x2c/0x60 | |
34 | alloc_surplus_huge_page.constprop.19+0xf0/0x140 | |
35 | hugetlb_acct_memory+0x104/0x378 | |
36 | hugetlb_reserve_pages+0xe0/0x250 | |
37 | hugetlbfs_file_mmap+0xc0/0x140 | |
38 | mmap_region+0x3e8/0x5b0 | |
39 | do_mmap+0x280/0x460 | |
40 | vm_mmap_pgoff+0xf4/0x128 | |
41 | ksys_mmap_pgoff+0xb4/0x258 | |
42 | __arm64_sys_mmap+0x34/0x48 | |
43 | el0_svc_common+0x78/0x130 | |
44 | el0_svc_handler+0x38/0x78 | |
45 | el0_svc+0x8/0xc | |
46 | ||
47 | Link: http://lkml.kernel.org/r/b8ade452-2d6b-0372-32c2-703644032b47@huawei.com | |
48 | Fixes: 9980d744a0 ("mm, hugetlb: get rid of surplus page accounting tricks") | |
49 | Signed-off-by: Kai Shen <shenkai8@huawei.com> | |
50 | Signed-off-by: Feilong Lin <linfeilong@huawei.com> | |
51 | Reported-by: Wang Wang <wangwang2@huawei.com> | |
52 | Reviewed-by: Oscar Salvador <osalvador@suse.de> | |
53 | Reviewed-by: Mike Kravetz <mike.kravetz@oracle.com> | |
54 | Reviewed-by: Andrew Morton <akpm@linux-foundation.org> | |
55 | Acked-by: Michal Hocko <mhocko@suse.com> | |
56 | Cc: <stable@vger.kernel.org> | |
57 | Signed-off-by: Andrew Morton <akpm@linux-foundation.org> | |
58 | Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> | |
59 | Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> | |
60 | ||
61 | --- | |
62 | mm/hugetlb.c | 3 ++- | |
63 | 1 file changed, 2 insertions(+), 1 deletion(-) | |
64 | ||
65 | --- a/mm/hugetlb.c | |
66 | +++ b/mm/hugetlb.c | |
67 | @@ -1574,8 +1574,9 @@ static struct page *alloc_surplus_huge_p | |
68 | */ | |
69 | if (h->surplus_huge_pages >= h->nr_overcommit_huge_pages) { | |
70 | SetPageHugeTemporary(page); | |
71 | + spin_unlock(&hugetlb_lock); | |
72 | put_page(page); | |
73 | - page = NULL; | |
74 | + return NULL; | |
75 | } else { | |
76 | h->surplus_huge_pages++; | |
77 | h->surplus_huge_pages_node[page_to_nid(page)]++; |