@@ -22,6 +22,7 @@ import (
2222 "net/url"
2323 "os"
2424 "path/filepath"
25+ "strings"
2526
2627 "golang.org/x/net/context"
2728
@@ -42,6 +43,7 @@ import (
4243 "sigs.k8s.io/node-feature-discovery/pkg/resourcemonitor"
4344 "sigs.k8s.io/node-feature-discovery/pkg/topologypolicy"
4445 "sigs.k8s.io/node-feature-discovery/pkg/utils"
46+ "sigs.k8s.io/node-feature-discovery/pkg/utils/hostpath"
4547 "sigs.k8s.io/node-feature-discovery/pkg/utils/kubeconf"
4648 "sigs.k8s.io/node-feature-discovery/pkg/version"
4749 "sigs.k8s.io/yaml"
@@ -337,6 +339,32 @@ func (w *nfdTopologyUpdater) updateNodeResourceTopology(zoneInfo v1alpha2.ZoneLi
337339 return nil
338340}
339341
342+ // Dicsover E/P cores
343+ func discoverCpuCores () v1alpha2.AttributeList {
344+ attrList := v1alpha2.AttributeList {}
345+
346+ cpusPathGlob := hostpath .SysfsDir .Path ("sys/devices/cpu_*/cpus" )
347+ cpuPaths , err := filepath .Glob (cpusPathGlob )
348+ if err != nil {
349+ klog .ErrorS (err , "error reading cpu entries" , "cpusPathGlob" , cpusPathGlob )
350+ return attrList
351+ }
352+
353+ for _ , entry := range cpuPaths {
354+ cpus , err := os .ReadFile (entry )
355+ if err != nil {
356+ klog .ErrorS (err , "error reading cpu entry file" , "entry" , entry )
357+ } else {
358+ attrList = append (attrList , v1alpha2.AttributeInfo {
359+ Name : filepath .Base (filepath .Dir (entry )),
360+ Value : strings .TrimSpace (string (cpus )),
361+ })
362+ }
363+ }
364+
365+ return attrList
366+ }
367+
340368func (w * nfdTopologyUpdater ) updateNRTTopologyManagerInfo (nrt * v1alpha2.NodeResourceTopology ) error {
341369 policy , scope , err := w .detectTopologyPolicyAndScope ()
342370 if err != nil {
@@ -349,6 +377,9 @@ func (w *nfdTopologyUpdater) updateNRTTopologyManagerInfo(nrt *v1alpha2.NodeReso
349377 updateAttributes (& nrt .Attributes , tmAttributes )
350378 nrt .TopologyPolicies = deprecatedTopologyPolicies
351379
380+ attrList := discoverCpuCores ()
381+ updateAttributes (& nrt .Attributes , attrList )
382+
352383 return nil
353384}
354385
0 commit comments