@@ -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,39 @@ 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
+ cpu_atom , err := os .ReadFile (hostpath .SysfsDir .Path ("sys/devices/cpu_atom" , "cpus" ))
347
+ if err != nil {
348
+ klog .ErrorS (err , "error reading cpu_atom/cpus file" )
349
+ return v1alpha2.AttributeList {}
350
+ }
351
+
352
+ attrAtom := v1alpha2.AttributeInfo {
353
+ Name : "cpu_atom" ,
354
+ Value : strings .TrimSpace (string (cpu_atom )),
355
+ }
356
+
357
+ attrList = append (attrList , attrAtom )
358
+
359
+ cpu_core , err := os .ReadFile (hostpath .SysfsDir .Path ("sys/devices/cpu_core" , "cpus" ))
360
+ if err != nil {
361
+ klog .ErrorS (err , "error reading cpu_core/cpus file" )
362
+ return v1alpha2.AttributeList {}
363
+ }
364
+
365
+ attrCore := v1alpha2.AttributeInfo {
366
+ Name : "cpu_core" ,
367
+ Value : strings .TrimSpace (string (cpu_core )),
368
+ }
369
+
370
+ attrList = append (attrList , attrCore )
371
+
372
+ return attrList
373
+ }
374
+
340
375
func (w * nfdTopologyUpdater ) updateNRTTopologyManagerInfo (nrt * v1alpha2.NodeResourceTopology ) error {
341
376
policy , scope , err := w .detectTopologyPolicyAndScope ()
342
377
if err != nil {
@@ -349,6 +384,9 @@ func (w *nfdTopologyUpdater) updateNRTTopologyManagerInfo(nrt *v1alpha2.NodeReso
349
384
updateAttributes (& nrt .Attributes , tmAttributes )
350
385
nrt .TopologyPolicies = deprecatedTopologyPolicies
351
386
387
+ attrList := discoverCpuCores ()
388
+ updateAttributes (& nrt .Attributes , attrList )
389
+
352
390
return nil
353
391
}
354
392
0 commit comments