Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit f6c059f

Browse files
committedFeb 4, 2025·
tlb refactor.
tlb variables are moved into a struct for clean and readable code. Signed-off-by: Balakrishnan Unnithan <[email protected]>
1 parent a5ff6df commit f6c059f

File tree

4 files changed

+74
-155
lines changed

4 files changed

+74
-155
lines changed
 

‎src/x86/api.h

+20-43
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,22 @@ struct cpuinfo_x86_caches {
3333
uint32_t prefetch_size;
3434
};
3535

36+
struct cpuinfo_x86_tlbs {
37+
struct cpuinfo_tlb itlb_4KB;
38+
struct cpuinfo_tlb itlb_2MB;
39+
struct cpuinfo_tlb itlb_4MB;
40+
struct cpuinfo_tlb dtlb0_4KB;
41+
struct cpuinfo_tlb dtlb0_2MB;
42+
struct cpuinfo_tlb dtlb0_4MB;
43+
struct cpuinfo_tlb dtlb_4KB;
44+
struct cpuinfo_tlb dtlb_2MB;
45+
struct cpuinfo_tlb dtlb_4MB;
46+
struct cpuinfo_tlb dtlb_1GB;
47+
struct cpuinfo_tlb stlb2_4KB;
48+
struct cpuinfo_tlb stlb2_2MB;
49+
struct cpuinfo_tlb stlb2_1GB;
50+
};
51+
3652
struct cpuinfo_x86_model_info {
3753
uint32_t model;
3854
uint32_t family;
@@ -61,21 +77,7 @@ struct cpuinfo_x86_processor {
6177
int linux_id;
6278
#endif
6379
struct cpuinfo_x86_caches cache;
64-
struct {
65-
struct cpuinfo_tlb itlb_4KB;
66-
struct cpuinfo_tlb itlb_2MB;
67-
struct cpuinfo_tlb itlb_4MB;
68-
struct cpuinfo_tlb dtlb0_4KB;
69-
struct cpuinfo_tlb dtlb0_2MB;
70-
struct cpuinfo_tlb dtlb0_4MB;
71-
struct cpuinfo_tlb dtlb_4KB;
72-
struct cpuinfo_tlb dtlb_2MB;
73-
struct cpuinfo_tlb dtlb_4MB;
74-
struct cpuinfo_tlb dtlb_1GB;
75-
struct cpuinfo_tlb stlb2_4KB;
76-
struct cpuinfo_tlb stlb2_2MB;
77-
struct cpuinfo_tlb stlb2_1GB;
78-
} tlb;
80+
struct cpuinfo_x86_tlbs tlb;
7981
struct cpuinfo_x86_topology topology;
8082
char brand_string[CPUINFO_PACKAGE_NAME_MAX];
8183
};
@@ -109,40 +111,15 @@ CPUINFO_INTERNAL void cpuinfo_x86_detect_cache(
109111
enum cpuinfo_vendor vendor,
110112
const struct cpuinfo_x86_model_info* model_info,
111113
struct cpuinfo_x86_caches* cache,
112-
struct cpuinfo_tlb* itlb_4KB,
113-
struct cpuinfo_tlb* itlb_2MB,
114-
struct cpuinfo_tlb* itlb_4MB,
115-
struct cpuinfo_tlb* dtlb0_4KB,
116-
struct cpuinfo_tlb* dtlb0_2MB,
117-
struct cpuinfo_tlb* dtlb0_4MB,
118-
struct cpuinfo_tlb* dtlb_4KB,
119-
struct cpuinfo_tlb* dtlb_2MB,
120-
struct cpuinfo_tlb* dtlb_4MB,
121-
struct cpuinfo_tlb* dtlb_1GB,
122-
struct cpuinfo_tlb* stlb2_4KB,
123-
struct cpuinfo_tlb* stlb2_2MB,
124-
struct cpuinfo_tlb* stlb2_1GB,
125-
uint32_t* log2_package_cores_max);
114+
struct cpuinfo_x86_tlbs* tlb,
115+
struct cpuinfo_x86_topology* topology);
126116

127117
CPUINFO_INTERNAL void cpuinfo_x86_decode_cache_descriptor(
128118
uint8_t descriptor,
129119
enum cpuinfo_vendor vendor,
130120
const struct cpuinfo_x86_model_info* model_info,
131121
struct cpuinfo_x86_caches* cache,
132-
struct cpuinfo_tlb* itlb_4KB,
133-
struct cpuinfo_tlb* itlb_2MB,
134-
struct cpuinfo_tlb* itlb_4MB,
135-
struct cpuinfo_tlb* dtlb0_4KB,
136-
struct cpuinfo_tlb* dtlb0_2MB,
137-
struct cpuinfo_tlb* dtlb0_4MB,
138-
struct cpuinfo_tlb* dtlb_4KB,
139-
struct cpuinfo_tlb* dtlb_2MB,
140-
struct cpuinfo_tlb* dtlb_4MB,
141-
struct cpuinfo_tlb* dtlb_1GB,
142-
struct cpuinfo_tlb* stlb2_4KB,
143-
struct cpuinfo_tlb* stlb2_2MB,
144-
struct cpuinfo_tlb* stlb2_1GB,
145-
uint32_t* prefetch_size);
122+
struct cpuinfo_x86_tlbs* tlb);
146123

147124
CPUINFO_INTERNAL bool cpuinfo_x86_decode_deterministic_cache_parameters(
148125
struct cpuid_regs regs,

0 commit comments

Comments
 (0)
Please sign in to comment.