mirror of
https://github.com/kubernetes-sigs/node-feature-discovery.git
synced 2024-12-14 11:57:51 +00:00
sources: move all cpu related features under the cpu source
Remove 'cpuid', 'pstate' and 'rdt' feature sources and move their functionality under the 'cpu' source. The goal is to have a more systematic organization of feature sources and labels. After this change we now basically have one source per type of hw, one for kernel and one for userspace sw. Related feature labels are changed, correspondingly, new labels being: feature.node.k8s.io/cpu-cpuid.<cpuid flag> feature.node.k8s.io/cpu-pstate.turbo feature.node.k8s.io/cpu-rdt.<rdt feature>
This commit is contained in:
parent
5b73e271ba
commit
655f5c5555
14 changed files with 86 additions and 180 deletions
102
README.md
102
README.md
|
@ -124,7 +124,7 @@ nfd-worker.
|
|||
in testing
|
||||
[Default: ]
|
||||
--sources=<sources> Comma separated list of feature sources.
|
||||
[Default: cpu,cpuid,iommu,kernel,local,memory,network,pci,pstate,rdt,storage,system]
|
||||
[Default: cpu,iommu,kernel,local,memory,network,pci,storage,system]
|
||||
--no-publish Do not publish discovered features to the
|
||||
cluster-local Kubernetes API server.
|
||||
--label-whitelist=<pattern> Regular expression to filter label names to
|
||||
|
@ -149,14 +149,11 @@ for up-to-date information about the required volume mounts.
|
|||
The current set of feature sources are the following:
|
||||
|
||||
- CPU
|
||||
- [CPUID][cpuid] for x86/Arm64 CPU details
|
||||
- IOMMU
|
||||
- Kernel
|
||||
- Memory
|
||||
- Network
|
||||
- PCI
|
||||
- Pstate ([Intel P-State driver][intel-pstate])
|
||||
- RDT ([Intel Resource Director Technology][intel-rdt])
|
||||
- Storage
|
||||
- System
|
||||
- Local (hooks for user-specific features)
|
||||
|
@ -166,9 +163,9 @@ The current set of feature sources are the following:
|
|||
The published node labels encode a few pieces of information:
|
||||
|
||||
- Namespace, i.e. `feature.node.kubernetes.io`
|
||||
- The source for each label (e.g. `cpuid`).
|
||||
- The source for each label (e.g. `cpu`).
|
||||
- The name of the discovered feature as it appears in the underlying
|
||||
source, (e.g. `AESNI` from cpuid).
|
||||
source, (e.g. `cpuid.AESNI` from cpu).
|
||||
- The value of the discovered feature.
|
||||
|
||||
Feature label names adhere to the following pattern:
|
||||
|
@ -185,14 +182,11 @@ the only label value published for features is the string `"true"`._
|
|||
```json
|
||||
{
|
||||
"feature.node.kubernetes.io/cpu-<feature-name>": "true",
|
||||
"feature.node.kubernetes.io/cpuid-<feature-name>": "true",
|
||||
"feature.node.kubernetes.io/iommu-<feature-name>": "true",
|
||||
"feature.node.kubernetes.io/kernel-<feature name>": "<feature value>",
|
||||
"feature.node.kubernetes.io/memory-<feature-name>": "true",
|
||||
"feature.node.kubernetes.io/network-<feature-name>": "true",
|
||||
"feature.node.kubernetes.io/pci-<device label>.present": "true",
|
||||
"feature.node.kubernetes.io/pstate-<feature-name>": "true",
|
||||
"feature.node.kubernetes.io/rdt-<feature-name>": "true",
|
||||
"feature.node.kubernetes.io/storage-<feature-name>": "true",
|
||||
"feature.node.kubernetes.io/system-<feature name>": "<feature value>",
|
||||
"feature.node.kubernetes.io/<file name>-<feature name>": "<feature value>"
|
||||
|
@ -208,43 +202,50 @@ such as restricting discovered features with the --label-whitelist option._
|
|||
|
||||
### CPU Features
|
||||
|
||||
The CPU feature source differs from the CPUID feature source in that it
|
||||
discovers CPU related features that are actually enabled, whereas CPUID only
|
||||
reports *supported* CPU capabilities (i.e. a capability might be supported but
|
||||
not enabled) as reported by the `cpuid` instruction.
|
||||
| Feature name | Attribute | Description |
|
||||
| ----------------------- | ------------------ | ----------------------------- |
|
||||
| cpuid | <cpuid flag> | CPU capability is supported
|
||||
| hardware_multithreading | <br> | Hardware multithreading, such as Intel HTT, enabled (number of locical CPUs is greater than physical CPUs)
|
||||
| power | sst_bf.enabled | Intel SST-BF ([Intel Speed Select Technology][intel-sst] - Base frequency) enabled
|
||||
| [pstate][intel-pstate] | turbo | Turbo frequencies are enabled in Intel pstate driver
|
||||
| [rdt][intel-rdt] | RDTMON | Intel RDT Monitoring Technology
|
||||
| <br> | RDTCMT | Intel Cache Monitoring (CMT)
|
||||
| <br> | RDTMBM | Intel Memory Bandwidth Monitoring (MBM)
|
||||
| <br> | RDTL3CA | Intel L3 Cache Allocation Technology
|
||||
| <br> | RDTL2CA | Intel L2 Cache Allocation Technology
|
||||
| <br> | RDTMBA | Intel Memory Bandwidth Allocation (MBA) Technology
|
||||
|
||||
| Feature | Attribute | Description |
|
||||
| ----------------------- | -------------- | ----------------------------------|
|
||||
| hardware_multithreading | <br> | Hardware multithreading, such as Intel HTT, enabled (number of locical CPUs is greater than physical CPUs)
|
||||
| power | sst_bf.enabled | Intel SST-BF ([Intel Speed Select Technology][intel-sst] - Base frequency) enabled
|
||||
**NOTE** The cpuid features advertise *supported* CPU capabilities, that is, a
|
||||
capability might be supported but not enabled.
|
||||
|
||||
### X86 CPUID Features (Partial List)
|
||||
|
||||
| Feature name | Description |
|
||||
| :------------: | :----------------------------------------------------------: |
|
||||
| ADX | Multi-Precision Add-Carry Instruction Extensions (ADX)
|
||||
| AESNI | Advanced Encryption Standard (AES) New Instructions (AES-NI)
|
||||
| AVX | Advanced Vector Extensions (AVX)
|
||||
| AVX2 | Advanced Vector Extensions 2 (AVX2)
|
||||
| BMI1 | Bit Manipulation Instruction Set 1 (BMI)
|
||||
| BMI2 | Bit Manipulation Instruction Set 2 (BMI2)
|
||||
| SSE4.1 | Streaming SIMD Extensions 4.1 (SSE4.1)
|
||||
| SSE4.2 | Streaming SIMD Extensions 4.2 (SSE4.2)
|
||||
| SGX | Software Guard Extensions (SGX)
|
||||
#### X86 CPUID Attributes (Partial List)
|
||||
|
||||
### Arm64 CPUID Features (Partial List)
|
||||
| Attribute | Description |
|
||||
| --------- | ---------------------------------------------------------------- |
|
||||
| ADX | Multi-Precision Add-Carry Instruction Extensions (ADX)
|
||||
| AESNI | Advanced Encryption Standard (AES) New Instructions (AES-NI)
|
||||
| AVX | Advanced Vector Extensions (AVX)
|
||||
| AVX2 | Advanced Vector Extensions 2 (AVX2)
|
||||
| BMI1 | Bit Manipulation Instruction Set 1 (BMI)
|
||||
| BMI2 | Bit Manipulation Instruction Set 2 (BMI2)
|
||||
| SSE4.1 | Streaming SIMD Extensions 4.1 (SSE4.1)
|
||||
| SSE4.2 | Streaming SIMD Extensions 4.2 (SSE4.2)
|
||||
| SGX | Software Guard Extensions (SGX)
|
||||
|
||||
| Feature name | Description |
|
||||
| :------------: | :----------------------------------------------------------: |
|
||||
| AES | Announcing the Advanced Encryption Standard
|
||||
| EVSTRM | Event Stream Frequency Features
|
||||
| FPHP | Half Precision(16bit) Floating Point Data Processing Instructions
|
||||
| ASIMDHP | Half Precision(16bit) Asimd Data Processing Instructions
|
||||
| ATOMICS | Atomic Instructions to the A64
|
||||
| ASIMRDM | Support for Rounding Double Multiply Add/Subtract
|
||||
| PMULL | Optional Cryptographic and CRC32 Instructions
|
||||
| JSCVT | Perform Conversion to Match Javascript
|
||||
| DCPOP | Persistent Memory Support
|
||||
#### Arm64 CPUID Attribute (Partial List)
|
||||
|
||||
| Attribute | Description |
|
||||
| --------- | ---------------------------------------------------------------- |
|
||||
| AES | Announcing the Advanced Encryption Standard
|
||||
| EVSTRM | Event Stream Frequency Features
|
||||
| FPHP | Half Precision(16bit) Floating Point Data Processing Instructions
|
||||
| ASIMDHP | Half Precision(16bit) Asimd Data Processing Instructions
|
||||
| ATOMICS | Atomic Instructions to the A64
|
||||
| ASIMRDM | Support for Rounding Double Multiply Add/Subtract
|
||||
| PMULL | Optional Cryptographic and CRC32 Instructions
|
||||
| JSCVT | Perform Conversion to Match Javascript
|
||||
| DCPOP | Persistent Memory Support
|
||||
|
||||
### IOMMU Features
|
||||
|
||||
|
@ -267,12 +268,6 @@ Kernel config file to use, and, the set of config options to be detected are
|
|||
configurable.
|
||||
See [configuration options](#configuration-options) for more information.
|
||||
|
||||
### P-State Features
|
||||
|
||||
| Feature name | Description |
|
||||
| :----------: | ------------------------------------------------------------- |
|
||||
| turbo | Turbo frequencies are enabled in Intel pstate driver
|
||||
|
||||
### Memory Features
|
||||
|
||||
| Feature | Attribute | Description |
|
||||
|
@ -309,17 +304,6 @@ GPUs, co-processors and accelerator cards are detected.
|
|||
See [configuration options](#configuration-options)
|
||||
for more information on NFD config.
|
||||
|
||||
### RDT (Intel Resource Director Technology) Features
|
||||
|
||||
| Feature name | Description |
|
||||
| :------------: | :---------------------------------------------------------------------------------: |
|
||||
| RDTMON | Intel RDT Monitoring Technology
|
||||
| RDTCMT | Intel Cache Monitoring (CMT)
|
||||
| RDTMBM | Intel Memory Bandwidth Monitoring (MBM)
|
||||
| RDTL3CA | Intel L3 Cache Allocation Technology
|
||||
| RDTL2CA | Intel L2 Cache Allocation Technology
|
||||
| RDTMBA | Intel Memory Bandwidth Allocation (MBA) Technology
|
||||
|
||||
### Storage Features
|
||||
|
||||
| Feature name | Description |
|
||||
|
@ -629,7 +613,7 @@ spec:
|
|||
- image: golang
|
||||
name: go1
|
||||
nodeSelector:
|
||||
feature.node.kubernetes.io/pstate-turbo: 'true'
|
||||
feature.node.kubernetes.io/cpu-pstate.turbo: 'true'
|
||||
```
|
||||
|
||||
For more details on targeting nodes, see [node selection][node-sel].
|
||||
|
|
|
@ -91,7 +91,7 @@ func argsParse(argv []string) (worker.Args, error) {
|
|||
in testing
|
||||
[Default: ]
|
||||
--sources=<sources> Comma separated list of feature sources.
|
||||
[Default: cpu,cpuid,iommu,kernel,local,memory,network,pci,pstate,rdt,storage,system]
|
||||
[Default: cpu,iommu,kernel,local,memory,network,pci,storage,system]
|
||||
--no-publish Do not publish discovered features to the
|
||||
cluster-local Kubernetes API server.
|
||||
--label-whitelist=<pattern> Regular expression to filter label names to
|
||||
|
|
|
@ -32,7 +32,7 @@ func TestArgsParse(t *testing.T) {
|
|||
So(args.SleepInterval, ShouldEqual, 60*time.Second)
|
||||
So(args.NoPublish, ShouldBeTrue)
|
||||
So(args.Oneshot, ShouldBeTrue)
|
||||
So(args.Sources, ShouldResemble, []string{"cpu", "cpuid", "iommu", "kernel", "local", "memory", "network", "pci", "pstate", "rdt", "storage", "system"})
|
||||
So(args.Sources, ShouldResemble, []string{"cpu", "iommu", "kernel", "local", "memory", "network", "pci", "storage", "system"})
|
||||
So(len(args.LabelWhiteList), ShouldEqual, 0)
|
||||
So(err, ShouldBeNil)
|
||||
})
|
||||
|
@ -56,7 +56,7 @@ func TestArgsParse(t *testing.T) {
|
|||
|
||||
Convey("args.labelWhiteList is set to appropriate value and args.sources is set to default value", func() {
|
||||
So(args.NoPublish, ShouldBeFalse)
|
||||
So(args.Sources, ShouldResemble, []string{"cpu", "cpuid", "iommu", "kernel", "local", "memory", "network", "pci", "pstate", "rdt", "storage", "system"})
|
||||
So(args.Sources, ShouldResemble, []string{"cpu", "iommu", "kernel", "local", "memory", "network", "pci", "storage", "system"})
|
||||
So(args.LabelWhiteList, ShouldResemble, ".*rdt.*")
|
||||
So(err, ShouldBeNil)
|
||||
})
|
||||
|
|
|
@ -11,7 +11,7 @@ metadata:
|
|||
{
|
||||
"matchExpressions": [
|
||||
{
|
||||
"key": "feature.node.kubernetes.io/pstate-turbo",
|
||||
"key": "feature.node.kubernetes.io/cpu-pstate.turbo",
|
||||
"operator": "DoesNotExist"
|
||||
}
|
||||
]
|
||||
|
|
|
@ -10,5 +10,5 @@ spec:
|
|||
- containerPort: 3351
|
||||
hostPort: 10001
|
||||
nodeSelector:
|
||||
feature.node.kubernetes.io/pstate-turbo: 'true'
|
||||
feature.node.kubernetes.io/cpu-pstate.turbo: 'true'
|
||||
restartPolicy: Never
|
||||
|
|
|
@ -36,7 +36,6 @@ import (
|
|||
"sigs.k8s.io/node-feature-discovery/pkg/version"
|
||||
"sigs.k8s.io/node-feature-discovery/source"
|
||||
"sigs.k8s.io/node-feature-discovery/source/cpu"
|
||||
"sigs.k8s.io/node-feature-discovery/source/cpuid"
|
||||
"sigs.k8s.io/node-feature-discovery/source/fake"
|
||||
"sigs.k8s.io/node-feature-discovery/source/iommu"
|
||||
"sigs.k8s.io/node-feature-discovery/source/kernel"
|
||||
|
@ -45,8 +44,6 @@ import (
|
|||
"sigs.k8s.io/node-feature-discovery/source/network"
|
||||
"sigs.k8s.io/node-feature-discovery/source/panic_fake"
|
||||
"sigs.k8s.io/node-feature-discovery/source/pci"
|
||||
"sigs.k8s.io/node-feature-discovery/source/pstate"
|
||||
"sigs.k8s.io/node-feature-discovery/source/rdt"
|
||||
"sigs.k8s.io/node-feature-discovery/source/storage"
|
||||
"sigs.k8s.io/node-feature-discovery/source/system"
|
||||
)
|
||||
|
@ -235,7 +232,6 @@ func configureParameters(sourcesWhiteList []string, labelWhiteListStr string) (e
|
|||
// Configure feature sources.
|
||||
allSources := []source.FeatureSource{
|
||||
cpu.Source{},
|
||||
cpuid.Source{},
|
||||
fake.Source{},
|
||||
iommu.Source{},
|
||||
kernel.Source{},
|
||||
|
@ -243,8 +239,6 @@ func configureParameters(sourcesWhiteList []string, labelWhiteListStr string) (e
|
|||
network.Source{},
|
||||
panic_fake.Source{},
|
||||
pci.Source{},
|
||||
pstate.Source{},
|
||||
rdt.Source{},
|
||||
storage.Source{},
|
||||
system.Source{},
|
||||
// local needs to be the last source so that it is able to override
|
||||
|
|
|
@ -52,6 +52,26 @@ func (s Source) Discover() (source.Features, error) {
|
|||
features["power.sst_bf.enabled"] = true
|
||||
}
|
||||
|
||||
// Detect CPUID
|
||||
cpuidFlags := getCpuidFlags()
|
||||
for _, f := range cpuidFlags {
|
||||
features["cpuid."+f] = true
|
||||
}
|
||||
|
||||
// Detect turbo boost
|
||||
turbo, err := turboEnabled()
|
||||
if err != nil {
|
||||
log.Printf("ERROR: %v", err)
|
||||
} else if turbo {
|
||||
features["pstate.turbo"] = true
|
||||
}
|
||||
|
||||
// Detect RDT features
|
||||
rdt := discoverRDT()
|
||||
for _, f := range rdt {
|
||||
features["rdt."+f] = true
|
||||
}
|
||||
|
||||
return features, nil
|
||||
}
|
||||
|
||||
|
|
|
@ -14,10 +14,13 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
package cpuid
|
||||
package cpu
|
||||
|
||||
// Source implements FeatureSource.
|
||||
type Source struct{}
|
||||
import (
|
||||
"github.com/klauspost/cpuid"
|
||||
)
|
||||
|
||||
// Name returns an identifier string for this feature source.
|
||||
func (s Source) Name() string { return "cpuid" }
|
||||
// Discover returns feature names for all the supported CPU features.
|
||||
func getCpuidFlags() []string {
|
||||
return cpuid.CPU.Features.Strings()
|
||||
}
|
|
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
package cpuid
|
||||
package cpu
|
||||
|
||||
/*
|
||||
#include <sys/auxv.h>
|
||||
|
@ -84,7 +84,7 @@ var flagNames_arm64 = map[uint64]string{
|
|||
CPU_ARM64_FEATURE_SVE: "SVE",
|
||||
}
|
||||
|
||||
func getFeaturesFromHWCAP() []string {
|
||||
func getCpuidFlags() []string {
|
||||
r := make([]string, 0, 20)
|
||||
hwcap := uint64(C.gethwcap())
|
||||
for i := uint(0); i < 64; i++ {
|
||||
|
@ -96,15 +96,3 @@ func getFeaturesFromHWCAP() []string {
|
|||
}
|
||||
return r
|
||||
}
|
||||
|
||||
// Discover returns feature names for all the supported CPU features.
|
||||
func (s Source) Discover() (source.Features, error) {
|
||||
// Get the cpu features as strings
|
||||
features := source.Features{}
|
||||
|
||||
for _, f := range getFeaturesFromHWCAP() {
|
||||
features[f] = true
|
||||
}
|
||||
|
||||
return features, nil
|
||||
}
|
|
@ -14,42 +14,31 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
package pstate
|
||||
package cpu
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"runtime"
|
||||
|
||||
"sigs.k8s.io/node-feature-discovery/source"
|
||||
)
|
||||
|
||||
// Source implements FeatureSource.
|
||||
type Source struct{}
|
||||
|
||||
// Name returns an identifier string for this feature source.
|
||||
func (s Source) Name() string { return "pstate" }
|
||||
|
||||
// Discover returns feature names for p-state related features such as turbo boost.
|
||||
func (s Source) Discover() (source.Features, error) {
|
||||
features := source.Features{}
|
||||
|
||||
func turboEnabled() (bool, error) {
|
||||
// On Arm platform, the frequency boost mechanism is software-based.
|
||||
// So skip pstate detection on Arm.
|
||||
switch runtime.GOARCH {
|
||||
case "arm64":
|
||||
return features, nil
|
||||
return false, nil
|
||||
}
|
||||
|
||||
// Only looking for turbo boost for now...
|
||||
bytes, err := ioutil.ReadFile("/sys/devices/system/cpu/intel_pstate/no_turbo")
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("can't detect whether turbo boost is enabled: %s", err.Error())
|
||||
return false, fmt.Errorf("can't detect whether turbo boost is enabled: %s", err.Error())
|
||||
}
|
||||
if bytes[0] == byte('0') {
|
||||
// Turbo boost is enabled.
|
||||
features["turbo"] = true
|
||||
return true, nil
|
||||
}
|
||||
|
||||
return features, nil
|
||||
return false, nil
|
||||
}
|
|
@ -16,7 +16,7 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
package rdt
|
||||
package cpu
|
||||
|
||||
import (
|
||||
"sigs.k8s.io/node-feature-discovery/pkg/cpuid"
|
|
@ -16,7 +16,7 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
package rdt
|
||||
package cpu
|
||||
|
||||
func discoverRDT() []string {
|
||||
return []string{}
|
|
@ -1,32 +0,0 @@
|
|||
/*
|
||||
Copyright 2017 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package cpuid
|
||||
|
||||
import (
|
||||
"github.com/klauspost/cpuid"
|
||||
"sigs.k8s.io/node-feature-discovery/source"
|
||||
)
|
||||
|
||||
// Discover returns feature names for all the supported CPU features.
|
||||
func (s Source) Discover() (source.Features, error) {
|
||||
// Get the cpu features as strings
|
||||
features := source.Features{}
|
||||
for _, f := range cpuid.CPU.Features.Strings() {
|
||||
features[f] = true
|
||||
}
|
||||
return features, nil
|
||||
}
|
|
@ -1,40 +0,0 @@
|
|||
/*
|
||||
Copyright 2017 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package rdt
|
||||
|
||||
import (
|
||||
"sigs.k8s.io/node-feature-discovery/source"
|
||||
)
|
||||
|
||||
// Source implements FeatureSource.
|
||||
type Source struct{}
|
||||
|
||||
// Name returns an identifier string for this feature source.
|
||||
func (s Source) Name() string { return "rdt" }
|
||||
|
||||
// Discover returns feature names for CMT and CAT if supported.
|
||||
func (s Source) Discover() (source.Features, error) {
|
||||
features := source.Features{}
|
||||
|
||||
rdtFeatures := discoverRDT()
|
||||
|
||||
for _, f := range rdtFeatures {
|
||||
features[f] = true
|
||||
}
|
||||
|
||||
return features, nil
|
||||
}
|
Loading…
Reference in a new issue