From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=115.124.30.97 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796202812; b=IBuR9v64j8/Ae8Pc2kTbE41mp7RU7lnv277GPUFl0M9FZJerf8aKnK7pDMzAgk8EwBxR AVzCUNIGOqtTOEsRhvgLEgREtA7/9reL3Lp6VC7uSzTRuwCPkOohMm4r8LdAWhDu8Kb1G c9ZQRroORu7+1Q1PjQCbdkzpr/wrDnCUZ/tG4RowYlRZcp3UMUvbQ7yhqYQ/p8sEtL0uT OsOdX6PK0ZGrsgCu4RYYS/0ihWe87FTw8ukVnndUs31xC7/DkIfo1sh5WDzF+otJDSo6V sMQrxz0CkEZu0LNj8PA0dQDPnL4J4C0xn4mkXkpRjdeTaFXDipSDcaWZX23+h3u0I6w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796202812; 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=qM+0cJaWWuJEURMH0XHEsdboY/MksGN6CiMPqIOSR//E0teoHl1dQk5HuGQl/dXODeY5 WWNknoK2TV3IqiQZaPR3iBfIlaVicgGSriXxHQncT12KRJ6fvo/BwRdtdEQSSKM3n26KH 31dmYcm1DpCyYYHU3bfSx3EhvmZjFS9J514+8TdXHFcn8+bcfL54Z1w59hYnABVWRn1DK cilyoH7tqyAG/8SB8ahqr8pGx7MvRpCo2aq3YwZaSJDiNQkfFoovIleekHPExr8MiXK+A IrK37qLvv8AuiyjR6O6850MgNXYIjO8uwA0s7qymQ2rSZ7IbSaXhvmAM+/P16R+RM0Q== 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=N1p9WqiI; arc=none smtp.remote-ip=115.124.30.97 Received: from out30-97.freemail.mail.aliyun.com (out30-97.freemail.mail.aliyun.com [115.124.30.97]) (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 BC07E606A31A; Wed, 2 Dec 2026 09:13:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org BC07E606A31A 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) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.a=rsa-sha256 header.s=default header.b=N1p9WqiI DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1796202808; h=Message-ID:Date:MIME-Version:Subject:To:From:Content-Type; bh=t07xegmjlK5YW4/DqBXXyaLkAAx7RnITaYnsW2tISTg=; b=N1p9WqiIodDydETq7O3QDrNanJClZu9YPKwUfzaxHnQxyug6sVl2pVdQFnHUzz2ouCIm7Q3rEjfsSZ8nJct3iz/NjNfoyRLCWlf0ugryt/osB4Sts/TolvUuRaQDUiGbDcs4nVIxf1FSZNK5fvILBJXScqjRhzs0zPFHmSPfCug= 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-kernel@vger.kernel.org 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