From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.0 required=3.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 223B7C433DF for ; Mon, 27 Jul 2020 13:00:13 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id BB4692075A for ; Mon, 27 Jul 2020 13:00:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BB4692075A Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=sina.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 366B06B0005; Mon, 27 Jul 2020 09:00:12 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 316806B0007; Mon, 27 Jul 2020 09:00:12 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1E0808D0001; Mon, 27 Jul 2020 09:00:12 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0245.hostedemail.com [216.40.44.245]) by kanga.kvack.org (Postfix) with ESMTP id 01FDE6B0005 for ; Mon, 27 Jul 2020 09:00:11 -0400 (EDT) Received: from smtpin26.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 8F1DA180ACF7F for ; Mon, 27 Jul 2020 13:00:11 +0000 (UTC) X-FDA: 77083863822.26.hall03_020120c26f61 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin26.hostedemail.com (Postfix) with ESMTP id 68F321804B661 for ; Mon, 27 Jul 2020 13:00:09 +0000 (UTC) X-HE-Tag: hall03_020120c26f61 X-Filterd-Recvd-Size: 8174 Received: from r3-25.sinamail.sina.com.cn (r3-25.sinamail.sina.com.cn [202.108.3.25]) by imf39.hostedemail.com (Postfix) with SMTP for ; Mon, 27 Jul 2020 13:00:05 +0000 (UTC) Received: from unknown (HELO localhost.localdomain)([222.131.74.184]) by sina.com with ESMTP id 5F1ECFCF0000C236; Mon, 27 Jul 2020 21:00:02 +0800 (CST) X-Sender: hdanton@sina.com X-Auth-ID: hdanton@sina.com X-SMAIL-MID: 30032754919584 From: Hillf Danton To: Matthew Wilcox Cc: "Kirill A. Shutemov" , Hillf Danton , "Kirill A. Shutemov" , Andrew Morton , syzbot , linux-kernel@vger.kernel.org, linux-mm@kvack.org, syzkaller-bugs@googlegroups.com, Mike Kravetz , Johannes Weiner , Jens Axboe , Markus Elfring Subject: Re: kernel BUG at include/linux/swapops.h:LINE! Date: Mon, 27 Jul 2020 20:59:50 +0800 Message-Id: <20200727125950.12048-1-hdanton@sina.com> In-Reply-To: <20200727120310.GJ23808@casper.infradead.org> References: <000000000000bc4fd705a6e090e2@google.com> <0000000000004c38cd05aad1d13f@google.com> <20200720165144.93189f7825bd28e234a42cb8@linux-foundation.org> <20200723073744.5268-1-hdanton@sina.com> <20200724111311.rcjqigtjqpkenxg6@box> <20200726164904.GG23808@casper.infradead.org> <20200727103140.xycdx6ctecomqsoe@box> MIME-Version: 1.0 X-Rspamd-Queue-Id: 68F321804B661 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam01 Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Mon, 27 Jul 2020 13:03:10 +0100 Matthew Wilcox wrote: > On Mon, Jul 27, 2020 at 01:31:40PM +0300, Kirill A. Shutemov wrote: > > On Sun, Jul 26, 2020 at 05:49:04PM +0100, Matthew Wilcox wrote: > > > On Fri, Jul 24, 2020 at 02:13:11PM +0300, Kirill A. Shutemov wrote: > > > > On Thu, Jul 23, 2020 at 03:37:44PM +0800, Hillf Danton wrote: > > > > >=20 > > > > > On Tue, 21 Jul 2020 14:11:31 +0300 Kirill A. Shutemov wrote: > > > > > > On Mon, Jul 20, 2020 at 04:51:44PM -0700, Andrew Morton wrote= : > > > > > > > On Sun, 19 Jul 2020 14:10:19 -0700 syzbot wrote: > > > > > > >=20 > > > > > > > > syzbot has found a reproducer for the following issue on: > > > > > > > >=20 > > > > > > > > HEAD commit: 4c43049f Add linux-next specific files fo= r 20200716 > > > > > > > > git tree: linux-next > > > > > > > > console output: https://syzkaller.appspot.com/x/log.txt?x= =3D12c56087100000 > > > > > > > > kernel config: https://syzkaller.appspot.com/x/.config?x= =3D2c76d72659687242 > > > > > > > > dashboard link: https://syzkaller.appspot.com/bug?extid=3D= c48f34012b06c4ac67dd > > > > > > > > compiler: gcc (GCC) 10.1.0-syz 20200507 > > > > > > > > syz repro: https://syzkaller.appspot.com/x/repro.syz= ?x=3D1344abeb100000 > > > > > > > >=20 > > > > > > > > IMPORTANT: if you fix the issue, please add the following= tag to the commit: > > > > > > > > Reported-by: syzbot+c48f34012b06c4ac67dd@syzkaller.appspo= tmail.com > > > > > > >=20 > > > > > > > Thanks. > > > > > > >=20 > > > > > > > __handle_mm_fault > > > > > > > ->pmd_migration_entry_wait > > > > > > > ->migration_entry_to_page > > > > > > >=20 > > > > > > > stumbled onto an unlocked page. > > > > > > >=20 > > > > > > > I don't immediately see a cause. Perhaps Matthew's "THP pr= ep patches", > > > > > > > perhaps something else. > > > > > > >=20 > > > > > > > Is it possible to perform a bisection? > > > > > >=20 > > > > > > Maybe it's related to the new lock_page_async()? > > > > >=20 > > > > > Or is there likely the window that after copy_huge_pmd() the sr= c pmd migrate > > > > > entry is removed and the page unlocked but the dst is not? > > > >=20 > > > > No. > > > >=20 > > > > copy_huge_pmd() runs with exclusive mmap_lock on the source side = and > > > > destination side is not running yet. > > >=20 > > > The one I'm hitting is huge related though. > > >=20 > > > I added this debug: > > >=20 > > > +++ b/include/linux/swapops.h > > > @@ -165,8 +165,9 @@ static inline struct page *device_private_entry= _to_page(swp_entry_t entry) > > > #ifdef CONFIG_MIGRATION > > > static inline swp_entry_t make_migration_entry(struct page *page, = int write) > > > { > > > - BUG_ON(!PageLocked(compound_head(page))); > > > + VM_BUG_ON_PAGE(!PageLocked(page), page); > > > =20 > > > +if (PageCompound(page)) printk("pfn %lx order %d\n", page_to_pfn(p= age), thp_order(thp_head(page))); > > > return swp_entry(write ? SWP_MIGRATION_WRITE : SWP_MIGRATIO= N_READ, > > > page_to_pfn(page)); > > > } > > > @@ -194,7 +195,11 @@ static inline struct page *migration_entry_to_= page(swp_entry_t entry) > > > * Any use of migration entries may only occur while the > > > * corresponding page is locked > > > */ > > > - BUG_ON(!PageLocked(compound_head(p))); > > > + if (!PageLocked(p)) { > > > + dump_page(p, "not locked"); > > > + printk("swap entry %d.%lx\n", swp_type(entry), swp_= offset(entry)); > > > + BUG(); > > > + } > > > return p; > > > } > > > =20 > > >=20 > > > and got useful output (while running generic/086): > > >=20 > > > 1457 086 (20181): drop_caches: 3 > > > 1457 page:00000000a216ae9a refcount:2 mapcount:0 mapping:000000009b= a7bfed index:0x2227 pfn:0x229e7 > > > 1457 aops:def_blk_aops ino:0 > > > 1457 flags: 0x4000000000002030(lru|active|private) > > > 1457 raw: 4000000000002030 fffff5b4416b5a48 fffff5b4408a7988 ffff9e= 9c34848578 > > > 1457 raw: 0000000000002227 ffff9e9bd18f0d00 00000002ffffffff 000000= 0000000000 > > > 1457 page dumped because: not locked > > > 1457 swap entry 30.229e7 > > > 1457 ------------[ cut here ]------------ > > > 1457 kernel BUG at include/linux/swapops.h:201! > > > 1457 invalid opcode: 0000 [#1] SMP PTI > > > 1457 CPU: 3 PID: 646 Comm: check Kdump: loaded Tainted: G W = 5.8.0-rc6-00067-gd8b18bdf9870-dirty #355 > > > 1457 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.= 13.0-1 04/01/2014 > > > 1457 RIP: 0010:__migration_entry_wait+0x109/0x110 > > > [...] > > >=20 > > > Looking back in the trace, I see: > > >=20 > > > ... > > > 1457 pfn 229e5 order 9 > > > 1457 pfn 229e6 order 9 > > > 1457 pfn 229e7 order 9 > > > 1457 pfn 229e8 order 9 > > > 1457 pfn 229e9 order 9 > > > ... > > >=20 > > > so I would say we have a refcount problem. I've probably made it w= orse by > > > creating more THPs, but I don't think I'm the originator of the pro= blem. > > >=20 > > > I know very little about the migration code today. I suspect I'm g= oing > > > to have to learn about it next week. > >=20 > > It would be interesting to know if the migration entires ever got rem= oved > > for pfn. I mean if remove_migration_pte() got called for it. > >=20 > > It can be rmap issue too. Maybe it misses PMD on remove_migration_pte= s() > > or something. >=20 > It's not mapped with a PMD. I tweaked my debugging slightly: >=20 > static inline swp_entry_t make_migration_entry(struct page *page, int = write) > { > - BUG_ON(!PageLocked(compound_head(page))); > + VM_BUG_ON_PAGE(!PageLocked(page), page); > =20 > +if (PageHead(page)) dump_page(page, "make entry"); > +if (PageTail(page)) printk("pfn %lx order %d\n", page_to_pfn(page), th= p_order(thp_head(page))); >=20 > 1523 page:0000000006f62206 refcount:490 mapcount:1 mapping:000000000000= 0000 index:0x562b12a00 pfn:0x1dc00 > 1523 head:0000000006f62206 order:9 compound_mapcount:0 compound_pincoun= t:0 > 1523 anon flags: 0x400000000009003d(locked|uptodate|dirty|lru|active|he= ad|swapbacked) > > > 1457 flags: 0x4000000000002030(lru|active|private) Can you elaborate on the difference between the two dumps? > 1523 raw: 400000000009003d ffffecfd41301308 ffffecfd41b08008 ffff9e9971= c00059 > 1523 raw: 0000000562b12a00 0000000000000000 000001ea00000000 0000000000= 000000 > 1523 page dumped because: make entry > 1523 pfn 1dc01 order 9 > 1523 pfn 1dc02 order 9 > 1523 pfn 1dc03 order 9 > ... >=20 > Notice that it's an anonymous page, so it's not related to my work.