Add optional KMM integration for OoT kernel module loading - #79
Conversation
72f70ab to
f6b068d
Compare
tkatila
left a comment
There was a problem hiding this comment.
Some comments related to the CRD changes. I think the Module CR is somewhat complex as it has same fields in different places and would like to not copy them as they are. If possible.
c2de30e to
a85526a
Compare
|
Thanks @abyrne55 for the changes! I'll try to use this on my end in the next couple of days. |
a85526a to
8e0e555
Compare
tkatila
left a comment
There was a problem hiding this comment.
Some notes from testing the in-cluster build.
Couple of things that I noticed:
- In Ubuntu, the worker image fails to set the firmware load path. I "workarounded" that by building a custom worker image where the user is 0 (not 201).
- I think I tried setting the worker config to use user 0, but that didn't help.
- In Ubuntu26.04, the kernel prevents unloading the in-tree xe as there are devices using it.
- By blacklisting the
xedriver, the initial loading works, but the problem surfaces again when trying to remove the ClusterPolicy (=removing the Module thus unloading the oot kmd). - I think this is noted here: https://github.com/kubernetes-sigs/kernel-module-management/blob/main/docs/enhancements/0005-modprobed-config.md
- By blacklisting the
|
For fun, tested how KMMO handles update from x->y version. Updated ClusterPolicy with a different versions, and KMMO built the new kmd container and updated the driver. Nice 👍 Though, this was with a slightly hacked KMMO container to allow unbinding in the worker container. |
|
Thank you for the thorough testing, @tkatila! See my replies above w.r.t. your inline comments. As for the remaining items:
Sounds like a potential CRI-O vs containerd difference in how privileged non-root containers get capabilities. I'll see if I can reproduce within OCP tomorrow and file an upstream bug as needed.
Indeed, this aligns with the RHEL/OCP behavior I mention at the bottom of the PR description. You're spot-on that the modprobed enhancement would allow us to tackle that. I'll try to get some timeline insight there. In the meantime, just want to confirm: this is what you've been doing as an unbinding workaround, yes? # Zero out VFs, if SR-IOV is active
echo 0 > /sys/bus/pci/devices/$GPU_PCI_ADDRESS/sriov_numvf
# Unbind PF(s)
echo $GPU_PCI_ADDRESS > /sys/bus/pci/drivers/xe/unbind |
Thanks. I'll try to reproduce the issue again and see if using the worker config fixes it. But I think my past experience was that it didn't fix it.
Yes, that's the gist of it. Or iterate over all the BDFs under the xe driver and unbind them. |
|
fyi, if you add this, the "Build all" check should start passing: |
|
Update on the Root cause for those curious: KMM seems to ignore the worker config UID whenever |
|
I tested the latest content and it seems fine. 👍 If you @abyrne55 rebase this to main and maybe squash/cleanup the commits a bit, we can merge this. After the merge, I think the overall KMM support needs a section to README (or maybe a page of its own). We need to mark down the current known limitations and limited support in the Xe OoT KMD. |
15f50b2 to
2b97ba5
Compare
tkatila
left a comment
There was a problem hiding this comment.
Something went wrong with the rebase. There are some reverts in the change set that shouldn't be there (codeql.yml, scorecard.yml, node-feature-rules-gpu.yaml etc.)
Adds a KMMReconciler sub-controller that creates a KMM Module CR (owned by the ClusterPolicy, with a ResourceClaim deletion guard) when ClusterPolicy.spec.kernelModule is set and KMM is installed. The existing DP and DRA controllers keep their lifecycle logic; KMM handles only out-of-tree module loading (modprobe, kernel mappings, in-cluster builds). KMM availability is detected at startup via API group discovery, and downstream DaemonSets (DP, DRA, XPU Manager) gate on the KMM ready node label so they schedule only once the OoT module is loaded. Behavior is unchanged when kernelModule is unset. Signed-off-by: Anthony Byrne <abyrne@redhat.com>
2b97ba5 to
874320c
Compare
|
Good catch @tkatila. Should be all set now 🚀 |
This PR adds a
KMMReconcilersub-controller that creates a KMMModuleCR when the newClusterPolicy.spec.kernelModulefield is set and KMM is installed. The existing DP and DRA controllers keep their lifecycle logic. KMM handles only out-of-tree kernel module loading (modprobe, kernel mappings, in-cluster builds).How it works
When
ClusterPolicy.spec.kernelModuleis set and KMM is installed in the cluster,KMMReconcilercreates a KMMModuleCR with amoduleLoaderspec. The Module CR is owned by the ClusterPolicy and garbage-collected on deletion. A deletion guard skips Module CR removal while GPU ResourceClaims are still allocated.KMM availability is detected at startup via API group discovery (
kmm.sigs.x-k8s.io), same pattern asDRAEnable. IfkernelModuleis set but KMM isn't installed, the operator reports an error in ClusterPolicy status. IfkernelModuleis nil, the sub-controller is a no-op.Downstream DaemonSets (DP, DRA, XPU Manager) are gated on the KMM ready node label (
kmm.node.kubernetes.io/<ns>.<module>.ready), so they only schedule once the OoT module is actually loaded on a node. WhenkernelModuleunset, however, their behavior is unchanged.Relationship to PR #59
#59 proposed replacing the native DP/DRA controllers entirely with KMM. Two controllers collapse into one, and gpu-base-operator stops managing DP/DRA DaemonSets, RBAC, SCCs, and DeviceClasses at runtime. That gives the biggest code reduction (~-3,100 lines) but makes KMM a hard dependency for all users.
This PR takes a more conservative approach: the native controllers stay in place for DP/DRA lifecycle, and a new
KMMReconcilerruns alongside them solely for OoT kernel module management. KMM is never required, and clusters using in-tree drivers work exactly as before. The trade-off is more total code (+2,456 / -51 lines across 30 files).kernelModuleAPIkernelMappingsmust contain at least 1 entry. Minimal usage: one OoT driver image matched to all kernels:More realistic usage: different images per kernel version
In-cluster build mode: useful when driver source is available but pre-built images don't exist for every kernel version in the fleet. KMM checks the target registry first and only triggers a build if the image is missing.
The
dockerfileConfigMapreferences a ConfigMap containing the Dockerfile.buildArgsare passed as build arguments, andsecretsare mounted during the build (e.g., for private source repos). Registry auth should usepullSecreton ClusterPolicySpec instead.Fields
moduleNamexe.versionkernelMappings[].regexpkernelMappings[].containerImagekernelMappings[].inTreeModulesToRemovemoduleNameis prepended automatically.inTreeModulesToRemove(container level)[moduleName]by the controller — the in-tree module is always unloaded before OoT insertion.modulesLoadingOrdermoduleName, >=2 entries). Passed through as-is.firmwarePathModprobeSpec.FirmwarePath).registryTLSinsecure,insecureSkipTLSVerify) for the OoT image registry. Settable at top level and per mapping.What's included
KernelModuleSpec/KernelMappingSpec/RegistryTLSSpecCRD types with DeepCopyKMMReconcilersub-controller withCreateOrPatch, owner references, and deletion guardmoduleNamedefaulting forkernelModulemodulesverbs) in the operator ClusterRolekernelModuleconfigurationTest results
Latest end-to-end run on OCP 4.22.9 SNO, 2× Intel BMG-G31 (Battlemage, PCI
8086:e223), kernel5.14.0-687.35.1.el9_8.x86_64, KMM v2.7.0 + NFD pre-installed:xe(kmmStatus: 1/1); ready label gated DP/DRA/XPU until load; DRA driver + XPU Manager1/1; ResourceSlice populated with both GPUs; DRA isolation test passed (/dev/dri/present in claimed container, absent otherwise); status errors cleared once healthymoduleNamedefaults toxe;regexprequired (webhook-enforced)Corroborating results from earlier runs (OCP 4.22.2, Arc Pro B70 with SR-IOV VFs):
kmmStatus: N/A, clean deletiongpu.intel.com/xe=8registered, GPU workload OKKnown limitations
xecan't unload with active VFs.modprobe -rvcannot unloadxewhile SR-IOV VFs are active. KMM is adding modprobe.d support (kubernetes-sigs/kernel-module-management#1324) that could work around this in the future.This PR was written in part with the assistance of generative AI.