diff --git a/deployment/nodefeaturerule/samples/nodefeaturerule-cpu.yaml b/deployment/nodefeaturerule/samples/nodefeaturerule-cpu.yaml index 22ace7b5a..10c88613a 100644 --- a/deployment/nodefeaturerule/samples/nodefeaturerule-cpu.yaml +++ b/deployment/nodefeaturerule/samples/nodefeaturerule-cpu.yaml @@ -41,6 +41,17 @@ spec: - "SSE42" - "SSSE3" + - name: "nfd built-in cpu-cpuid non-bool labels" + labelsTemplate: | + {{ range .cpu.cpuid }}cpu-cpuid.{{ .Name }}={{ .Value }} + {{ end }} + matchFeatures: + - feature: cpu.cpuid + matchName: + op: In + value: + - "AVX10_VERSION" + - name: "nfd built-in cpu-hardware_multithreading label" labelsTemplate: | {{ range .cpu.topology }}cpu-{{ .Name }}={{ .Value }} diff --git a/docs/usage/customization-guide.md b/docs/usage/customization-guide.md index 810c5b4ab..f4be9a701 100644 --- a/docs/usage/customization-guide.md +++ b/docs/usage/customization-guide.md @@ -959,6 +959,8 @@ The following features are available for matching: | ---------------- | ------------ | -------- | ---------- | ----------- | | **`cpu.cpuid`** | flag | | | Supported CPU capabilities | | | | **``** | | CPUID flag is present | +| | attribute | | | CPU capability attributes | +| | | **AVX10_VERSION** | int | AVX10 vector ISA version (if supported) | | **`cpu.cstate`** | attribute | | | Status of cstates in the intel_idle cpuidle driver | | | | **`enabled`** | bool | 'true' if cstates are set, otherwise 'false'. Does not exist of intel_idle driver is not active. | | **`cpu.model`** | attribute | | | CPU model related attributes | diff --git a/docs/usage/features.md b/docs/usage/features.md index afbe71c18..8a6486a45 100644 --- a/docs/usage/features.md +++ b/docs/usage/features.md @@ -47,6 +47,7 @@ feature.node.kubernetes.io/ = | Feature name | Value | Description | | ----------------------------------- | ------ | --------------------------------------------------------------------------- | | **`cpu-cpuid.`** | true | CPU capability is supported. **NOTE:** the capability might be supported but not enabled. | +| **`cpu-cpuid.`** | string | CPU attribute value | | **`cpu-hardware_multithreading`** | true | Hardware multithreading, such as Intel HTT, enabled (number of logical CPUs is greater than physical CPUs) | | **`cpu-coprocessor.nx_gzip`** | true | Nest Accelerator for GZIP is supported(Power). | | **`cpu-power.sst_bf.enabled`** | true | Intel SST-BF ([Intel Speed Select Technology][intel-sst] - Base frequency) enabled | @@ -123,6 +124,12 @@ configuration options to change the behavior. See the full list in [github.com/klauspost/cpuid][klauspost-cpuid]. +#### X86 CPUID attributes + +| Attribute | Description | +| ------------------ | ------------------------------------------------------- | +| AVX10_VERSION | AVX10 vector ISA version (if supported) | + #### Arm CPUID flags (partial list) | Flag | Description | diff --git a/source/cpu/cpu.go b/source/cpu/cpu.go index 37187457e..426f8f692 100644 --- a/source/cpu/cpu.go +++ b/source/cpu/cpu.go @@ -149,6 +149,9 @@ func (s *cpuSource) GetLabels() (source.FeatureLabels, error) { labels["cpuid."+f] = true } } + for f, v := range features.Attributes[CpuidFeature].Elements { + labels["cpuid."+f] = v + } // CPU model for k, v := range features.Attributes[Cpumodel].Elements { @@ -203,6 +206,9 @@ func (s *cpuSource) Discover() error { // Detect CPUID s.features.Flags[CpuidFeature] = nfdv1alpha1.NewFlagFeatures(getCpuidFlags()...) + if cpuidAttrs := getCpuidAttributes(); cpuidAttrs != nil { + s.features.Attributes[CpuidFeature] = nfdv1alpha1.NewAttributeFeatures(cpuidAttrs) + } // Detect CPU model s.features.Attributes[Cpumodel] = nfdv1alpha1.NewAttributeFeatures(getCPUModel()) diff --git a/source/cpu/cpuid_amd64.go b/source/cpu/cpuid_amd64.go index cdc635e72..bca590380 100644 --- a/source/cpu/cpuid_amd64.go +++ b/source/cpu/cpuid_amd64.go @@ -17,6 +17,8 @@ limitations under the License. package cpu import ( + "strconv" + "github.com/klauspost/cpuid/v2" ) @@ -24,3 +26,13 @@ import ( func getCpuidFlags() []string { return cpuid.CPU.FeatureSet() } + +func getCpuidAttributes() map[string]string { + ret := map[string]string{} + + if cpuid.CPU.AVX10Level > 0 { + ret["AVX10_VERSION"] = strconv.Itoa(int(cpuid.CPU.AVX10Level)) + } + + return ret +} diff --git a/source/cpu/cpuid_linux_arm.go b/source/cpu/cpuid_linux_arm.go index e01071f00..3b3e0e8a7 100644 --- a/source/cpu/cpuid_linux_arm.go +++ b/source/cpu/cpuid_linux_arm.go @@ -119,3 +119,5 @@ func getCpuidFlags() []string { } return r } + +func getCpuidAttributes() map[string]string { return nil } diff --git a/source/cpu/cpuid_linux_arm64.go b/source/cpu/cpuid_linux_arm64.go index c8d6a91a0..9f44a75eb 100644 --- a/source/cpu/cpuid_linux_arm64.go +++ b/source/cpu/cpuid_linux_arm64.go @@ -199,3 +199,5 @@ func getCpuidFlags() []string { } return r } + +func getCpuidAttributes() map[string]string { return nil } diff --git a/source/cpu/cpuid_linux_ppc64le.go b/source/cpu/cpuid_linux_ppc64le.go index 9466e74f2..503f2d407 100644 --- a/source/cpu/cpuid_linux_ppc64le.go +++ b/source/cpu/cpuid_linux_ppc64le.go @@ -153,3 +153,5 @@ func getCpuidFlags() []string { } return r } + +func getCpuidAttributes() map[string]string { return nil } diff --git a/source/cpu/cpuid_linux_s390x.go b/source/cpu/cpuid_linux_s390x.go index ab35c6b6b..33a67ae5d 100644 --- a/source/cpu/cpuid_linux_s390x.go +++ b/source/cpu/cpuid_linux_s390x.go @@ -95,3 +95,5 @@ func getCpuidFlags() []string { } return r } + +func getCpuidAttributes() map[string]string { return nil } diff --git a/source/cpu/cpuid_stub.go b/source/cpu/cpuid_stub.go index b512207c9..df6751cb4 100644 --- a/source/cpu/cpuid_stub.go +++ b/source/cpu/cpuid_stub.go @@ -20,3 +20,5 @@ limitations under the License. package cpu func getCpuidFlags() []string { return nil } + +func getCpuidAttributes() map[string]string { return nil }