Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=115.124.30.119 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796202810; b=YG5xz0TnY5WAlngdikXMJJYQpU0BhQ0hg29pKTSZ6GoyYbSz+19s31MvTwVE6Huy1m9j jEPhaRwgj/UG+AN1V3P7mLX+YjDpYLp3HmrAbOa6zNuMZIO+EGVOFtA80/zmAckhejmMk w87R7+JbobVPrE1kp2wqxaD0dLthrgebI8FBlhuBPRKv1wGZiGv8WwTO/dzSxCcty7DZU YGzm1AaJahy30MtUH86nWuB/y4wN33QFiPDuUaWFHHR0RTfJZSNuTNXHP24Wh3otb1udk pyPL+CHLC5LtPF8zudLSmklRpmLlkwrlt56yUt2SAxtHaeH3tAqTokGxUr0HQgtAU+g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796202810; h=DMARC-Filter:DKIM-Signature:X-Alimail-AntiSpam:Received:Message-ID: Date:MIME-Version:User-Agent:Subject:To:Cc:References:From: In-Reply-To:Content-Type:Content-Transfer-Encoding; bh=t07xegmjlK5YW4/DqBXXyaLkAAx7RnITaYnsW2tISTg=; b=Vh16jEufvsFIVnvlrgCVd+oOqt4OSRQpRFNV2jhHmbDV4OGNVxL95txOOSYOOarWrlAl 6994YpJfnJm1Om2e5OlZLarhu4xpG0jnljhpOHuv1JrgCYvnepsOveyoNV0tpM7vDKV4u XrFvvU/HDmHFmR2CxukC0Lm3n9DX58gS6M7Q00B3MdTFMDVw59QLYcSF1CNTP79MNOIre 6ub3nrC2TIXGePHl+9+grY2zcFOeGhr9uu9qit+MbO89qQ6aNyOaM5BEfhFH6J0zJ2QD0 bvHcEeLkQXLJKVFjkPU+oHFqFowjBycb8/yJcGJZ01o8DyWZ03zr4Mhvw6nBJyDirFw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.alibaba.com; spf=pass smtp.mailfrom=linux.alibaba.com; dkim=pass header.d=linux.alibaba.com header.i=@linux.alibaba.com header.a=rsa-sha256 header.s=default header.b="B4PlUj8/"; arc=none smtp.remote-ip=115.124.30.119 Received: from out30-119.freemail.mail.aliyun.com (out30-119.freemail.mail.aliyun.com [115.124.30.119]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 318FC606A322 for ; Wed, 2 Dec 2026 09:13:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 318FC606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.a=rsa-sha256 header.s=default header.b=B4PlUj8/ DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1796202807; h=Message-ID:Date:MIME-Version:Subject:To:From:Content-Type; bh=t07xegmjlK5YW4/DqBXXyaLkAAx7RnITaYnsW2tISTg=; b=B4PlUj8/ZrsHEE+6NEgFZpsvLpOklHAytYyfDl8SbMSpFdRFdv84SwxMIJtokuhkzy43G689Kb562Ucgdd7nF4xY9Vz8xV2JRqmFYr/k6Y7ghfgTAsUgfLbtvY76OtuU68LbMVO2eRqKZ2aDovH2OCTJDiikqNnmBFV4c+/6lVI= X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R571e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=maildocker-contentspam033037009110;MF=baolin.wang@linux.alibaba.com;NM=1;PH=DS;RN=81;SR=0;TI=SMTPD_---0XG8kfrX_1796202800; Received: from 30.74.144.133(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0XG8kfrX_1796202800 cluster:ay36) by smtp.aliyun-inc.com; Wed, 02 Dec 2026 17:13:23 +0800 Message-ID: <7b18ca6f-3066-4b43-a680-b4a5653ba59e@linux.alibaba.com> Date: Wed, 2 Dec 2026 17:13:19 +0800 X-Mailing-List: linux-rt-devel@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 08/32] mm/khugepaged: flush file after unlocking folios in collapse_file() To: "David Hildenbrand (Arm)" , Hugh Dickins , Andrew Morton , Mike Rapoport , Peter Xu , Michal Hocko , Kiryl Shutsemau , Manfred Spraul , Davidlohr Bueso , Cyrill Gorcunov , Zi Yan , "Liam R. Howlett" , Nico Pache , Ryan Roberts , Dev Jain , Barry Song , Lance Yang , Usama Arif , Lorenzo Stoakes , Rik van Riel , Vlastimil Babka , Harry Yoo , Jann Horn , Yang Shi , Zach O'Keefe , Song Liu , David Stevens , Kefeng Wang , Alex Williamson , Suren Baghdasaryan , Dave Jiang , Matthew Wilcox , Miaohe Lin , David Rientjes , Shakeel Butt , Jan Kara , Mel Gorman , Jason Gunthorpe , John Hubbard , Gerd Hoffmann , Vivek Kasireddy , Dave Airlie , Matthew Brost , Joshua Hahn , Byungchul Park , Gregory Price , Ying Huang , Alistair Popple , Hagen Paul Pfeifer , James Bottomley , Felix Kuehling , Alex Sierra , Balbir Singh , Kairui Song , Qi Zheng , Axel Rasmussen , Yuanchu Xie , Wei Xu , Baoquan He , Oscar Salvador , Muchun Song , Dan Williams , Rakie Kim , Hao Li , Christoph Lameter , Roman Gushchin , Sebastian Andrzej Siewior , Clark Williams , Steven Rostedt , Alexei Starovoitov , Xu Xin , Chengming Zhou , Shivank Garg Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-cxl@vger.kernel.org, linux-rt-devel@lists.linux.dev, SJ Park , Chris Mason , stable@vger.kernel.org References: <20261129-fixes_core_3-v1-0-f66094116801@kernel.org> <20261129-fixes_core_3-v1-8-f66094116801@kernel.org> From: Baolin Wang In-Reply-To: <20261129-fixes_core_3-v1-8-f66094116801@kernel.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 11/29/26 6:06 PM, David Hildenbrand (Arm) wrote: > From: Chris Mason > > collapse_file() calls filemap_flush() when it encounters a dirty folio in > a file that is not open for writing. At that point, source folios earlier > in the range are still locked. The writable-open check is racy: a writer > can open the file after the check. > > On ext4, the flush may need a journal handle, while EXT4_IOC_MOVE_EXT > takes a journal handle before locking folios, and a journal commit blocks > new handles while waiting for existing handles to be released. > > Consequently, we can deadlock: collapse_file() waits for a handle, the > commit waits for extent movement to finish, and extent movement waits for > a source folio lock. > > Let's fix it by deferring filemap_flush() until rollback has unlocked all > source folios. > > This has medium urgency, as it can deadlock ext4 in some scenarios. > > Fixes: 75f360696ce9 ("mm/thp: flush file for !is_shmem PageDirty() case in collapse_file()") > Cc: stable@vger.kernel.org > Signed-off-by: Chris Mason > [ david: rework code; simplify comments and description ] > Signed-off-by: David Hildenbrand (Arm) > --- LGTM. Reviewed-by: Baolin Wang