MCPcopy
hub / github.com/google/cadvisor / addCacheInfo

Function addCacheInfo

lib/utils/sysinfo/sysinfo.go:338–388  ·  view source on GitHub ↗

addCacheInfo adds information about cache for NUMA node

(sysFs sysfs.SysFs, node *info.Node)

Source from the content-addressed store, hash-verified

336
337// addCacheInfo adds information about cache for NUMA node
338func addCacheInfo(sysFs sysfs.SysFs, node *info.Node) error {
339 for coreID, core := range node.Cores {
340 threadID := core.Threads[0] //get any thread for core
341 caches, err := GetCacheInfo(sysFs, threadID)
342 if err != nil {
343 return err
344 }
345
346 numThreadsPerCore := len(core.Threads)
347 numThreadsPerNode := len(node.Cores) * numThreadsPerCore
348
349 for _, cache := range caches {
350 c := info.Cache{
351 Id: cache.Id,
352 Size: cache.Size,
353 Level: cache.Level,
354 Type: cache.Type,
355 }
356 if cache.Level > cacheLevel2 {
357 if cache.Cpus == numThreadsPerNode {
358 // Add a node level cache.
359 cacheFound := false
360 for _, nodeCache := range node.Caches {
361 if nodeCache == c {
362 cacheFound = true
363 }
364 }
365 if !cacheFound {
366 node.Caches = append(node.Caches, c)
367 }
368 } else {
369 // Add uncore cache, for architecture in which l3 cache only shared among some cores.
370 uncoreCacheFound := false
371 for _, uncoreCache := range node.Cores[coreID].UncoreCaches {
372 if uncoreCache == c {
373 uncoreCacheFound = true
374 }
375 }
376 if !uncoreCacheFound {
377 node.Cores[coreID].UncoreCaches = append(node.Cores[coreID].UncoreCaches, c)
378 }
379 }
380 } else if cache.Cpus == numThreadsPerCore {
381 // Add core level cache
382 node.Cores[coreID].Caches = append(node.Cores[coreID].Caches, c)
383 }
384 // Ignore unknown caches.
385 }
386 }
387 return nil
388}
389
390// getNodeMemInfo returns information about total memory for NUMA node
391func getNodeMemInfo(sysFs sysfs.SysFs, nodeDir string) (uint64, error) {

Callers 2

GetNodesInfoFunction · 0.85
getCPUTopologyFunction · 0.85

Calls 1

GetCacheInfoFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…