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,DKIM_SIGNED, DKIM_VALID,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 BC0E9C433E0 for ; Mon, 27 Jul 2020 10:31:42 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 7C5AB20786 for ; Mon, 27 Jul 2020 10:31:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=shutemov-name.20150623.gappssmtp.com header.i=@shutemov-name.20150623.gappssmtp.com header.b="iwguWkkz" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7C5AB20786 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=shutemov.name Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id DB15F6B0002; Mon, 27 Jul 2020 06:31:41 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D60B36B0003; Mon, 27 Jul 2020 06:31:41 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C4F616B0005; Mon, 27 Jul 2020 06:31:41 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0229.hostedemail.com [216.40.44.229]) by kanga.kvack.org (Postfix) with ESMTP id AFD756B0002 for ; Mon, 27 Jul 2020 06:31:41 -0400 (EDT) Received: from smtpin11.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 316CE1EE6 for ; Mon, 27 Jul 2020 10:31:41 +0000 (UTC) X-FDA: 77083489602.11.owner02_1a0962226f60 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin11.hostedemail.com (Postfix) with ESMTP id AEB0A180F8B8C for ; Mon, 27 Jul 2020 10:31:40 +0000 (UTC) X-HE-Tag: owner02_1a0962226f60 X-Filterd-Recvd-Size: 8431 Received: from mail-lj1-f194.google.com (mail-lj1-f194.google.com [209.85.208.194]) by imf08.hostedemail.com (Postfix) with ESMTP for ; Mon, 27 Jul 2020 10:31:39 +0000 (UTC) Received: by mail-lj1-f194.google.com with SMTP id d17so16636289ljl.3 for ; Mon, 27 Jul 2020 03:31:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shutemov-name.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=i3XwR98HxDmxV1ax4v8jtaggfWv+sYL3uUK+dd0akmY=; b=iwguWkkz533L7LLgAfcn4S0q7w5+uQy4yBNRRiZmqHmr32Saxi4jkbpRXWOGmYcFh9 wYt/8XroNWsei+k2Lulvjr3b29rc4c1hCmMIO6c1lh/ETxygvSdcv1XgvUcRvdHJF2L7 hnjR40WWJhG/PTFhxsgv7Er8+AC3mAoRiEtdsUBHZd2IBpK4bQXfpk5cH63HFMF61hQc apJWzSUgCMni5ogSzUMpttLSw8a89UIGWf5ttOdxT/+KqyphKKLCWwY6V7VrS1ijotai GLyDHB6bPtzaTZqTraYp7a/TS9dowzYOEVzuzWFo8KjTaRZRjVCeOJTkOs6b9UqBXScv ytrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=i3XwR98HxDmxV1ax4v8jtaggfWv+sYL3uUK+dd0akmY=; b=BgYZxARcW3uM1Gwh0dLEXczMjhGJP0dS21qKlVaTXe5NKkK40Y+urlZx/bfDFlx8VV Del9HtHOStR32Sj8bQgHv4oYFzYTgm4ZzUsDkO90MT20aLXo69M3cg4OsZ9y/zfbqCdV QYvD8rOYfiMgCQIBZ80BkDkwUqmFTKp7y6m5x8HD2bgLfbqU916XqTIch8cHbWF0SPXy M7KY7e/3NpSGTWbR2kUEKpgmm0aFXJ9qgpCQh5ePDrML8y1ZbqUSwznpwJSMRMIcAz1E Xd+KbTNhtQnwz9oC6+KLKCeZgpmKdrrsUyhZ33p1DEN0/Q5wR/GlwHPHH1CwqyLWLxaT CLBA== X-Gm-Message-State: AOAM530vspl1bdW4yeWoq5BfzgyQDhdSxjQ/efJuOnDioqkTFqmJffeK n9w+JbSvd9/nhf5JuFcaJn7AoA== X-Google-Smtp-Source: ABdhPJxAS93HRzUuftjwn7h5yhLOuVfWE5SlYaIHq2tQF/YYYmWM/rxNmsXtpjuWJK2FUaOVMTiT4g== X-Received: by 2002:a2e:8995:: with SMTP id c21mr1405063lji.52.1595845898317; Mon, 27 Jul 2020 03:31:38 -0700 (PDT) Received: from box.localdomain ([86.57.175.117]) by smtp.gmail.com with ESMTPSA id b2sm2607553lji.63.2020.07.27.03.31.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Jul 2020 03:31:37 -0700 (PDT) Received: by box.localdomain (Postfix, from userid 1000) id AC621102081; Mon, 27 Jul 2020 13:31:40 +0300 (+03) Date: Mon, 27 Jul 2020 13:31:40 +0300 From: "Kirill A. Shutemov" To: Matthew Wilcox Cc: 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! Message-ID: <20200727103140.xycdx6ctecomqsoe@box> 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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200726164904.GG23808@casper.infradead.org> X-Rspamd-Queue-Id: AEB0A180F8B8C X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam05 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 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: > > > > > > 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: > > > > > > > > > > > syzbot has found a reproducer for the following issue on: > > > > > > > > > > > > HEAD commit: 4c43049f Add linux-next specific files for 20200716 > > > > > > git tree: linux-next > > > > > > console output: https://syzkaller.appspot.com/x/log.txt?x=12c56087100000 > > > > > > kernel config: https://syzkaller.appspot.com/x/.config?x=2c76d72659687242 > > > > > > dashboard link: https://syzkaller.appspot.com/bug?extid=c48f34012b06c4ac67dd > > > > > > compiler: gcc (GCC) 10.1.0-syz 20200507 > > > > > > syz repro: https://syzkaller.appspot.com/x/repro.syz?x=1344abeb100000 > > > > > > > > > > > > IMPORTANT: if you fix the issue, please add the following tag to the commit: > > > > > > Reported-by: syzbot+c48f34012b06c4ac67dd@syzkaller.appspotmail.com > > > > > > > > > > Thanks. > > > > > > > > > > __handle_mm_fault > > > > > ->pmd_migration_entry_wait > > > > > ->migration_entry_to_page > > > > > > > > > > stumbled onto an unlocked page. > > > > > > > > > > I don't immediately see a cause. Perhaps Matthew's "THP prep patches", > > > > > perhaps something else. > > > > > > > > > > Is it possible to perform a bisection? > > > > > > > > Maybe it's related to the new lock_page_async()? > > > > > > Or is there likely the window that after copy_huge_pmd() the src pmd migrate > > > entry is removed and the page unlocked but the dst is not? > > > > No. > > > > copy_huge_pmd() runs with exclusive mmap_lock on the source side and > > destination side is not running yet. > > The one I'm hitting is huge related though. > > I added this debug: > > +++ 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); > > +if (PageCompound(page)) printk("pfn %lx order %d\n", page_to_pfn(page), thp_order(thp_head(page))); > return swp_entry(write ? SWP_MIGRATION_WRITE : SWP_MIGRATION_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; > } > > > and got useful output (while running generic/086): > > 1457 086 (20181): drop_caches: 3 > 1457 page:00000000a216ae9a refcount:2 mapcount:0 mapping:000000009ba7bfed index:0x2227 pfn:0x229e7 > 1457 aops:def_blk_aops ino:0 > 1457 flags: 0x4000000000002030(lru|active|private) > 1457 raw: 4000000000002030 fffff5b4416b5a48 fffff5b4408a7988 ffff9e9c34848578 > 1457 raw: 0000000000002227 ffff9e9bd18f0d00 00000002ffffffff 0000000000000000 > 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 > [...] > > Looking back in the trace, I see: > > ... > 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 > ... > > so I would say we have a refcount problem. I've probably made it worse by > creating more THPs, but I don't think I'm the originator of the problem. > > I know very little about the migration code today. I suspect I'm going > to have to learn about it next week. It would be interesting to know if the migration entires ever got removed for pfn. I mean if remove_migration_pte() got called for it. It can be rmap issue too. Maybe it misses PMD on remove_migration_ptes() or something. -- Kirill A. Shutemov