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