linux-rt-devel.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: Yunseong Kim <ysk@kzalloc.com>
To: Song Liu <song@kernel.org>, Yu Kuai <yukuai3@huawei.com>
Cc: linux-raid@vger.kernel.org, linux-rt-devel@lists.linux.dev,
	linux-kernel@vger.kernel.org, Yunseong Kim <ysk@kzalloc.com>
Subject: [PATCH] md/raid5-ppl: Fix invalid context sleep in ppl_io_unit_finished() on PREEMPT_RT
Date: Sun, 17 Aug 2025 11:31:16 +0000	[thread overview]
Message-ID: <20250817113114.1335810-3-ysk@kzalloc.com> (raw)

The function ppl_io_unit_finished() uses a local_irq_save()/spin_lock()
sequence. On a PREEMPT_RT enabled kernel, spin_lock() can sleep. Calling it
with interrupts disabled creates an atomic context where sleeping is
forbidden.

Ensuring that the interrupt state is managed atomically with the lock
itself. The change is applied to both the 'log->io_list_lock' and
'ppl_conf->no_mem_stripes_lock' critical sections within the function.

Signed-off-by: Yunseong Kim <ysk@kzalloc.com>
---
 drivers/md/raid5-ppl.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/md/raid5-ppl.c b/drivers/md/raid5-ppl.c
index 56b234683ee6..650bd59ead72 100644
--- a/drivers/md/raid5-ppl.c
+++ b/drivers/md/raid5-ppl.c
@@ -553,15 +553,13 @@ static void ppl_io_unit_finished(struct ppl_io_unit *io)
 
 	pr_debug("%s: seq: %llu\n", __func__, io->seq);
 
-	local_irq_save(flags);
-
-	spin_lock(&log->io_list_lock);
+	spin_lock_irqsave(&log->io_list_lock, flags);
 	list_del(&io->log_sibling);
-	spin_unlock(&log->io_list_lock);
+	spin_unlock_irqrestore(&log->io_list_lock, flags);
 
 	mempool_free(io, &ppl_conf->io_pool);
 
-	spin_lock(&ppl_conf->no_mem_stripes_lock);
+	spin_lock_irqsave(&ppl_conf->no_mem_stripes_lock, flags);
 	if (!list_empty(&ppl_conf->no_mem_stripes)) {
 		struct stripe_head *sh;
 
@@ -571,9 +569,7 @@ static void ppl_io_unit_finished(struct ppl_io_unit *io)
 		set_bit(STRIPE_HANDLE, &sh->state);
 		raid5_release_stripe(sh);
 	}
-	spin_unlock(&ppl_conf->no_mem_stripes_lock);
-
-	local_irq_restore(flags);
+	spin_unlock_irqrestore(&ppl_conf->no_mem_stripes_lock, flags);
 
 	wake_up(&conf->wait_for_quiescent);
 }
-- 
2.50.0


             reply	other threads:[~2025-08-17 11:33 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-17 11:31 Yunseong Kim [this message]
2025-08-18  0:56 ` [PATCH] md/raid5-ppl: Fix invalid context sleep in ppl_io_unit_finished() on PREEMPT_RT Yu Kuai
2025-08-18 11:54   ` Yunseong Kim
2025-08-18 15:56     ` Yu Kuai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250817113114.1335810-3-ysk@kzalloc.com \
    --to=ysk@kzalloc.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-raid@vger.kernel.org \
    --cc=linux-rt-devel@lists.linux.dev \
    --cc=song@kernel.org \
    --cc=yukuai3@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).