From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-oi1-f172.google.com (mail-oi1-f172.google.com [209.85.167.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7A2B8379C20 for ; Tue, 12 May 2026 08:07:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778573240; cv=none; b=daqiQkjF2C+1VVLUyz7SdfGUqvY3o7Q936Bszpcl4Hp9gUBOXmyEvXuHqw7AzBqpNTnkXTnldG/nivkxAn+F8Piy3+2ghQugXvm2DoxwNbccLnF/CpcKLkeaxqG3JFU9DE2Ri9RT6JLAxYYsGTN2shwe8MXB8OlEzMQk2zoYnEI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778573240; c=relaxed/simple; bh=jAgQG7EAsC36kPwVxZzWPi1dqHCRuBg4xd0zcyE/2EQ=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=IQK8ZxW2SS7DZaBz0JMKCMCeFBTNiCWz6GZw9Pp36tFj8ITQ9Kdam4bfgI7OPQWaYmgki08IWkwdABANPjx7ESPK8XmnsI6Dzn2GuioE3CvMvbYiFOvVZsdKcButWao8oYOPNAVRHk7v3ST32/XmvF8P1BtiOI6kA7qHCV6CVqs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=DHtIGK8N; arc=none smtp.client-ip=209.85.167.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="DHtIGK8N" Received: by mail-oi1-f172.google.com with SMTP id 5614622812f47-47bdee5bfc4so3610012b6e.1 for ; Tue, 12 May 2026 01:07:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1778573237; x=1779178037; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=xdojfavMRM36mRqPBUNav0nKv8uWwk4QyGdy/Q3s4jo=; b=DHtIGK8N99liEslDW+UlteRa+ixhktYXmjJJlC5j1K3GQu5HN/9fOSKhbUb7ej9e5z GGXD9rBrVoBdarAMnWT3yLwWvlSI5yLAFFwU7qJW+yU7N6mIuCF+r4G/5G3WtFVWJsYm 2mTrOvFPFvErglJlYSANjrDjWJ12Am6Buz58yVP/Y3H0smbsy6zICqkrnSUoluHzvFJr tN0rUkQj2i5z+s9v4AF3N8phcATfp0kp4JiHBgYfmeHvXn58nnNuWNIxChApszpj0Igl j4C0kIfWMofBEkzqxZQq0+m1LcQGSRFSKtJuXuB9lGi/MCNx6GnLkJyhbwVLRUR/Nfd9 6/vg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778573237; x=1779178037; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xdojfavMRM36mRqPBUNav0nKv8uWwk4QyGdy/Q3s4jo=; b=algpOXwySX4psOBwpvT8BUOhGc0ZzaoVfECwDEEzqemOKAoJ5gfT45kJabYKyCa63V +Xt+QXL3JA1HUyGfO4VDKCWe+fXyh+Er3bQHMa8g54yFsp3SzAD0u611csRlhxdYI3Cv VbYHKbUEcRaZSs2CbP4LOUaIkXYHS2ADU0SpPMLDie5RGMMr6t4tmTOWbu1OUjpQPX3h 35ShtuF5DppVJmbybeGsR5EA5QLM3rWKhgCYQn+FoCVdtkZ8yOI7MTN9CJHoY3nLlpil PJD/zt1Nj3xz9C1GmzUWiBCmXilqgF06QHwrTwpZbG9+CNq97r1G+GV+I6mCLR1hHqNL Rkhw== X-Forwarded-Encrypted: i=1; AFNElJ+RTl+gl20lNw7UF3vhYqbeYIOiUSys/i5YhcdNtKRc9+rfM00lm7190ufFiQL18rLtRfOejiyUCKlBMWQ=@vger.kernel.org X-Gm-Message-State: AOJu0YzMitgZtyvDAzHrV7wgZfGki8UJnbJpwCLTTWama265mCvoJU/n 7u6OhSjyH1Q7wVvcRbEWim/LgafUcJEprg72rNMny0a56CKfwtB9tgGX X-Gm-Gg: Acq92OH2FeSf3aMKIUXqPmDHmkIJ/EvQqJKbjQppoJYNiCl2iqmHY1JsmyJw8mcdx/l 604Qa1g7hVQuxKkCOjsOAvhUzztAj5b4TI0M+UWEhF3Qv0w1J8Z5jGvWWZGkLg8xIntlpJsWK+e WkpdGZqCq9JnczYDIUI/7uiFEA7aUancnnBJ0Vj3W6d8sIVZPSh4tudRGhB1pswAFmVROuLWSg1 5cjF/sJ36YfOIzFy92EuO269ZM89fyQykUHQN6o/WiffZxCERl7nI8jxYF7+UN58JXXcoKgCQBZ mqZ9FmsyN21KT288QPIwNflJKUu/Bce2RnhvDExwWlybYepEkXU7RG77TC39Hbl+D1t8UGi+Cqw 6+JgyKIRf5OhOXarhp8G3syUyZuuSyarrwzuaX3xzKw1yz7p/lXo46CFm+6Hc2O2GnCq0tKwwyY AHGgYgl11I55/Ppwoh+PTNTX/30SxKdPVsKOY6JrGOAokbntZwxtHvXrkTism2TgUk/eVs1Sh0B qg8sAPKq21pB5hcLNgra3l02euWEB8= X-Received: by 2002:a05:6808:c171:b0:47c:be57:7fb0 with SMTP id 5614622812f47-48293c21669mr2066853b6e.9.1778573237226; Tue, 12 May 2026 01:07:17 -0700 (PDT) Received: from fedora ([172.245.82.59]) by smtp.gmail.com with ESMTPSA id 5614622812f47-4824f8f1964sm6030932b6e.7.2026.05.12.01.07.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 May 2026 01:07:16 -0700 (PDT) Date: Tue, 12 May 2026 16:07:11 +0800 From: Ming Lei To: Xiaosen Cc: Jens Axboe , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Michael Wu Subject: Re: [PATCH] sched: disable preemption around blk_flush_plug in sched_submit_work Message-ID: References: <20260423125528.2917171-1-tom.leiming@gmail.com> <5660795d-87de-46f5-add4-7729a02225ef@oss.qualcomm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5660795d-87de-46f5-add4-7729a02225ef@oss.qualcomm.com> On Tue, May 12, 2026 at 01:56:55PM +0800, Xiaosen wrote: > There is another deadlock caused by preemption during calling > blk_flush_plug() in sched_submit_work(). > blk_mq_dispatch_list > percpu_ref_get(&this_hctx->queue->q_usage_counter) > percpu_ref_get_many(ref, 1); > rcu_read_lock() > __rcu_read_lock() > rcu_lock_acquire > lock_acquire > preempt_schedule_irq --> writeback worker got > preempted here and be scheduled out in D state > > 1. task kworker/u32:6 had dirty pages from f2fs node inode submitted to > block layer and the corresponding request was added to plug list of the > current task. > 2. task snpe-net-run acquired gc_lock waiting for the request that > contained page from node inode to be completed. > 3. task kworker/u32:6 needed to acquire gc_lock to perform foreground > GC, since the gc_lock had already been acquired by task snpe-net-run, so > it called blk_flush_plug() in sched_submit_work() before sleeping to > avoid deadlocks, but task kworker/u32:6 got preempted in RCU critical > section before running hw queue to issue plugged requests. so the > plugged requests were pending in local request list. task kworker/u32:6 > was scheduled out waiting to be woken up by the release of gc_lock. > 4. so, there is a deadlock to cause RCU STALL. > > I think task kworker/u32:6 should not be scheduled out before returning > from blk_flush_plug(), and I think this patch should be able to fix such > deadlocks. This patch isn't enough, because the current task could be preempted anytime before calling into blk_flush_plug(), even before schedule(). One quick way is to fix schedule_preempt_disabled(), I will prepare one formal patch later. diff --git a/kernel/sched/core.c b/kernel/sched/core.c index b8871449d3c6..18ef6ed71b4f 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -7336,6 +7336,7 @@ asmlinkage __visible void __sched schedule_user(void) */ void __sched schedule_preempt_disabled(void) { + blk_flush_plug(current->plug, true); sched_preempt_enable_no_resched(); schedule(); preempt_disable(); Thanks, Ming