Skip to content

Commit

Permalink
cpu: support for detecting nx-gzip coprocessor feature
Browse files Browse the repository at this point in the history
Nest accelerator gzip support for IBM Power systems.

Signed-off-by: Chandan Abhyankar <[email protected]>
  • Loading branch information
Chandan-Abhyankar committed Jan 18, 2023
1 parent 080105c commit d66096a
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 10 deletions.
2 changes: 2 additions & 0 deletions docs/usage/customization-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,8 @@ The following features are available for matching:
| | | **`enabled`** | bool | **DEPRECATED**: use **`se.enabled`** from **`cpu.security`** instead
| **`cpu.topology`** | attribute | | | CPU topology related features
| | | **`hardware_multithreading`** | bool | Hardware multithreading, such as Intel HTT, is enabled
| **`cpu.coprocessor`** | attribute | | | CPU Coprocessor related features
| | | **`nx_gzip`** | bool | Nest Accelerator GZIP support is enabled
| **`kernel.config`** | attribute | | | Kernel configuration options
| | | **`<config-flag>`** | string | Value of the kconfig option
| **`kernel.loadedmodule`** | flag | | | Loaded kernel modules
Expand Down
1 change: 1 addition & 0 deletions docs/usage/features.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ option of nfd-worker.
| ----------------------- | ------------ | -----------
| **`cpu-cpuid.<cpuid-flag>`** | true | CPU capability is supported. **NOTE:** the capability might be supported but not enabled.
| **`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
| **`cpu-pstate.status`** | string | The status of the [Intel pstate][intel-pstate] driver when in use and enabled, either 'active' or 'passive'.
| **`cpu-pstate.turbo`** | bool | Set to 'true' if turbo frequencies are enabled in Intel pstate driver, set to 'false' if they have been disabled.
Expand Down
43 changes: 43 additions & 0 deletions source/cpu/coprocessor_ppc64le.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
//go:build ppc64le
// +build ppc64le

/*
Copyright 2023 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 cpu

import (
"k8s.io/klog/v2"
"os"
"sigs.k8s.io/node-feature-discovery/pkg/utils/hostpath"
"strconv"
)

/* Detect NX_GZIP */
func discoverCoprocessor() map[string]string {
features := make(map[string]string)

nxGzipPath := hostpath.SysfsDir.Path("devices/vio/ibm,compression-v1/nx_gzip_caps")

_, err := os.Stat(nxGzipPath)
if err != nil {
klog.V(5).Infof("Failed to detect nx_gzip for Nest Accelerator: %v", err)
} else {
features["nx_gzip"] = strconv.FormatBool(true)
}

return features
}
24 changes: 24 additions & 0 deletions source/cpu/coprocessor_stub.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//go:build !ppc64le
// +build !ppc64le

/*
Copyright 2023 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 cpu

func discoverCoprocessor() map[string]string {
return nil
}
29 changes: 19 additions & 10 deletions source/cpu/cpu.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,17 @@ import (
const Name = "cpu"

const (
CpuidFeature = "cpuid"
Cpumodel = "model"
CstateFeature = "cstate"
PstateFeature = "pstate"
RdtFeature = "rdt"
SeFeature = "se" // DEPRECATED in v0.12: will be removed in the future
SecurityFeature = "security"
SgxFeature = "sgx" // DEPRECATED in v0.12: will be removed in the future
SstFeature = "sst"
TopologyFeature = "topology"
CpuidFeature = "cpuid"
Cpumodel = "model"
CstateFeature = "cstate"
PstateFeature = "pstate"
RdtFeature = "rdt"
SeFeature = "se" // DEPRECATED in v0.12: will be removed in the future
SecurityFeature = "security"
SgxFeature = "sgx" // DEPRECATED in v0.12: will be removed in the future
SstFeature = "sst"
TopologyFeature = "topology"
CoprocessorFeature = "coprocessor"
)

// Configuration file options
Expand Down Expand Up @@ -192,6 +193,11 @@ func (s *cpuSource) GetLabels() (source.FeatureLabels, error) {
labels["hardware_multithreading"] = v
}

// NX
if v, ok := features.Attributes[CoprocessorFeature].Elements["nx_gzip"]; ok {
labels["coprocessor.nx_gzip"] = v
}

return labels, nil
}

Expand Down Expand Up @@ -246,6 +252,9 @@ func (s *cpuSource) Discover() error {
// Detect hyper-threading
s.features.Attributes[TopologyFeature] = nfdv1alpha1.NewAttributeFeatures(discoverTopology())

// Detect Coprocessor features
s.features.Attributes[CoprocessorFeature] = nfdv1alpha1.NewAttributeFeatures(discoverCoprocessor())

utils.KlogDump(3, "discovered cpu features:", " ", s.features)

return nil
Expand Down

0 comments on commit d66096a

Please sign in to comment.