MCPcopy
hub / github.com/jaypipes/ghw / memoryCacheID

Function memoryCacheID

pkg/memory/memory_cache_linux.go:156–178  ·  view source on GitHub ↗
(
	ctx context.Context,
	paths *linuxpath.Paths,
	nodeID int,
	lpID int,
	cacheIndex int,
)

Source from the content-addressed store, hash-verified

154}
155
156func memoryCacheID(
157 ctx context.Context,
158 paths *linuxpath.Paths,
159 nodeID int,
160 lpID int,
161 cacheIndex int,
162) int {
163 idPath := filepath.Join(
164 paths.NodeCPUCacheIndex(nodeID, lpID, cacheIndex),
165 "id",
166 )
167 idContents, err := os.ReadFile(idPath)
168 if err != nil {
169 // The id file may not exist in early kernel versions, so we don't warn
170 return -1
171 }
172 id, err := strconv.Atoi(string(idContents[:len(idContents)-1]))
173 if err != nil {
174 log.Warn(ctx, "Unable to parse int from %s", idContents)
175 return -1
176 }
177 return id
178}
179
180func memoryCacheSize(
181 ctx context.Context,

Callers 1

CachesForNodeFunction · 0.85

Calls 2

WarnFunction · 0.92
NodeCPUCacheIndexMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…