@@ -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,46 @@ func (w *nfdTopologyUpdater) updateNodeResourceTopology(zoneInfo v1alpha2.ZoneLi
337339 return nil
338340}
339341
342+ func readAttributeFromFile (entry string ) (v1alpha2.AttributeInfo , error ) {
343+ cpus , err := os .ReadFile (entry )
344+ if err != nil {
345+ return v1alpha2.AttributeInfo {}, err
346+ }
347+
348+ dir , _ := filepath .Split (entry )
349+ kind := filepath .Base (dir )
350+
351+ attr := v1alpha2.AttributeInfo {
352+ Name : kind ,
353+ Value : strings .TrimSpace (string (cpus )),
354+ }
355+
356+ return attr , nil
357+ }
358+
359+ // Dicsover E/P cores
360+ func discoverCpuCores () v1alpha2.AttributeList {
361+ attrList := v1alpha2.AttributeList {}
362+
363+ cpusPathGlob := hostpath .SysfsDir .Path ("sys/devices/cpu_*/cpus" )
364+ cpuPaths , err := filepath .Glob (cpusPathGlob )
365+ if err != nil {
366+ klog .ErrorS (err , "error reading cpu entries" , "cpusPathGlob" , cpusPathGlob )
367+ return attrList
368+ }
369+
370+ for _ , entry := range cpuPaths {
371+ attr , err := readAttributeFromFile (entry )
372+ if err != nil {
373+ klog .ErrorS (err , "error reading cpu entry file" , "entry" , entry )
374+ } else {
375+ attrList = append (attrList , attr )
376+ }
377+ }
378+
379+ return attrList
380+ }
381+
340382func (w * nfdTopologyUpdater ) updateNRTTopologyManagerInfo (nrt * v1alpha2.NodeResourceTopology ) error {
341383 policy , scope , err := w .detectTopologyPolicyAndScope ()
342384 if err != nil {
@@ -349,6 +391,9 @@ func (w *nfdTopologyUpdater) updateNRTTopologyManagerInfo(nrt *v1alpha2.NodeReso
349391 updateAttributes (& nrt .Attributes , tmAttributes )
350392 nrt .TopologyPolicies = deprecatedTopologyPolicies
351393
394+ attrList := discoverCpuCores ()
395+ updateAttributes (& nrt .Attributes , attrList )
396+
352397 return nil
353398}
354399
0 commit comments