164
static gchar *__cache_get_info_as_string(Processor *processor)
166
gchar *result = g_strdup("");
168
ProcessorCache *cache;
170
if (!processor->cache) {
171
return g_strdup("Cache information not available=\n");
174
for (cache_list = processor->cache; cache_list; cache_list = cache_list->next) {
175
cache = (ProcessorCache *)cache_list->data;
177
result = h_strdup_cprintf("Level %d (%s)=%d-way set-associative, %d sets, %dKB size\n",
181
cache->ways_of_associativity,
182
cache->number_of_sets,
189
static void __cache_obtain_info(Processor *processor, gint processor_number)
191
ProcessorCache *cache;
192
gchar *endpoint, *entry, *index;
195
endpoint = g_strdup_printf("/sys/devices/system/cpu/cpu%d/cache", processor_number);
198
cache = g_new0(ProcessorCache, 1);
200
index = g_strdup_printf("index%d/", i);
202
entry = g_strconcat(index, "type", NULL);
203
cache->type = h_sysfs_read_string(endpoint, entry);
212
entry = g_strconcat(index, "level", NULL);
213
cache->level = h_sysfs_read_int(endpoint, entry);
216
entry = g_strconcat(index, "number_of_sets", NULL);
217
cache->number_of_sets = h_sysfs_read_int(endpoint, entry);
220
entry = g_strconcat(index, "physical_line_partition", NULL);
221
cache->physical_line_partition = h_sysfs_read_int(endpoint, entry);
224
entry = g_strconcat(index, "size", NULL);
225
cache->size = h_sysfs_read_int(endpoint, entry);
229
entry = g_strconcat(index, "ways_of_associativity", NULL);
230
cache->ways_of_associativity = h_sysfs_read_int(endpoint, entry);
235
processor->cache = g_slist_append(processor->cache, cache);
151
242
static GSList *__scan_processors(void)
153
244
GSList *procs = NULL;
154
245
Processor *processor = NULL;
156
247
gchar buffer[256];
248
gint processor_number = 0;
158
250
cpuinfo = fopen("/proc/cpuinfo", "r");
254
354
{ "tm", "Thermal Monitor" },
255
355
{ "pbe", "Pending Break Enable" },
256
356
{ "pb", "Pending Break Enable" },
357
{ "pn", "Processor serial number" },
358
{ "ds", "Debug Store" },
359
{ "xmm2", "Streaming SIMD Extensions-2" },
360
{ "xmm3", "Streaming SIMD Extensions-3" },
361
{ "selfsnoop", "CPU self snoop" },
362
{ "rdtscp", "RDTSCP" },
363
{ "recovery", "CPU in recovery mode" },
364
{ "longrun", "Longrun power control" },
365
{ "lrti", "LongRun table interface" },
366
{ "cxmmx", "Cyrix MMX extensions" },
367
{ "k6_mtrr", "AMD K6 nonstandard MTRRs" },
368
{ "cyrix_arr", "Cyrix ARRs (= MTRRs)" },
369
{ "centaur_mcr","Centaur MCRs (= MTRRs)" },
370
{ "constant_tsc","TSC ticks at a constant rate" },
371
{ "up", "smp kernel running on up" },
372
{ "fxsave_leak","FXSAVE leaks FOP/FIP/FOP" },
373
{ "arch_perfmon","Intel Architectural PerfMon" },
374
{ "pebs", "Precise-Event Based Sampling" },
375
{ "bts", "Branch Trace Store" },
376
{ "sync_rdtsc", "RDTSC synchronizes the CPU" },
377
{ "rep_good", "rep microcode works well on this CPU" },
378
{ "mwait", "Monitor/Mwait support" },
379
{ "ds_cpl", "CPL Qualified Debug Store" },
380
{ "est", "Enhanced SpeedStep" },
381
{ "tm2", "Thermal Monitor 2" },
382
{ "cid", "Context ID" },
383
{ "xtpr", "Send Task Priority Messages" },
384
{ "xstore", "on-CPU RNG present (xstore insn)" },
385
{ "xstore_en", "on-CPU RNG enabled" },
386
{ "xcrypt", "on-CPU crypto (xcrypt insn)" },
387
{ "xcrypt_en", "on-CPU crypto enabled" },
388
{ "ace2", "Advanced Cryptography Engine v2" },
389
{ "ace2_en", "ACE v2 enabled" },
390
{ "phe", "PadLock Hash Engine" },
391
{ "phe_en", "PHE enabled" },
392
{ "pmm", "PadLock Montgomery Multiplier" },
393
{ "pmm_en", "PMM enabled" },
394
{ "lahf_lm", "LAHF/SAHF in long mode" },
395
{ "cmp_legacy", "HyperThreading not valid" },
396
{ "lm", "LAHF/SAHF in long mode" },
397
{ "ds_cpl", "CPL Qualified Debug Store" },
398
{ "vmx", "Virtualization support (Intel)" },
399
{ "svm", "Virtualization support (AMD)" },
400
{ "est", "Enhanced SpeedStep" },
401
{ "tm2", "Thermal Monitor 2" },
402
{ "ssse3", "Supplemental Streaming SIMD Extension 3" },
403
{ "cx16", "CMPXCHG16B instruction" },
404
{ "xptr", "Send Task Priority Messages" },
405
{ "pebs", "Precise Event Based Sampling" },
406
{ "bts", "Branch Trace Store" },
407
{ "ida", "Intel Dynamic Acceleration" },
408
{ "arch_perfmon","Intel Architectural PerfMon" },
409
{ "pni", "Streaming SIMD Extension 3 (Prescott New Instruction)" },
410
{ "rep_good", "rep microcode works well on this CPU" },
411
{ "ts", "Thermal Sensor" },
412
{ "sse3", "Streaming SIMD Extension 3" },
413
{ "sse4", "Streaming SIMD Extension 4" },
414
{ "tni", "Tejas New Instruction" },
415
{ "nni", "Nehalem New Instruction" },
416
{ "tpr", "Task Priority Register" },
417
{ "vid", "Voltage Identifier" },
418
{ "fid", "Frequency Identifier" },