Skip to content

Commit 311eaf8

Browse files
committed
cpu: advertise AVX10 version
Add new cpuid label "feature.node.kubernetes.io/cpu-cpuid.AVX10_VERSION" that advertises the supported version of AVX10 vector ISA. Correspondingly, the patch adds AVX10_VERSION to the "cpu.cpuid" feature for NodeFeatureRules to consume. This makes cpu.cpuid on amd64 architecture a "multi-type" feature in that it contains "flags" and potentially also "attributes" (the only cpuid attribute so far is the AVX10_VERSION).
1 parent ca13b49 commit 311eaf8

10 files changed

+48
-0
lines changed

deployment/nodefeaturerule/samples/nodefeaturerule-cpu.yaml

+11
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,17 @@ spec:
4141
- "SSE42"
4242
- "SSSE3"
4343

44+
- name: "nfd built-in cpu-cpuid non-bool labels"
45+
labelsTemplate: |
46+
{{ range .cpu.cpuid }}cpu-cpuid.{{ .Name }}={{ .Value }}
47+
{{ end }}
48+
matchFeatures:
49+
- feature: cpu.cpuid
50+
matchName:
51+
op: In
52+
value:
53+
- "AVX10_VERSION"
54+
4455
- name: "nfd built-in cpu-hardware_multithreading label"
4556
labelsTemplate: |
4657
{{ range .cpu.topology }}cpu-{{ .Name }}={{ .Value }}

docs/usage/customization-guide.md

+2
Original file line numberDiff line numberDiff line change
@@ -916,6 +916,8 @@ The following features are available for matching:
916916
| ---------------- | ------------ | -------- | ---------- | ----------- |
917917
| **`cpu.cpuid`** | flag | | | Supported CPU capabilities |
918918
| | | **`<cpuid-flag>`** | | CPUID flag is present |
919+
| | attribute | | | CPU capability attributes |
920+
| | | **AVX10_VERSION** | int | AVX10 vector ISA version (if supported) |
919921
| **`cpu.cstate`** | attribute | | | Status of cstates in the intel_idle cpuidle driver |
920922
| | | **`enabled`** | bool | 'true' if cstates are set, otherwise 'false'. Does not exist of intel_idle driver is not active. |
921923
| **`cpu.model`** | attribute | | | CPU model related attributes |

docs/usage/features.md

+7
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ feature.node.kubernetes.io/<feature> = <value>
4747
| Feature name | Value | Description |
4848
| ----------------------------------- | ------ | --------------------------------------------------------------------------- |
4949
| **`cpu-cpuid.<cpuid-flag>`** | true | CPU capability is supported. **NOTE:** the capability might be supported but not enabled. |
50+
| **`cpu-cpuid.<cpuid-attribute>`** | string | CPU attribute value |
5051
| **`cpu-hardware_multithreading`** | true | Hardware multithreading, such as Intel HTT, enabled (number of logical CPUs is greater than physical CPUs) |
5152
| **`cpu-coprocessor.nx_gzip`** | true | Nest Accelerator for GZIP is supported(Power). |
5253
| **`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.
123124

124125
See the full list in [github.com/klauspost/cpuid][klauspost-cpuid].
125126

127+
#### X86 CPUID attributes
128+
129+
| Attribute | Description |
130+
| ------------------ | ------------------------------------------------------- |
131+
| AVX10_VERSION | AVX10 vector ISA version (if supported) |
132+
126133
#### Arm CPUID flags (partial list)
127134

128135
| Flag | Description |

source/cpu/cpu.go

+6
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,9 @@ func (s *cpuSource) GetLabels() (source.FeatureLabels, error) {
149149
labels["cpuid."+f] = true
150150
}
151151
}
152+
for f, v := range features.Attributes[CpuidFeature].Elements {
153+
labels["cpuid."+f] = v
154+
}
152155

153156
// CPU model
154157
for k, v := range features.Attributes[Cpumodel].Elements {
@@ -203,6 +206,9 @@ func (s *cpuSource) Discover() error {
203206

204207
// Detect CPUID
205208
s.features.Flags[CpuidFeature] = nfdv1alpha1.NewFlagFeatures(getCpuidFlags()...)
209+
if cpuidAttrs := getCpuidAttributes(); cpuidAttrs != nil {
210+
s.features.Attributes[CpuidFeature] = nfdv1alpha1.NewAttributeFeatures(cpuidAttrs)
211+
}
206212

207213
// Detect CPU model
208214
s.features.Attributes[Cpumodel] = nfdv1alpha1.NewAttributeFeatures(getCPUModel())

source/cpu/cpuid_amd64.go

+12
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,22 @@ limitations under the License.
1717
package cpu
1818

1919
import (
20+
"strconv"
21+
2022
"github.com/klauspost/cpuid/v2"
2123
)
2224

2325
// getCpuidFlags returns feature names for all the supported CPU features.
2426
func getCpuidFlags() []string {
2527
return cpuid.CPU.FeatureSet()
2628
}
29+
30+
func getCpuidAttributes() map[string]string {
31+
ret := map[string]string{}
32+
33+
if cpuid.CPU.AVX10Level > 0 {
34+
ret["AVX10_VERSION"] = strconv.Itoa(int(cpuid.CPU.AVX10Level))
35+
}
36+
37+
return ret
38+
}

source/cpu/cpuid_linux_arm.go

+2
Original file line numberDiff line numberDiff line change
@@ -119,3 +119,5 @@ func getCpuidFlags() []string {
119119
}
120120
return r
121121
}
122+
123+
func getCpuidAttributes() map[string]string { return nil }

source/cpu/cpuid_linux_arm64.go

+2
Original file line numberDiff line numberDiff line change
@@ -199,3 +199,5 @@ func getCpuidFlags() []string {
199199
}
200200
return r
201201
}
202+
203+
func getCpuidAttributes() map[string]string { return nil }

source/cpu/cpuid_linux_ppc64le.go

+2
Original file line numberDiff line numberDiff line change
@@ -153,3 +153,5 @@ func getCpuidFlags() []string {
153153
}
154154
return r
155155
}
156+
157+
func getCpuidAttributes() map[string]string { return nil }

source/cpu/cpuid_linux_s390x.go

+2
Original file line numberDiff line numberDiff line change
@@ -95,3 +95,5 @@ func getCpuidFlags() []string {
9595
}
9696
return r
9797
}
98+
99+
func getCpuidAttributes() map[string]string { return nil }

source/cpu/cpuid_stub.go

+2
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,5 @@ limitations under the License.
2020
package cpu
2121

2222
func getCpuidFlags() []string { return nil }
23+
24+
func getCpuidAttributes() map[string]string { return nil }

0 commit comments

Comments
 (0)