diff options
| author | Louis Burda <quent.burda@gmail.com> | 2022-08-15 16:20:27 +0200 |
|---|---|---|
| committer | Louis Burda <quent.burda@gmail.com> | 2022-08-15 16:20:27 +0200 |
| commit | fef45f5207c99b00676c014bc02141e284c331ce (patch) | |
| tree | 136766ab312e5bd56582fb54dbd2932005c18ad7 /kmod/cachepc.c | |
| parent | 2ee8bd2f14f1fe909108e89a24ec9f6de814f438 (diff) | |
| download | cachepc-fef45f5207c99b00676c014bc02141e284c331ce.tar.gz cachepc-fef45f5207c99b00676c014bc02141e284c331ce.zip | |
Stash version with no consistent noise in eviction test
Diffstat (limited to 'kmod/cachepc.c')
| -rwxr-xr-x | kmod/cachepc.c | 32 |
1 files changed, 23 insertions, 9 deletions
diff --git a/kmod/cachepc.c b/kmod/cachepc.c index 4e07f32..df8ea0e 100755 --- a/kmod/cachepc.c +++ b/kmod/cachepc.c @@ -284,8 +284,9 @@ remove_cache_group_set(void *ptr) * and D = Associativity = | cache set | */ cacheline *build_cache_ds(cache_ctx *ctx, cacheline **cl_ptr_arr) { + cacheline **first_cl_in_sets, **last_cl_in_sets; cacheline **cl_ptr_arr_sorted; - cacheline *curr_cl, *next_cl; + cacheline *curr_cl; cacheline *cache_ds; uint32_t *idx_per_set; uint32_t idx_curr_set, set_offset; @@ -319,17 +320,30 @@ cacheline *build_cache_ds(cache_ctx *ctx, cacheline **cl_ptr_arr) { gen_random_indices(idx_map, ctx->sets); - curr_cl = cl_ptr_arr_sorted[idx_map[0] * set_len]->prev; - for (j = 0; j < ctx->sets; ++j) { - curr_cl->next = cl_ptr_arr_sorted[idx_map[(j + 1) % ctx->sets] * set_len]; - next_cl = curr_cl->next->prev; - curr_cl->next->prev = curr_cl; - curr_cl = next_cl; + first_cl_in_sets = kzalloc(ctx->sets * sizeof(cacheline *), GFP_KERNEL); + BUG_ON(first_cl_in_sets == NULL); + + last_cl_in_sets = kzalloc(ctx->sets * sizeof(cacheline *), GFP_KERNEL); + BUG_ON(last_cl_in_sets == NULL); + + for (j = 0; j < ctx->nr_of_cachelines; ++j) { + curr_cl = cl_ptr_arr_sorted[j]; + if (IS_FIRST(curr_cl->flags)) + first_cl_in_sets[curr_cl->cache_set] = curr_cl; + if (IS_LAST(curr_cl->flags)) + last_cl_in_sets[curr_cl->cache_set] = curr_cl; } - cache_ds = cl_ptr_arr_sorted[idx_map[0] * set_len]; + /* connect up sets */ + for (i = 0; i < ctx->sets; ++i) { + last_cl_in_sets[idx_map[i]]->next = first_cl_in_sets[idx_map[(i + 1) % ctx->sets]]; + first_cl_in_sets[idx_map[(i + 1) % ctx->sets]]->prev = last_cl_in_sets[idx_map[i]]; + } + cache_ds = first_cl_in_sets[idx_map[0]]; kfree(cl_ptr_arr_sorted); + kfree(first_cl_in_sets); + kfree(last_cl_in_sets); kfree(idx_per_set); kfree(idx_map); @@ -361,7 +375,7 @@ void build_randomized_list_for_cache_set(cache_ctx *ctx, cacheline **cacheline_p curr_cl->flags = SET_FIRST(DEFAULT_FLAGS); curr_cl->prev->flags = SET_LAST(DEFAULT_FLAGS); } else { - curr_cl->flags = curr_cl->flags | DEFAULT_FLAGS; + curr_cl->flags |= DEFAULT_FLAGS; } } |
