🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: muc.lists.freebsd.current
2 messages
2 total messages Started by Olivier Certner Wed, 11 Nov 2026 12:48
Re: ULE: run queue lock deadlock in sched_switch_migrate() + tdq_move()
#181
Author: Olivier Certner
Date: Wed, 11 Nov 2026 12:48
77 lines
5040 bytes
--nextPart2531705.bDOn7JOVgO
Content-Transfer-Encoding: 7Bit
Content-Type: text/plain; charset="utf-8"; protected-headers="v1"
From: Olivier Certner <olce@freebsd.org>
Date: Wed, 11 Nov 2026 13:48:56 +0100
Message-ID: <6612379.O1aUxXEVJ6@ravel>
In-Reply-To: <avRQ4kbiSw-xbhzU@kib.kiev.ua>
MIME-Version: 1.0

Hi,

> > - CPU 4: thread T was preempted (ipi_bitmap_handler -> sched_preempt ->
> >   mi_switch -> sched_switch) and is migrating to CPU 12.
> >   sched_switch_migrate() has dropped tdq 4's lock, added T to tdq 12
> >   with td_lock == &blocked_lock, dropped tdq 12's lock, and now spins in
> >   the final TDQ_LOCK(tdq) on tdq 4's lock.
> > - CPU 20: idle thread, tdq_idled() -> tdq_move(from = tdq 12, to = tdq 20).
> >   It holds the tdq 20 and tdq 12 locks and spins in
> >   thread_lock_block_wait(T).
> > - CPU 0: idle thread, statclock -> sched_clock -> sched_balance ->
> >   sched_balance_group -> sched_balance_pair -> tdq_lock_pair().
> >   It holds tdq 4's lock and spins on tdq 20's lock.
> > 
> > T's td_lock can be released only by cpu_switch() on CPU 4, which can run
> > only after CPU 4 gets tdq 4's lock.  So CPU 0 waits for CPU 20, CPU 20 waits
> > for T, and T waits for CPU 0.  Other CPUs then piled up on tdq 20's lock
> > (sched_add from sleepq_timeout) until one of them panicked.

This indeed can happen.
 
> > Ermal proposed to fix (avoid) the issue by not waiting in tdq_move() at all:
> > if the thread is still blocked, return -1, which all callers already handle,
> > since stealing is opportunistic.

Yes, but that decreases efficiency of the "try steal" and it looks like it can be fixed differently.
 
> I can open a review request if it would make discussing and reviewing easier.

In the patch below, `thread_lock_block_wait()` is now superfluous.

Except for trivial things, please always put up scheduler changes under review with the `#scheduler` group as a reviewer.

Thanks and regards.

-- 
Olivier Certner
--nextPart2531705.bDOn7JOVgO
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: This is a digitally signed message part.
Content-Transfer-Encoding: 7Bit

-----BEGIN PGP SIGNATURE-----

iQIzBAABCQAdFiEEmNCxHjkosai0LYIujKEwQJceJicFAmr0ZDgACgkQjKEwQJce
JieGaA/+LfOfkBuXuqFD5/wJ3PVfR/7GT3DO60GXvi9ev/a4UCgPn9VsMzlt931q
4dsaiBJATsV7cTu6pPw9XoHHJSZBGVLUOuIAbeq9XTjBmIZNYeJtBP0MfAxU0iDa
0wVAeopNWUYin/tvCnNjwDyOKLhILTv5dgWG/KDETO1Ax1YxjTq5NDhkdow66UA9
6Z2vJfSyqaqzFnY3yyKK+UNiRhJTvPOkxUjMuaxuYYu1qEbY4lFQvTeJpuZOcjuy
g7nwGZ5/eKSfcQpJmwqkhGdtaq5W9/1tElzoGO/nyZz3/iJtemADBdE651r0pnhh
RYv36SnuajJ0O1LGY7XAV1nKHWH/d2X3NVmPJIizZlijGKCZX3TQa6t052nSWiI/
mprJ2WZpFY61GGoWe4AZV+EJDku9xOi+sPJg+t8v3D0Jw9DOydG4Askiz6QROyjb
xKLzwcXmjzfz8EUL4a7zMT8lRNdhoFKktlJkT6PhJkSmG36n45qjKUrzTbq57jl8
71AvVdp1MM01+bRSkk02sU5Z0LxiNlwt/FexQNJZKgr0/D3EJGlTRpLOhATENns3
ins6fO8H6pbAK8Ifcn5+CuG5Kt/OJW8HV2xkmVnQldjUcQh6mTXxwI0BaOUQBogx
Q1TgyXuWaYjWTTDYyeuVhJEUdtk+G2T4tsj/iuShWkFqJSoyCXQ=
=P4zl
-----END PGP SIGNATURE-----

--nextPart2531705.bDOn7JOVgO--





--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-admin@muc.de
Re: ULE: run queue lock deadlock in sched_switch_migrate() + tdq_move()
#183
Author: Olivier Certner
Date: Wed, 11 Nov 2026 22:36
46 lines
3425 bytes
--nextPart4251773.p4y8TspHLy
Content-Transfer-Encoding: 7Bit
Content-Type: text/plain; charset="utf-8"; protected-headers="v1"
From: Olivier Certner <olce@freebsd.org>
Date: Wed, 11 Nov 2026 23:36:08 +0100
Message-ID: <4342686.O2WMGSuNBG@ravel>
In-Reply-To: <6612379.O1aUxXEVJ6@ravel>
MIME-Version: 1.0

Please see https://reviews.freebsd.org/D61448.

Regards.

-- 
Olivier Certner
--nextPart4251773.p4y8TspHLy
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: This is a digitally signed message part.
Content-Transfer-Encoding: 7Bit

-----BEGIN PGP SIGNATURE-----

iQIzBAABCQAdFiEEmNCxHjkosai0LYIujKEwQJceJicFAmr07dkACgkQjKEwQJce
JicbKxAAmN+j8XFgsxI628GtvYE1ARQ6Ve53CBCPnPcjYBvfSuZ/b8ne465zUVuJ
178NAy4JqwIhjNPDncg34jICZHHRc7tBfiuLRda4/A1WfDyZwqLMH31iDUdtG3BY
J4wemHcco0rHa/CbalHlDecxGx5P85w9ybCEyOe6aunqlgk/vCd31Q08KpihL+rJ
3OiYoynTwAo2ns1MYVjrT3WcRCPL/xAXE4idDNph4yJnNz8E6tJNCLWSc5vK+kEk
0qynmvgrF3ccvKxBpBBhfDWEWY/+RmoSOFP4+FkciNJccf31h6AYIL0my64JHXRz
ORu4tAz5ArEpuUqMdEGvGYypFS/LMn6sWgzttKkIKvNtO8aWfO1RNiYq6Nb3Pper
VoKZ78JMlklJrPnaYlY1I6LWtIkWREksoLSxgCx9cytI4hzEGN45+U81/Xns9+ML
UvqBXTXmbpxR/NCaSiXSYYC8jpDmWdttsXD4Du0ETgHnFnnbd1H/lcusMRY/DsAw
SmVVU/IgFNLx6mYtyEVZqo8cAx5cq87PZGvoIAYYYLNYpAshRNMVn4jRfwJYzHaf
g+sS1zvtfA9HxcQJiEX9VN+60864gnH/YYARo4QnG7NCzZyn/W3jHgne4oztee9O
XOp5hSVVrDXDZaQxrQ/I1AsUd+NaksUWthpUV4d04+IuHG5uA3o=
=ViHY
-----END PGP SIGNATURE-----

--nextPart4251773.p4y8TspHLy--





--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-admin@muc.de
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads