From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
To: "Naulls, Peter" <PeterNaulls@eaton.com>
Cc: "linux-rt-users@vger.kernel.org" <linux-rt-users@vger.kernel.org>
Subject: Re: Btrfs PREEMPT_RT transaction-waiter livelock: experimental mitigation in kernel 6.6.78
Date: Tue, 13 Oct 2026 16:41:19 +0200 [thread overview]
Message-ID: <20261013144119.-2EEqlL-@linutronix.de> (raw)
In-Reply-To: <PH0PR17MB4277167A37B20340B231443FBB922@PH0PR17MB4277.namprd17.prod.outlook.com>
On 2026-10-09 15:34:02 [+0000], Naulls, Peter wrote:
> Long term kernel hacker, but very infrequent contributor.
Hi Peter,
> We are using the RT kernel patch on x86 under kernel 6.6.78-rt51.
> Specifically, this is the kernel from meta-intel in Yocto Scarthgap in
> the intel-kernel-rt recipe.
…
> sync (PID 52371)
> btrfs_commit_transaction+0xc48
> [return address immediately after rt_spin_lock(&fs_info->trans_lock)]
> btrfs_sync_fs
> sync_fs_one_sb
> ksys_sync
This sort of sounds like the state is TRANS_STATE_SUPER_COMMITTED but is
not making progress after that. Are there any tasks involved that run at
realtime priority and would block other tasks from making progress?
…
> This is in related code. I put this patch into our 6.6.78 kernel and it did not resolve the problem.
…
> # Experimental mitigation for a suspected PREEMPT_RT Btrfs transaction-waiter
> # livelock. wait_for_commit() can reselect a completed transaction that remains
> # on trans_list after its waiters are woken. Skip completed entries while still
> # waiting for older incomplete transactions. This is a diagnostic hypothesis,
> # not a confirmed fix for the observed lockup.
> # Review notes: the scan is O(n) under trans_lock. Completion state is published
> # locklessly elsewhere; READ_ONCE provides a single load, not acquire ordering.
> # A multi-hour run did not reproduce the issue, but the lock owner and root cause
> # remain unknown.
> diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
> index e15e1855fa0a..0f05fabe451c 100644
> --- a/fs/btrfs/transaction.c
> +++ b/fs/btrfs/transaction.c
> @@ -865,6 +865,7 @@ static noinline void wait_for_commit(struct btrfs_transaction *commit,
> const enum btrfs_trans_state min_state)
> {
> struct btrfs_fs_info *fs_info = commit->fs_info;
> + struct btrfs_transaction *next;
> u64 transid = commit->transid;
> bool put = false;
>
> @@ -893,10 +894,16 @@ static noinline void wait_for_commit(struct btrfs_transaction *commit,
> */
>
> spin_lock(&fs_info->trans_lock);
> - commit = list_first_entry_or_null(&fs_info->trans_list,
> - struct btrfs_transaction,
> - list);
> - if (!commit || commit->transid > transid) {
> + commit = NULL;
> + list_for_each_entry(next, &fs_info->trans_list, list) {
> + if (next->transid > transid)
> + break;
> + if (READ_ONCE(next->state) == TRANS_STATE_COMPLETED)
> + continue;
> + commit = next;
> + break;
> + }
> + if (!commit) {
> spin_unlock(&fs_info->trans_lock);
> break;
> }
>
>
> Note the O(N) time here. To that end, this is very unlikely to be the
> correct fix, but I hope it highlights the core problem. I ran this
> patch for several hours with no apparent problem (versus seconds of a
> lockup in previous testing).
>
> If there's a later kernel patch I've missed, or something else I ought
> to be looking at or test or need more info, please let me know.
PREEMPT_RT shouldn't do much different than !PREEMPT_RT. Do you have
tasks with different priorities? If that is the case then it might be
that one thread is blocking another thread that should make progress.
Your changes iterates over TRANS_STATE_COMPLETED so it seems that it is
not cleaned up for some reason.
Could you try if you can reproduce this with v7.3-rc7? This one does not
require any additional patches.
I'm not sure if this report would help the btrfs folks to recognize if
this is a solved problem or where the issue might be.
Sebastian
next prev parent reply other threads:[~2026-10-13 14:41 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-09 15:34 Btrfs PREEMPT_RT transaction-waiter livelock: experimental mitigation in kernel 6.6.78 Naulls, Peter
2026-10-13 14:41 ` Sebastian Andrzej Siewior [this message]
2026-10-13 15:29 ` [EXTERNAL] " Naulls, Peter
2026-10-13 15:52 ` Sebastian Andrzej Siewior
[not found] ` <SJ0PR17MB4288FC2E7FFB577F5D6C6D9EBB9E2@SJ0PR17MB4288.namprd17.prod.outlook.com>
2026-10-13 17:33 ` Naulls, Peter
2026-10-14 14:23 ` Daniel Vacek
2026-10-14 14:33 ` Daniel Vacek
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=20261013144119.-2EEqlL-@linutronix.de \
--to=bigeasy@linutronix.de \
--cc=PeterNaulls@eaton.com \
--cc=linux-rt-users@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.