Skip to content

vms-ff7 (P4-A): lock manager compiled into the NetBSD vms module — real exec_rbtree backend - #482

Merged
baron-3dl merged 1 commit into
mainfrom
vms-ff7-netbsd-locks
Aug 13, 2026
Merged

baron-3dl merged 1 commit into
mainfrom
vms-ff7-netbsd-locks

Conversation

@baron-3dl

Copy link
Copy Markdown
Contributor

Completes the NetBSD executive backend set (last facility, epic vms-8e8 P4-A) → unblocks the executive-on-VAX compile (B1, vms-20b9).

What

src/kernel-core/vms_lock.c — the shared distributed lock manager ($ENQ/$DEQ/$CONVERT/$GETLKI + DLM directory/mastering) — now compiles into the OVMX/NetBSD vms pseudo-device from the same source the Linux vms.ko runs. One facility, two substrates (INV-DRIFT); Linux behaviour untouched.

The real exec_rbtree NetBSD backend (the main new work)

vms_lock.c is the sole exec_rbtree consumer (its lock-ID tree) and drives a low-level, caller-descended contract (exec_rb_left/right + exec_rb_link_node/insert_color/erase) that NetBSD rb_tree(3)'s comparator API cannot back (design record §5 #2). So exec_rbtree_netbsd.c ships OVMX's own textbook red-black tree — the analogue of exec_list_netbsd.c / exec_hash_netbsd.c — with the packed parent+colour node the contract exposes.

Validated against a 4000-element random insert/erase stress harness: all red-black invariants (parent links, no red-red, equal black-height, BST order, root black) held through full deletion to empty.

Wiring (NetBSD backend only)

  • vms_lock_nb.h — DLM wire contract: LCK_K_*/LCK_M_*, LCK_VALBLK_SIZE, four arg structs (all _IOWR, ≤104 B → no IOC_VOID big-io), request numbers byte-identical to Linux (V, NR 0x30–0x34), size asserts.
  • vms_internal.h twinstruct vms_lock_entry/resource in exec_* vocabulary, proc lock fields, VMS_RES_HASH_BITS, lock SS$ codes, extern vms_local_csid, prototypes; includes exec_rbtree.h.
  • vms_netbsd.c — defines vms_local_csid (glue, =1, as Linux vms_module.c); brings up/tears down proc lock fields; vms_proc_release_locks at proc death; vms_lock_init/cleanup in module lifecycle (cleanup frees entries, so proctab_teardown only destroys the guard — the eflag asymmetry); dispatches the five lock ioctls; drops the now-real weak rundown_locks stub.
  • Makefile + crosscompile.sh — add vms_lock.c + exec_rbtree_netbsd.c to SRCS.

Verification

Per-PR gate "NetBSD/amd64 vms module cross-compiles" reproduced locally in a clang container against the pinned NetBSD/amd64 kernel headers: 10 TUs compile -Werror and relocatable-link clean (no dangling exec_rbtree_*/exec_*, no duplicate); negctl fails as it must. Lock logic not duplicated (only kernel-core/vms_lock.c); new .c lives in src/kernel-netbsd/ (excluded from the userspace_service_register host-compile, per the V3 gotcha).

🤖 Generated with Claude Code

…al exec_rbtree backend, COMPLETES the NetBSD executive set

The LAST NetBSD executive facility. src/kernel-core/vms_lock.c (the shared DLM:
$ENQ/$DEQ/$CONVERT/$GETLKI + directory/mastering) now compiles into the OVMX/
NetBSD `vms' pseudo-device from the SAME source the Linux vms.ko runs — one
facility, two substrates (INV-DRIFT). With every facility now runnable on
NetBSD, this unblocks the executive-on-VAX compile (B1, vms-20b9).

The main new work is the real exec_rbtree NetBSD backend. vms_lock.c is the sole
exec_rbtree consumer (its lock-ID tree) and drives a LOW-LEVEL, caller-descended
contract (exec_rb_left/right + exec_rb_link_node/insert_color/erase) that NetBSD
rb_tree(3)'s comparator API cannot back (design record §5 #2), so
exec_rbtree_netbsd.c ships OVMX's OWN textbook red-black tree — the analogue of
exec_list_netbsd.c / exec_hash_netbsd.c — with the packed parent+colour node the
contract exposes. Verified against a 4000-element random insert/erase stress
harness: all red-black invariants (parent links, no red-red, equal black-height,
BST order, root black) held through full deletion to empty.

Wiring (NetBSD backend only; Linux untouched):
- vms_lock_nb.h: the DLM wire contract — LCK_K_*/LCK_M_* modes+flags,
  LCK_VALBLK_SIZE, the four arg structs (all _IOWR, <=104B — no IOC_VOID big-io),
  request numbers byte-identical to Linux (magic 'V', NR 0x30-0x34), size asserts.
- vms_internal.h twin: struct vms_lock_entry/resource in exec_* vocabulary, the
  proc lock fields (locks/lock_count/lock_list_lock), VMS_RES_HASH_BITS, the lock
  SS$ codes, extern vms_local_csid, facility prototypes; includes exec_rbtree.h.
- vms_netbsd.c: defines vms_local_csid (glue, =1, as Linux vms_module.c);
  brings up/tears down the lock proc fields; calls vms_proc_release_locks at proc
  death and vms_lock_init/cleanup in the module lifecycle (cleanup frees the
  entries, so proctab_teardown only destroys the guard — the eflag asymmetry);
  dispatches the five lock ioctls; drops the now-real weak rundown_locks stub.
- Makefile + crosscompile.sh: add vms_lock.c + exec_rbtree_netbsd.c to SRCS.

Per-PR gate reproduced locally in a clang container against the pinned NetBSD/
amd64 kernel headers: 10 TUs compile -Werror and relocatable-link clean (no
dangling exec_rbtree_*/exec_* symbol, no duplicate); negctl fails as it must.
Lock logic is not duplicated (only kernel-core/vms_lock.c); the new .c lives in
src/kernel-netbsd/ (excluded from the userspace_service_register host-compile).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@baron-3dl
baron-3dl merged commit 892b84c into main Aug 13, 2026
66 checks passed
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