Right, fixed in v4 (patch 8/12): https://lore.kernel.org/bpf/[email protected]/
The reader no longer loads the vmlinux BTF itself. If it is not there yet, the reader queues a work item that calls bpf_load_btf_vmlinux(), and waits for the module's BTF to be published, for @gone, or for the load attempt to end without the BTF. MODULE_STATE_GOING sets @gone and wakes before it removes the file, so the drain no longer waits on a module load: in your cycle the reader returns -ENODEV, the drain completes, GOING returns, and the kworker's modprobe gets the rwsem once the writer is done. On the lock comment, you are right that the btf_module_mutex -> cand_cache_mutex edge is gone. v4 states what the separate lock does keep: btf_module_mutex, which the module notifier takes, is never taken under btf_vmlinux_lock. Jay
