Changes in libcfa/src/device/cpu.cfa [8157bde:ab4a595]
- File:
-
- 1 edited
-
libcfa/src/device/cpu.cfa (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/device/cpu.cfa
r8157bde rab4a595 135 135 count++; 136 136 } 137 int ret = iterate_dir(path, lambda); 138 if(ret == ENOTDIR) return 0; 137 iterate_dir(path, lambda); 139 138 140 139 /* paranoid */ verifyf(count == max + 1, "Inconsistent %s count, counted %d, but max %s was %d", prefix, count, prefix, (int)max); … … 160 159 161 160 const char * _; 162 return read_width(buff, r - 1, &_);; 161 int cnt = read_width(buff, r - 1, &_); 162 /* paranoid */ verify(cnt == count_prefix_dirs("/sys/devices/system/cpu", "cpu")); 163 return cnt; 163 164 } 164 165 … … 225 226 226 227 struct raw_cache_instance { 227 idx_range_t range; // A text description of the cpus covered228 unsigned width; // The number of cpus covered229 unsigned char level; // the cache level228 idx_range_t range; 229 unsigned width; 230 unsigned char level; 230 231 // FIXME add at least size and type 231 232 }; … … 234 235 static void ^?{}(raw_cache_instance & this) { free(this.range);} 235 236 236 // Returns a 2D array of instances of size [cpu count][cache levels]237 // where cache level doesn't include instruction caches238 237 raw_cache_instance ** build_raw_cache_table(unsigned cpus, unsigned idxs, unsigned cache_levels) 239 238 { 240 239 raw_cache_instance ** raw = alloc(cpus); 241 242 // TODO: this loop is broken, it only works if the present cpu start at 0 and are contiguous which is not guaranteed.243 240 for(i; cpus) { 244 if (cache_levels > 0) { 245 raw[i] = alloc(cache_levels); 246 void addcache(unsigned fidx, unsigned char level, idx_range_t range, size_t len) { 247 /* paranoid */ verifyf(level <= cache_levels, "Unexpected cache level %d on cpu %u index %u", (int)level, i, fidx); 248 249 unsigned idx = cache_levels - level; 250 raw_cache_instance & r = raw[i][idx]; 251 r.range = strndup(range, len); 252 r.level = level; 253 const char * end; 254 r.width = read_width(range, len, &end); 255 } 256 foreach_cacheidx(i, idxs, addcache); 257 } 258 else { 259 char buf[128]; 260 snprintf(buf, 128, "0-%u", cpus); 261 raw[i] = alloc(); 262 raw[i]->range = strndup(buf, 128); 263 raw[i]->level = 0; 264 raw[i]->width = cpus; 265 } 241 raw[i] = alloc(cache_levels); 242 void addcache(unsigned fidx, unsigned char level, idx_range_t range, size_t len) { 243 /* paranoid */ verifyf(level <= cache_levels, "Unexpected cache level %d on cpu %u index %u", (int)level, i, fidx); 244 245 unsigned idx = cache_levels - level; 246 raw_cache_instance & r = raw[i][idx]; 247 r.range = strndup(range, len); 248 r.level = level; 249 const char * end; 250 r.width = read_width(range, len, &end); 251 } 252 foreach_cacheidx(i, idxs, addcache); 266 253 } 267 254 … … 346 333 unsigned cache_levels = 0; 347 334 unsigned llc = 0; 348 if (idxs != 0){335 { 349 336 unsigned char prev = -1u; 350 337 void first(unsigned idx, unsigned char level, const char * map, size_t len) { … … 429 416 cpu_info.llc_map = entries; 430 417 cpu_info.hthrd_count = cpus; 431 cpu_info.llc_count = map_cnt;432 418 } 433 419
Note:
See TracChangeset
for help on using the changeset viewer.