From: Hillf Danton <hdanton@sina.com>
To: Igor Raits <igor@gooddata.com>
Cc: linux-mm@kvack.org,
syzbot <syzbot+c48f34012b06c4ac67dd@syzkaller.appspotmail.com>,
Andrew Morton <akpm@linux-foundation.org>
Subject: Re: kernel BUG at include/linux/swapops.h:204!
Date: Sat, 10 Jul 2021 20:46:30 +0800 [thread overview]
Message-ID: <20210710124630.542-1-hdanton@sina.com> (raw)
In-Reply-To: <CA+9S74hk0E=ju4jH95RBWMKFCGyfE6fb1Mgww3c4tmgzjfR8Og@mail.gmail.com>
On Sat, 10 Jul 2021 09:33:26 +0200 Igor Raits wrote:
>Hello,
>
>I've seen one weird bug on 5.12.14 that happened a couple of times when I
>started a bunch of VMs on a server.
Thanks for your report.
>
>I've briefly googled this problem but could not find any relevant commit
>that would fix this issue.
Not sure this is the first report - a similar one [0] from syzbot.
[0] https://lore.kernel.org/linux-mm/00000000000045ff9505c1cfc9ae@google.com/
>
>Do you have any hint how to debug this further or know the fix by any
>chance?
This report has more info about the BUG - in pmd_migration_entry_wait() huge
migration entry is checked under page table lock. And on the updater side,
hme should be set and removed also with ptl held, see below diff.
>
>Thanks in advance. Stack trace following:
>
>[ 376.876610] ------------[ cut here ]------------
>[ 376.881274] kernel BUG at include/linux/swapops.h:204!
>[ 376.886455] invalid opcode: 0000 [#1] SMP NOPTI
>[ 376.891014] CPU: 40 PID: 11775 Comm: rpc-worker Tainted: G E
> 5.12.14-1.gdc.el8.x86_64 #1
>[ 376.900464] Hardware name: HPE ProLiant DL380 Gen10/ProLiant DL380
>Gen10, BIOS U30 05/24/2021
>[ 376.909038] RIP: 0010:pmd_migration_entry_wait+0x132/0x140
>[ 376.914562] Code: 02 00 00 00 5b 4c 89 c7 5d e9 8a e4 f6 ff 48 81 e2 00
>f0 ff ff 48 f7 d2 48 21 c2 89 d1 f7 c2 81 01 00 00 75 80 e9 44 ff ff ff
><0f> 0b 48 8b 2d 75 bd 30 01 e9 ef fe ff ff 0f 1f 44 00 00 41 55 48
>[ 376.933443] RSP: 0000:ffffb65a5e1cfdc8 EFLAGS: 00010246
>[ 376.938701] RAX: 0017ffffc0000000 RBX: ffff908b8ecabaf8 RCX:
>ffffffffffffffff
>[ 376.945878] RDX: 0000000000000000 RSI: ffff908b8ecabaf8 RDI:
>fffff497473b2ae8
>[ 376.953055] RBP: fffff497473b2ae8 R08: fffff49747fa8080 R09:
>0000000000000000
>[ 376.960230] R10: 0000000000000000 R11: 0000000000000000 R12:
>0000000000000af8
>[ 376.967407] R13: 0400000000000000 R14: 0400000000000080 R15:
>ffff908bbef7b6a8
>[ 376.974582] FS: 00007f5bb1f81700(0000) GS:ffff90e87fd80000(0000)
>knlGS:0000000000000000
>[ 376.982718] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
>[ 376.988497] CR2: 00007f5b2bfffd98 CR3: 00000001f793e006 CR4:
>00000000007726e0
>[ 376.995673] DR0: 0000000000000000 DR1: 0000000000000000 DR2:
>0000000000000000
>[ 377.002849] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7:
>0000000000000400
>[ 377.010026] PKRU: 55555554
>[ 377.012745] Call Trace:
>[ 377.015207] __handle_mm_fault+0x5ad/0x6e0
>[ 377.019335] handle_mm_fault+0xc5/0x290
>[ 377.023194] do_user_addr_fault+0x1cd/0x740
>[ 377.027406] exc_page_fault+0x54/0x110
>[ 377.031182] ? asm_exc_page_fault+0x8/0x30
>[ 377.035307] asm_exc_page_fault+0x1e/0x30
+++ x/mm/huge_memory.c
@@ -2983,6 +2983,7 @@ void set_pmd_migration_entry(struct page
struct vm_area_struct *vma = pvmw->vma;
struct mm_struct *mm = vma->vm_mm;
unsigned long address = pvmw->address;
+ spinlock_t *ptl;
pmd_t pmdval;
swp_entry_t entry;
pmd_t pmdswp;
@@ -2998,7 +2999,9 @@ void set_pmd_migration_entry(struct page
pmdswp = swp_entry_to_pmd(entry);
if (pmd_soft_dirty(pmdval))
pmdswp = pmd_swp_mksoft_dirty(pmdswp);
+ ptl = pmd_lock(mm, pvmw->pmd);
set_pmd_at(mm, address, pvmw->pmd, pmdswp);
+ spin_unlock(ptl);
page_remove_rmap(page, true);
put_page(page);
}
@@ -3009,6 +3012,7 @@ void remove_migration_pmd(struct page_vm
struct mm_struct *mm = vma->vm_mm;
unsigned long address = pvmw->address;
unsigned long mmun_start = address & HPAGE_PMD_MASK;
+ spinlock_t *ptl;
pmd_t pmde;
swp_entry_t entry;
@@ -3028,7 +3032,9 @@ void remove_migration_pmd(struct page_vm
page_add_anon_rmap(new, vma, mmun_start, true);
else
page_add_file_rmap(new, true);
+ ptl = pmd_lock(mm, pvmw->pmd);
set_pmd_at(mm, mmun_start, pvmw->pmd, pmde);
+ spin_unlock(ptl);
if ((vma->vm_flags & VM_LOCKED) && !PageDoubleMap(new))
mlock_vma_page(new);
update_mmu_cache_pmd(vma, address, pvmw->pmd);
next prev parent reply other threads:[~2021-07-10 12:46 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-10 7:33 kernel BUG at include/linux/swapops.h:204! Igor Raits
2021-07-10 12:46 ` Hillf Danton [this message]
2021-07-11 4:17 ` Hugh Dickins
2021-07-11 6:06 ` Igor Raits
2021-07-15 17:47 ` Igor Raits
2021-07-16 19:45 ` Hugh Dickins
2021-07-19 19:11 ` Hugh Dickins
2021-07-19 22:12 ` Peter Xu
2021-07-19 22:42 ` Hugh Dickins
2021-07-20 0:34 ` Peter Xu
2021-07-20 3:31 ` Hugh Dickins
2021-07-20 7:47 ` Igor Raits
2021-07-20 16:01 ` Peter Xu
2021-07-20 16:05 ` Igor Raits
2021-07-20 15:51 ` [PATCH stable 5.13.y/5.12.y 0/2] mm/thp: Fix uffd-wp with fork(); crash on pmd migration entry on fork Peter Xu
2021-07-20 15:51 ` [PATCH stable 5.13.y/5.12.y 1/2] mm/thp: simplify copying of huge zero page pmd when fork Peter Xu
2021-07-20 15:51 ` [PATCH stable 5.13.y/5.12.y 2/2] mm/userfaultfd: fix uffd-wp special cases for fork() Peter Xu
2021-07-20 20:32 ` [PATCH stable 5.13.y/5.12.y 0/2] mm/thp: Fix uffd-wp with fork(); crash on pmd migration entry on fork Hugh Dickins
2021-07-22 14:02 ` Greg KH
2021-07-20 15:56 ` [PATCH stable 5.10.y " Peter Xu
2021-07-20 15:56 ` [PATCH stable 5.10.y 1/2] mm/thp: simplify copying of huge zero page pmd when fork Peter Xu
2021-07-20 15:56 ` [PATCH stable 5.10.y 2/2] mm/userfaultfd: fix uffd-wp special cases for fork() Peter Xu
2021-07-20 20:38 ` [PATCH stable 5.10.y 0/2] mm/thp: Fix uffd-wp with fork(); crash on pmd migration entry on fork Hugh Dickins
2021-07-22 14:05 ` Greg KH
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=20210710124630.542-1-hdanton@sina.com \
--to=hdanton@sina.com \
--cc=akpm@linux-foundation.org \
--cc=igor@gooddata.com \
--cc=linux-mm@kvack.org \
--cc=syzbot+c48f34012b06c4ac67dd@syzkaller.appspotmail.com \
/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).