addCacheInfo adds information about cache for NUMA node
(sysFs sysfs.SysFs, node *info.Node)
| 336 | |
| 337 | // addCacheInfo adds information about cache for NUMA node |
| 338 | func 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 |
| 391 | func getNodeMemInfo(sysFs sysfs.SysFs, nodeDir string) (uint64, error) { |
no test coverage detected
searching dependent graphs…