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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id B4F18C5AE59 for ; Thu, 5 Jun 2025 07:18:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4FD096B008C; Thu, 5 Jun 2025 03:18:44 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4D3796B0093; Thu, 5 Jun 2025 03:18:44 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 410776B0096; Thu, 5 Jun 2025 03:18:44 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 203986B008C for ; Thu, 5 Jun 2025 03:18:44 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id B97ECEFA59 for ; Thu, 5 Jun 2025 07:18:43 +0000 (UTC) X-FDA: 83520494526.09.CBD96BB Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by imf12.hostedemail.com (Postfix) with ESMTP id 6436540009 for ; Thu, 5 Jun 2025 07:18:40 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=none; spf=pass (imf12.hostedemail.com: domain of tujinjiang@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=tujinjiang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1749107922; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=iTDqBgOMjHjK8pH0tuh0khBfV6j/21BPS/7e1dFmT4Q=; b=OICZBVLFuuhN8WSciUCjg5Zhbcd3uQay5y01gpQB6hl2oOpNtnSmzFN1zjxcO+0S2hUpba DcUy1rz5lFC4hcgRwA1ieNa7eXa7fNzXvv9FIpWAKtlPegwjqwPU/kKtcIQUPWBISh/u2i xPhuIkczoG5HJUOeZ9HZ4KOeP+oddU4= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=none; spf=pass (imf12.hostedemail.com: domain of tujinjiang@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=tujinjiang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1749107922; a=rsa-sha256; cv=none; b=Ua+DiqeFRxqVx1CAvDxnJkiBIjfSC7NrF0xslVaQawJvHcGfPI/69q+OQKPoTF9p2g5vxr dj2SgkyHZA/2WEHS3K9iO3vv9s/i7msRnfnRO+S8zDibC21wJZAirjbNx+skafXxhS1BA3 f99qoD1dAbbFrJ4yoVp9N/fm6Ydcbsw= Received: from mail.maildlp.com (unknown [172.19.163.48]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4bCbLH4l0hzGpwn; Thu, 5 Jun 2025 15:14:47 +0800 (CST) Received: from kwepemo200002.china.huawei.com (unknown [7.202.195.209]) by mail.maildlp.com (Postfix) with ESMTPS id 67BF1180080; Thu, 5 Jun 2025 15:18:36 +0800 (CST) Received: from [10.174.179.13] (10.174.179.13) by kwepemo200002.china.huawei.com (7.202.195.209) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Thu, 5 Jun 2025 15:18:35 +0800 Message-ID: Date: Thu, 5 Jun 2025 15:18:34 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 Subject: Re: [syzbot] [mm?] kernel BUG in try_to_unmap_one (2) To: David Hildenbrand , syzbot , , , , , , , , , , Jens Axboe , Catalin Marinas References: <68412d57.050a0220.2461cf.000e.GAE@google.com> <4fc2c008-2384-4d94-b1bf-f0a076585a4a@redhat.com> From: Jinjiang Tu In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.174.179.13] X-ClientProxiedBy: kwepems500002.china.huawei.com (7.221.188.17) To kwepemo200002.china.huawei.com (7.202.195.209) X-Rspam-User: X-Stat-Signature: as6dyb3ny7tfp4f6yc5zpushdzgn8hcy X-Rspamd-Queue-Id: 6436540009 X-Rspamd-Server: rspam11 X-HE-Tag: 1749107920-480324 X-HE-Meta: U2FsdGVkX1/BV/PuWX2xn5Gy5lDBPohflCWXz7A1otI+9lFjMbuoCxy6hyjR4rqeRrZXjL/uBwX1tHNmFBCXApgZT7JryNNxGpR/2Yw51GZC3DM329rzss+4Ii0hqtMCKn5fQq2Scs18z2kCAk4Rvnz4PhKZFWn2MI3P15N6VzZJZ2/VKDsKGQH6KFW8orOuQRROifPY47XgcEfQblJLKe2YLRq1Sds2DudYdEvvXOU0WCe5vfxrJODnsvDXV+eDudwE1wpq+Ct7W+CxtO60JgwmwXZ9d5MS9WNuPfX7R5GffgmmA/mlPrWJah2qjSvlJv6Bou4vFnyag2kllJ8Yi2SADTzD4DnmKogoYMAFnAYO48RlCFGJw1MebXYZtZqJHE06KtZXwdGe2H60ybHa+CaJt9r7ZQs6HaYnoX0tYothBhHmBY1d/nv51A7JtI83gyugII7GwYZ5z7LBT/gVq5oTEP7wjdm50XjGtopQ2P6ta1nTLrAhIRThN4ZBfAxVFhuE8TjYkdOvoLxJIK+5uxhWRCxkYxnFRBkc6NGpr/lR2YyS38YSs9NmmVKEUPt2ikFpzGKevvDykG6EBDUP6TxttSh1UGILx9X0buauURLpFlg8WICynHTMgSHGT/sT3u0fDpD/uQurVT0QQSu3D9Kww3kh7b+h4BU+oWdFalkk1O24C85uKSbbc/5TbXRY6TufcM9Un1YBSw4yvRchwmCT69MNGTtfKxoIsBHB321rSj+xi7YSi7qdgCPLOoMC1QwvTS6u/wZeZB6HDsduF+A163yyidGOyyT0g9OlYa/AahFwY4taWhzRqdsFB2xgD6XbVxxFvCxLu59il/mFI3c7fGoAS3A3zbe0POD56yO37382/AM+gOYQ4tKQTFUTKzxaXL1jz+cSgm58VForepbdYlDtlRlnbcRxBgyT3BOzZjIAnaL1/lXnOHbQYLnHziPhVBFkHKVeT74o4BX gEKgIYi3 TTCa+jaj+PlnVs4viMuHKLz22ghSV6Yip+JstidKP+zQkYOR9HvHFdAYSwCLmPtQ6arGu19nZfN6j+lO3HAZ8zq6OJn02IbsiIO9fmbb7uCUChtnP9TDs0xRgD1XweZR8lyA5xRzdHWFqdFThOKdYtPkGSb4aTthP+kE6nqwFzdFSG3PCpvSQyItiikAQaRBMsWz2sQEiHR0zuIGUG8xOKBJPIBidAPZcSYT/2kx3au7Q3okn6hBldh93gvL2Quxbu2twCql7ufSYgJ7m6SrqOOFMOFugL/u0rbPGSPTH2ApHGVARdsXbRS5KiZap5kaBrLjL+dQ8auP/i4z8Wa1sHiHi/pMSAmfWckTyqXaXlQUdeusNT6/TRJe0Mi9m+s29etoxZ3xky2BniSQcBHMEo/51XYk8W86JLprx 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: List-Subscribe: List-Unsubscribe: 在 2025/6/5 14:37, David Hildenbrand 写道: > On 05.06.25 08:27, David Hildenbrand wrote: >> On 05.06.25 08:11, David Hildenbrand wrote: >>> On 05.06.25 07:38, syzbot wrote: >>>> Hello, >>>> >>>> syzbot found the following issue on: >>>> >>>> HEAD commit:    d7fa1af5b33e Merge branch 'for-next/core' into >>>> for-kernelci >>> >>> Hmmm, another very odd page-table mapping related problem on that tree >>> found on arm64 only: >> >> In this particular reproducer we seem to be having MADV_HUGEPAGE and >> io_uring_setup() be racing with MADV_HWPOISON, MADV_PAGEOUT and >> io_uring_register(IORING_REGISTER_BUFFERS). >> >> I assume the issue is related to MADV_HWPOISON, MADV_PAGEOUT and >> io_uring_register racing, only. I suspect MADV_HWPOISON is trying to >> split a THP, while MADV_PAGEOUT tries paging it out. >> >> IORING_REGISTER_BUFFERS ends up in >> io_sqe_buffers_register->io_sqe_buffer_register where we GUP-fast and >> try coalescing buffers. >> >> And something about THPs is not particularly happy :) >> > > Not sure if realted to io_uring. > > unmap_poisoned_folio() calls try_to_unmap() without TTU_SPLIT_HUGE_PMD. > > When called from memory_failure(), we make sure to never call it on a > large folio: WARN_ON(folio_test_large(folio)); > > However, from shrink_folio_list() we might call unmap_poisoned_folio() > on a large folio, which doesn't work if it is still PMD-mapped. Maybe > passing TTU_SPLIT_HUGE_PMD would fix it. > TTU_SPLIT_HUGE_PMD only converts the PMD-mapped THP to PTE-mapped THP, and may trigger the below WARN_ON_ONCE in try_to_unmap_one. if (PageHWPoison(subpage) && (flags & TTU_HWPOISON)) { ... } else if (likely(pte_present(pteval)) && pte_unused(pteval) && !userfaultfd_armed(vma)) { .... } else if (folio_test_anon(folio)) { swp_entry_t entry = page_swap_entry(subpage); pte_t swp_pte; /* * Store the swap location in the pte. * See handle_pte_fault() ... */ if (unlikely(folio_test_swapbacked(folio) != folio_test_swapcache(folio))) { WARN_ON_ONCE(1);          // here. if the subpage isn't hwposioned, and we hasn't call add_to_swap() for the THP goto walk_abort; } If we want to unmap in shrink_folio_list, we have to try_to_split_thp_page() like memory_failure(). But it't too complicated, maybe just skip the hwpoisoned folio is enough? If the folio is accessed again, memory_failure will be trigerred again and kill the accessing process since the folio has be hwpoisoned. > > Likely the relevant commit is: > > commit 1b0449544c6482179ac84530b61fc192a6527bfd > Author: Jinjiang Tu > Date:   Tue Mar 18 16:39:39 2025 +0800 Yes, It is caused by this commit. > >     mm/vmscan: don't try to reclaim hwpoison folio >         Syzkaller reports a bug as follows: >         Injecting memory failure for pfn 0x18b00e at process virtual > address 0x20ffd000 >     Memory failure: 0x18b00e: dirty swapcache page still referenced by > 2 users >     Memory failure: 0x18b00e: recovery action for dirty swapcache > page: Failed >     page: refcount:2 mapcount:0 mapping:0000000000000000 index:0x20ffd > pfn:0x18b00e >     memcg:ffff0000dd6d9000 >     anon flags: > 0x5ffffe00482011(locked|dirty|arch_1|swapbacked|hwpoison|node=0|zone=2|lastcpupid=0xfffff) >     raw: 005ffffe00482011 dead000000000100 dead000000000122 > ffff0000e232a7c9 >     raw: 0000000000020ffd 0000000000000000 00000002ffffffff > ffff0000dd6d9000 >     page dumped because: VM_BUG_ON_FOLIO(!folio_test_uptodate(folio)) > > CCing Jinjiang Tu >