Skip to content

Commit

Permalink
Add "TLB size" to /proc/cpuinfo parsing. (#33)
Browse files Browse the repository at this point in the history
Signed-off-by: Anjali Kulkarni <[email protected]>
  • Loading branch information
anjalidk authored Jan 24, 2024
1 parent 18ad4c3 commit 44b114a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
7 changes: 6 additions & 1 deletion rescpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,12 @@ static int populate_cpuinfo(void *out, char *buffer, int total_len, int probe)
else
cpu->bogomips = atof(end2);
}
if (!strcmp(start, "TLB size")) {
if (probe)
cpu->tlb_size[0] = 1;
else
strcpy(cpu->tlb_size, end2);
}
if (!strcmp(start, "clflush size")) {
if (probe)
cpu->clflush_size = 1;
Expand All @@ -245,7 +251,6 @@ static int populate_cpuinfo(void *out, char *buffer, int total_len, int probe)
else
strcpy(cpu->power_mgmt, end2);
}

nextline:
start = start2;
start++;
Expand Down
1 change: 1 addition & 0 deletions resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ struct cpuinfo {
unsigned int cache_alignment;
char address_sizes[CPU_STR];
char power_mgmt[CPU_STR];
char tlb_size[CPU_STR];
};

struct memstat {
Expand Down
2 changes: 2 additions & 0 deletions tests/CPU/cpu_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ int main(int argc, char **argv)
fprintf(fp, "bugs\t\t: %s\n",cpu->bugs);
if (exist->bogomips)
fprintf(fp, "bogomips\t: %0.2f\n",cpu->bogomips);
if (exist->tlb_size[0])
fprintf(fp, "TLB size\t: %s\n",cpu->tlb_size);
if (exist->clflush_size)
fprintf(fp, "clflush size\t: %u\n",cpu->clflush_size);
if (exist->cache_alignment)
Expand Down

0 comments on commit 44b114a

Please sign in to comment.