From 44b114a0b2f1d860e56b57b8b65a43a1949a7a8c Mon Sep 17 00:00:00 2001 From: anjalidk <67758175+anjalidk@users.noreply.github.com> Date: Wed, 24 Jan 2024 09:29:06 -0800 Subject: [PATCH] Add "TLB size" to /proc/cpuinfo parsing. (#33) Signed-off-by: Anjali Kulkarni --- rescpu.c | 7 ++++++- resource.h | 1 + tests/CPU/cpu_test.c | 2 ++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/rescpu.c b/rescpu.c index 2b29e44..6e5c8b5 100644 --- a/rescpu.c +++ b/rescpu.c @@ -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; @@ -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++; diff --git a/resource.h b/resource.h index 9d5304d..8f92e3c 100644 --- a/resource.h +++ b/resource.h @@ -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 { diff --git a/tests/CPU/cpu_test.c b/tests/CPU/cpu_test.c index 6020e54..f655653 100644 --- a/tests/CPU/cpu_test.c +++ b/tests/CPU/cpu_test.c @@ -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)