@@ -22,6 +22,7 @@ import (
22
22
"net/url"
23
23
"os"
24
24
"path/filepath"
25
+ "strings"
25
26
26
27
"golang.org/x/net/context"
27
28
@@ -42,6 +43,7 @@ import (
42
43
"sigs.k8s.io/node-feature-discovery/pkg/resourcemonitor"
43
44
"sigs.k8s.io/node-feature-discovery/pkg/topologypolicy"
44
45
"sigs.k8s.io/node-feature-discovery/pkg/utils"
46
+ "sigs.k8s.io/node-feature-discovery/pkg/utils/hostpath"
45
47
"sigs.k8s.io/node-feature-discovery/pkg/utils/kubeconf"
46
48
"sigs.k8s.io/node-feature-discovery/pkg/version"
47
49
"sigs.k8s.io/yaml"
@@ -337,6 +339,32 @@ func (w *nfdTopologyUpdater) updateNodeResourceTopology(zoneInfo v1alpha2.ZoneLi
337
339
return nil
338
340
}
339
341
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
+
340
368
func (w * nfdTopologyUpdater ) updateNRTTopologyManagerInfo (nrt * v1alpha2.NodeResourceTopology ) error {
341
369
policy , scope , err := w .detectTopologyPolicyAndScope ()
342
370
if err != nil {
@@ -349,6 +377,9 @@ func (w *nfdTopologyUpdater) updateNRTTopologyManagerInfo(nrt *v1alpha2.NodeReso
349
377
updateAttributes (& nrt .Attributes , tmAttributes )
350
378
nrt .TopologyPolicies = deprecatedTopologyPolicies
351
379
380
+ attrList := discoverCpuCores ()
381
+ updateAttributes (& nrt .Attributes , attrList )
382
+
352
383
return nil
353
384
}
354
385
0 commit comments