mirror of
https://github.com/kubernetes-sigs/node-feature-discovery.git
synced 2025-04-15 00:36:23 +00:00
source/cpu: move cpuid code to a shared internal package
Signed-off-by: Mikko Ylinen <mikko.ylinen@intel.com>
This commit is contained in:
parent
dc64fe0979
commit
109da6c980
6 changed files with 12 additions and 11 deletions
|
@ -21,6 +21,7 @@ import (
|
|||
"log"
|
||||
|
||||
"sigs.k8s.io/node-feature-discovery/source"
|
||||
"sigs.k8s.io/node-feature-discovery/source/internal/cpuidutils"
|
||||
)
|
||||
|
||||
// Configuration file options
|
||||
|
@ -119,7 +120,7 @@ func (s *Source) Discover() (source.Features, error) {
|
|||
}
|
||||
|
||||
// Detect CPUID
|
||||
cpuidFlags := getCpuidFlags()
|
||||
cpuidFlags := cpuidutils.GetCpuidFlags()
|
||||
for _, f := range cpuidFlags {
|
||||
if s.cpuidFilter.unmask(f) {
|
||||
features["cpuid."+f] = true
|
||||
|
|
|
@ -14,13 +14,13 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
package cpu
|
||||
package cpuidutils
|
||||
|
||||
import (
|
||||
"github.com/klauspost/cpuid"
|
||||
)
|
||||
|
||||
// Discover returns feature names for all the supported CPU features.
|
||||
func getCpuidFlags() []string {
|
||||
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 cpu
|
||||
package cpuidutils
|
||||
|
||||
/*
|
||||
#include <sys/auxv.h>
|
||||
|
@ -90,7 +90,7 @@ var flagNames_arm = map[uint64]string{
|
|||
CPU_ARM_FEATURE_CRC32: "CRC32",
|
||||
}
|
||||
|
||||
func getCpuidFlags() []string {
|
||||
func GetCpuidFlags() []string {
|
||||
r := make([]string, 0, 20)
|
||||
hwcap := uint64(C.gethwcap())
|
||||
for i := uint(0); i < 64; i++ {
|
|
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
package cpu
|
||||
package cpuidutils
|
||||
|
||||
/*
|
||||
#include <sys/auxv.h>
|
||||
|
@ -80,7 +80,7 @@ var flagNames_arm64 = map[uint64]string{
|
|||
CPU_ARM64_FEATURE_SVE: "SVE",
|
||||
}
|
||||
|
||||
func getCpuidFlags() []string {
|
||||
func GetCpuidFlags() []string {
|
||||
r := make([]string, 0, 20)
|
||||
hwcap := uint64(C.gethwcap())
|
||||
for i := uint(0); i < 64; i++ {
|
|
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
package cpu
|
||||
package cpuidutils
|
||||
|
||||
/*
|
||||
#include <sys/auxv.h>
|
||||
|
@ -126,7 +126,7 @@ var flag2Names_ppc64le = map[uint64]string{
|
|||
PPC_FEATURE2_HTM_NO_SUSPEND: "HTM-NO-SUSPEND",
|
||||
}
|
||||
|
||||
func getCpuidFlags() []string {
|
||||
func GetCpuidFlags() []string {
|
||||
r := make([]string, 0, 30)
|
||||
hwcap := uint64(C.gethwcap())
|
||||
hwcap2 := uint64(C.gethwcap2())
|
|
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
package cpu
|
||||
package cpuidutils
|
||||
|
||||
/*
|
||||
#include <sys/auxv.h>
|
||||
|
@ -71,7 +71,7 @@ var flagNames_s390x = map[uint64]string{
|
|||
HWCAP_S390_DFLT: "DFLT",
|
||||
}
|
||||
|
||||
func getCpuidFlags() []string {
|
||||
func GetCpuidFlags() []string {
|
||||
r := make([]string, 0, 20)
|
||||
hwcap := uint64(C.gethwcap())
|
||||
for i := uint(0); i < 64; i++ {
|
Loading…
Add table
Reference in a new issue