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 lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6071DE9907D for ; Fri, 10 Apr 2026 10:33:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.sourceforge.net; s=beta; h=Content-Transfer-Encoding:Content-Type:Cc: Reply-To:From:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:Subject:MIME-Version:References:In-Reply-To: Message-Id:Date:To:Sender:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=QpdC6oeSqdwP6DmX9JmIR8STgMucJt/Lju+d0a8TJS8=; b=VMzoognu9fL/PlhIpuI5qREaKO 67cTyC1AlFX9CnJQPta4WkuysQXfW/RKZd2kdTspwAHRfIgqvxqTzcTkItbH6D0q4w5V0FKiMofOK BiGBxOitdW+BMNhiIqlnotWi9IAqSAQKaUEM1F7hyOLFxSC6kuA+OfyJeA54UhptwhjM=; Received: from [127.0.0.1] (helo=sfs-ml-3.v29.lw.sourceforge.com) by sfs-ml-3.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1wB9B9-0003uf-4M; Fri, 10 Apr 2026 10:33:35 +0000 Received: from [172.30.29.66] (helo=mx.sourceforge.net) by sfs-ml-3.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1wB9B8-0003uX-B7 for linux-f2fs-devel@lists.sourceforge.net; Fri, 10 Apr 2026 10:33:34 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=xZ6TAo+TYnp13Hfh21hAsBb3kxXdDt70XfPAJsthrt8=; b=gAtCjwtvLypsciG4ar2lvcmzo8 /p3iODh1eD2egLWIYNYFKo9j5BJCAjqX/5nPWXmbYbXlINxg9REgaPf8iPtRqieF4MG44e2t3/21w 2Pcv0dyoa6mDVGzpW+e1H8S+7IIOWWGqb/ZRCF0CiTFZEE02ehh4OM9hYghnjRptUV7k=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=xZ6TAo+TYnp13Hfh21hAsBb3kxXdDt70XfPAJsthrt8=; b=E+Q91WSYY8ht13PdN91IJC+Kjs paLs3b4NlxwEEFhoiE1MK/ltr420FcEiHrGoYBgSdIqzMwakB+B5bMr8SOL1k60V2By60xBuUfe2L 1+myA4XFIG6AQJgtamQSSXDBYr9rdhACWYeh2cli5NNrA/O0UggRrGn7MtsBeuUEE3MA=; Received: from mx0a-0031df01.pphosted.com ([205.220.168.131]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1wB9B7-0003Yq-PL for linux-f2fs-devel@lists.sourceforge.net; Fri, 10 Apr 2026 10:33:34 +0000 Received: from pps.filterd (m0279866.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 63A5iUj2779506; Fri, 10 Apr 2026 10:20:02 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=qcppdkim1; bh=xZ6TAo+TYnp 13Hfh21hAsBb3kxXdDt70XfPAJsthrt8=; b=TfFAnc4UyVOhbGm8otChWQHFmhy MihvW+zgNjJVixRr93CmA5UaLUgIFzln/pYc6+mhDt2vzchvQmnZFGCqwqoedH+A Y36rD6uDlnjpBGPk0/FuqAgFwAGBurcetfIbEmDix2a6BiECsG1OlzS6iO5j9xRh aB8+UDZjmnlXgYYA3ZI2ypzZy9lF5jII+J7CYoUS36WEZQcVmTk0oWgryAOGhCa3 1O6PhKxmU2+c2kfQkIZkgs27Mpt6EUv6vIr42DGTO9LOvgfQz1Vk9jd7kNM4OMtT uFpsMu9uZcFHzidMsyYUkK7qhJZpnVrfskAs2wqiuVyXlHogqSdi4qUN/ig== Received: from nalasppmta02.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4dec8hv3pn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 10 Apr 2026 10:20:02 +0000 (GMT) Received: from pps.filterd (NALASPPMTA02.qualcomm.com [127.0.0.1]) by NALASPPMTA02.qualcomm.com (8.18.1.7/8.18.1.7) with ESMTP id 63AAK1Va024378; Fri, 10 Apr 2026 10:20:01 GMT Received: from pps.reinject (localhost [127.0.0.1]) by NALASPPMTA02.qualcomm.com (PPS) with ESMTPS id 4denmue5aq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 10 Apr 2026 10:20:01 +0000 (GMT) Received: from NALASPPMTA02.qualcomm.com (NALASPPMTA02.qualcomm.com [127.0.0.1]) by pps.reinject (8.18.1.12/8.18.1.12) with ESMTP id 63AAK1iR024304; Fri, 10 Apr 2026 10:20:01 GMT Received: from hu-devc-lv-u22-c.qualcomm.com (hu-xiaosenh-lv.qualcomm.com [10.81.27.218]) by NALASPPMTA02.qualcomm.com (PPS) with ESMTPS id 63AAK0tm024285 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 10 Apr 2026 10:20:01 +0000 (GMT) Received: by hu-devc-lv-u22-c.qualcomm.com (Postfix, from userid 4148646) id 8B3326E4; Fri, 10 Apr 2026 03:20:00 -0700 (PDT) To: jaegeuk@kernel.org, chao@kernel.org, linux-f2fs-devel@lists.sourceforge.net Date: Fri, 10 Apr 2026 03:19:52 -0700 Message-Id: <20260410101952.3210031-2-xiaosen.he@oss.qualcomm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260410101952.3210031-1-xiaosen.he@oss.qualcomm.com> References: <20260410101952.3210031-1-xiaosen.he@oss.qualcomm.com> MIME-Version: 1.0 X-QCInternal: smtphost X-QCInternal: smtphost X-Authority-Analysis: v=2.4 cv=PMM/P/qC c=1 sm=1 tr=0 ts=69d8ced2 cx=c_pps a=ouPCqIW2jiPt+lZRy3xVPw==:117 a=ouPCqIW2jiPt+lZRy3xVPw==:17 a=A5OVakUREuEA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=YMgV9FUhrdKAYTUUvYB2:22 a=EUspDBNiAAAA:8 a=r2Ui-NX8CWQL2jrR6UsA:9 X-Proofpoint-ORIG-GUID: A02i-X7cyGBoa2no5dR5P1NJgyTzmkJO X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNDEwMDA5NSBTYWx0ZWRfX0cXqFuuKJRGf 4JzzgSWpMIeyaICp7909b8VbBywNPYuSyInqpY9BKgj4/yQsNnNEh7tH0Mlxt2Q3ZCAM8zNZvC1 5XvWJPKes56BllLkVZNdochaSlXGUoqtjP/Oa8Xsk4UKxPAKFZZp7eDA2rsc9vwH0ac0xma31cA gw6K3Kr9s3lXUQ7LTzK22F1IFdMdNZBT2++RVtmFlU1QGg7HAYtCmdPUMo2r5iNLTZqtmGGiOvL hsvmHJYB24v2uVIDp8V3YLJbje0hPpd1QqdZS92kxmQ09IkIb7oenHZlaBJ4icka3IPOxQpNWIH 6o53bLEXnxIqadKlEoKT6G9MlnlyUmREbMV3antiXrgENU14cZ8fyal7kGcHn/BLesae4loRKhf ImLWoGo4LovcXqs+hJGi1TGBEafyT0QWDTLZXiuyDzG9roBYCai1ZL9+7+dBDC3eNj/0fFsnica qPGey9aDNN8NUt6kB9w== X-Proofpoint-GUID: A02i-X7cyGBoa2no5dR5P1NJgyTzmkJO X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-04-10_03,2026-04-09_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 suspectscore=0 priorityscore=1501 adultscore=0 lowpriorityscore=0 bulkscore=0 phishscore=0 clxscore=1015 malwarescore=0 spamscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2604010000 definitions=main-2604100095 X-Headers-End: 1wB9B7-0003Yq-PL Subject: [f2fs-dev] [PATCH v2 1/1] f2fs: fix deadlock in serializing io X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Xiaosen He via Linux-f2fs-devel Reply-To: Xiaosen He Cc: can.guo@oss.qualcomm.com, xiaosen.he@oss.qualcomm.com Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net kworker/u32:7(f2fs writeback thread) was trying to acquire sbi->writepages, the mutex was already acquired by emulated;0. kworker/u32:7 tried to flush plugged IO before sleep, during flushing plug list, kworker/u32:7 got preempted in RCU read-side critical section and got scheduled out waiting to be woken up by the release of mutex. emulated;0 was blocked on blk_mq_get_tag as there was no available tag and expected the previous IO requests to be handled by UFS host to release tags, but UFS host was blocked on synchronize_rcu waiting for ending of RCU grace period. the deadlock was caused by writeback thread was stuck in RCU critical section waiting for mutex. call blk_flush_plug() if mutex_trylock(&sbi->writepages) failed, so that the plug list is empty when blk_flush_plug() is called in sched_submit_work to fix the deadlock. Task name: kworker/u32:7 [affinity: 0xff] pid: 233 tgid: 233 cpu: 6 prio: 98 start: 0xffffff8099390040 state: 0x2[D] exit_state: 0x0 stack base: 0xffffffc083c48000 Last_enqueued_ts: 390.169395877 Last_sleep_ts: 389.756639574 Stack: [] __switch_to+0x214 [] __schedule+0xa30 [] preempt_schedule_notrace+0x68 [] rcu_is_watching[jt]+0x5c [] lock_acquire+0x68 [] rcu_lock_acquire+0x34 [] percpu_ref_put_many+0x20 [] blk_mq_dispatch_list+0x570 [] blk_mq_flush_plug_list+0x13c [] __blk_flush_plug+0x11c [] sched_submit_work+0x78 [] schedule+0x38 [] schedule_preempt_disabled+0x18 [] __mutex_lock_common+0xab8 [] mutex_lock_nested+0x2c [] f2fs_write_data_pages+0xd64 [] do_writepages+0xd4 [] __writeback_single_inode+0x78 [] writeback_sb_inodes+0x2b8 [] __writeback_inodes_wb+0xa0 [] wb_writeback+0x188 [] wb_workfn[jt]+0x438 [] process_one_work+0x27c [] worker_thread+0x358 [] kthread+0x150 [] ret_from_fork+0x10 Task name: kworker/u32:2 [affinity: 0xff] pid: 90 tgid: 90 cpu: 1 prio: 120 start: 0xffffff80adae8040 state: 0x2[D] exit_state: 0x0 stack base: 0xffffffc080a18000 Last_enqueued_ts: 389.899608637 Last_sleep_ts: 389.899665303 Stack: [] __switch_to+0x214 [] __schedule+0xa30 [] schedule+0x48 [] synchronize_rcu_expedited+0x928 [] synchronize_rcu[jt]+0x234 [] blk_mq_quiesce_tagset[jt]+0xa8 [] ufshcd_devfreq_scale+0x90 [] ufshcd_devfreq_target+0x204 [] devfreq_set_target+0xb8 [] devfreq_update_target[jt]+0xd8 [] devfreq_monitor+0x38 [] process_one_work+0x27c [] worker_thread+0x358 [] kthread+0x150 [] ret_from_fork+0x10 Task name: emulated;0 [affinity: 0xff] pid: 5245 tgid: 4922 cpu: 6 prio: 120 start: 0xffffff89e2e60040 state: 0x2[D] exit_state: 0x0 stack base: 0xffffffc0d42f8000 Last_enqueued_ts: 390.169395877 Last_sleep_ts: 390.178459731 Stack: [] __switch_to+0x214 [] __schedule+0xa30 [] schedule+0x48 [] io_schedule+0x38 [] blk_mq_get_tag+0x1a4 [] __blk_mq_alloc_requests+0x358 [] blk_mq_submit_bio+0x50c [] __submit_bio[jt]+0x164 [] submit_bio_noacct_nocheck+0x14c [] submit_bio_noacct+0x330 [] submit_bio+0x1f4 [] f2fs_submit_write_bio+0x88 [] __submit_merged_bio[jt]+0xbc [] f2fs_submit_page_write+0x400 [] do_write_page+0x180 [] f2fs_outplace_write_data+0x78 [] f2fs_do_write_data_page+0x390 [] f2fs_write_single_data_page+0x1e0 [] f2fs_write_data_pages+0x8c0 [] do_writepages+0xd4 [] __filemap_fdatawrite_range+0x94 [] generic_fadvise+0x1d8 [] f2fs_file_fadvise+0x124 [] __arm64_sys_fadvise64_64+0x70 [] invoke_syscall+0x58 [] el0_svc_common[jt]+0xb8 [] do_el0_svc+0x1c [] el0_svc+0x40 [] el0t_64_sync_handler[jt]+0xd0 [] ret_to_user[jt]+0x0 Signed-off-by: Xiaosen He --- fs/f2fs/data.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index 338df7a2aea6..f570c3b47dd0 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -3585,6 +3585,8 @@ static int __f2fs_write_data_pages(struct address_space *mapping, } if (__should_serialize_io(inode, wbc)) { + if (!mutex_trylock(&sbi->writepages)) + blk_flush_plug(((struct task_struct *)current)->plug, true); mutex_lock(&sbi->writepages); locked = true; } -- 2.34.1 _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel