Skip to content

DRAFT: kill giant - part 1 - #2399

Draft
opntr wants to merge 4 commits into
freebsd:mainfrom
opntr:op/kill-giant
Draft

DRAFT: kill giant - part 1#2399
opntr wants to merge 4 commits into
freebsd:mainfrom
opntr:op/kill-giant

Conversation

@opntr

@opntr opntr commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

No description provided.

Every Giant acquisition in this file is a bus topology lock: creating and
destroying VF children mutates the device tree, and pci_iov_config(),
pci_iov_delete() and the two ioctl paths all reach into it.  Use the handle
that says so.

No functional change: bus_topo_lock() is still &Giant today.  Converting the
callers is a prerequisite for giving the topology lock its own sx, which is
tracked in design/giant-removal-strategy.md.

Note for that later change: pci_iov_config() calls pause() for the 100 ms the
SR-IOV specification requires before VFs may be accessed, and does so with the
lock held.  Giant is silently dropped there today; an sx will not be, so the
lock will need to be dropped and retaken around the pause.  The region is
already protected by IOV_BUSY, so that is safe.

Signed-off-by: Oliver Pinter <oliver.pntr@gmail.com>
The Giant acquisition here wraps device_probe_and_attach(), which is a bus
topology operation.  Use the handle that says so.

No functional change: bus_topo_lock() is still &Giant today.

This file is not referenced by any files* entry, sys/modules Makefile or
kernel configuration, and it still includes headers that no longer exist
(machine/xen-os.h, machine/hypervisor.h, machine/xenbus.h).  It is converted
here only so that no bus topology use of Giant is left in the tree; it is
untested by construction and is a candidate for removal.

Signed-off-by: Oliver Pinter <oliver.pntr@gmail.com>
apei_pcie_handler() calls pci_find_dbsf(), which walks the device tree, so the
lock it takes is the bus topology lock.  Use the handle that says so, and
record why the fatal path deliberately runs without it: the machine is going
down and the handler may be running in a context that cannot block.

No functional change: bus_topo_lock() is still &Giant today.

Signed-off-by: Oliver Pinter <oliver.pntr@gmail.com>
The code has called bus_topo_lock() around DEVICE_SUSPEND and DEVICE_RESUME
for some time; only the comment still named Giant.

Signed-off-by: Oliver Pinter <oliver.pntr@gmail.com>
@opntr
opntr requested review from bsdimp and bsdjhb as code owners September 2, 2026 13:03
@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown

Thank you for taking the time to contribute to FreeBSD!

Some of files have special handling:

Important

@bsdimp @bsdjhb wants to review changes to sys/dev/pci

@opntr

opntr commented Sep 2, 2026

Copy link
Copy Markdown
Contributor Author

@bsdimp / @erikarn could you please take a look at it?

@opntr opntr changed the title kill giant - part 1 DRAFT: kill giant - part 1 Sep 2, 2026
@opntr
opntr marked this pull request as draft September 2, 2026 14:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant