[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL v5 41/44] plugins/cache: Enable cache parameterization
From: |
Alex Bennée |
Subject: |
[PULL v5 41/44] plugins/cache: Enable cache parameterization |
Date: |
Wed, 14 Jul 2021 16:00:33 +0100 |
From: Mahmoud Mandour <ma.mandourr@gmail.com>
Enabled configuring both icache and dcache parameters using plugin
parameters.
Signed-off-by: Mahmoud Mandour <ma.mandourr@gmail.com>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-Id: <20210623125458.450462-3-ma.mandourr@gmail.com>
Message-Id: <20210709143005.1554-38-alex.bennee@linaro.org>
diff --git a/contrib/plugins/cache.c b/contrib/plugins/cache.c
index e9955cdc3a..b550ef31b0 100644
--- a/contrib/plugins/cache.c
+++ b/contrib/plugins/cache.c
@@ -99,8 +99,28 @@ static inline uint64_t extract_set(Cache *cache, uint64_t
addr)
return (addr & cache->set_mask) >> cache->blksize_shift;
}
+static const char *cache_config_error(int blksize, int assoc, int cachesize)
+{
+ if (cachesize % blksize != 0) {
+ return "cache size must be divisible by block size";
+ } else if (cachesize % (blksize * assoc) != 0) {
+ return "cache size must be divisible by set size (assoc * block size)";
+ } else {
+ return NULL;
+ }
+}
+
+static bool bad_cache_params(int blksize, int assoc, int cachesize)
+{
+ return (cachesize % blksize) != 0 || (cachesize % (blksize * assoc) != 0);
+}
+
static Cache *cache_init(int blksize, int assoc, int cachesize)
{
+ if (bad_cache_params(blksize, assoc, cachesize)) {
+ return NULL;
+ }
+
Cache *cache;
int i;
uint64_t blk_mask;
@@ -397,7 +417,19 @@ int qemu_plugin_install(qemu_plugin_id_t id, const
qemu_info_t *info,
for (i = 0; i < argc; i++) {
char *opt = argv[i];
- if (g_str_has_prefix(opt, "limit=")) {
+ if (g_str_has_prefix(opt, "iblksize=")) {
+ iblksize = g_ascii_strtoll(opt + 9, NULL, 10);
+ } else if (g_str_has_prefix(opt, "iassoc=")) {
+ iassoc = g_ascii_strtoll(opt + 7, NULL, 10);
+ } else if (g_str_has_prefix(opt, "icachesize=")) {
+ icachesize = g_ascii_strtoll(opt + 11, NULL, 10);
+ } else if (g_str_has_prefix(opt, "dblksize=")) {
+ dblksize = g_ascii_strtoll(opt + 9, NULL, 10);
+ } else if (g_str_has_prefix(opt, "dassoc=")) {
+ dassoc = g_ascii_strtoll(opt + 7, NULL, 10);
+ } else if (g_str_has_prefix(opt, "dcachesize=")) {
+ dcachesize = g_ascii_strtoll(opt + 11, NULL, 10);
+ } else if (g_str_has_prefix(opt, "limit=")) {
limit = g_ascii_strtoll(opt + 6, NULL, 10);
} else {
fprintf(stderr, "option parsing failed: %s\n", opt);
@@ -406,7 +438,20 @@ int qemu_plugin_install(qemu_plugin_id_t id, const
qemu_info_t *info,
}
dcache = cache_init(dblksize, dassoc, dcachesize);
+ if (!dcache) {
+ const char *err = cache_config_error(dblksize, dassoc, dcachesize);
+ fprintf(stderr, "dcache cannot be constructed from given
parameters\n");
+ fprintf(stderr, "%s\n", err);
+ return -1;
+ }
+
icache = cache_init(iblksize, iassoc, icachesize);
+ if (!icache) {
+ const char *err = cache_config_error(iblksize, iassoc, icachesize);
+ fprintf(stderr, "icache cannot be constructed from given
parameters\n");
+ fprintf(stderr, "%s\n", err);
+ return -1;
+ }
rng = g_rand_new();
--
2.20.1
- [PULL v5 36/44] tcg/plugins: enable by default for most TCG builds, (continued)
- [PULL v5 36/44] tcg/plugins: enable by default for most TCG builds, Alex Bennée, 2021/07/14
- [PULL v5 44/44] MAINTAINERS: Added myself as a reviewer for TCG Plugins, Alex Bennée, 2021/07/14
- [PULL v5 34/44] configure: add an explicit static and plugins check, Alex Bennée, 2021/07/14
- [PULL v5 26/44] tests/vm: update NetBSD to 9.2, Alex Bennée, 2021/07/14
- [PULL v5 24/44] tests/docker: expand ubuntu2004 package list, Alex Bennée, 2021/07/14
- [PULL v5 40/44] plugins: Added a new cache modelling plugin, Alex Bennée, 2021/07/14
- [PULL v5 22/44] tests/docker: expand fedora package list, Alex Bennée, 2021/07/14
- [PULL v5 30/44] meson.build: move TCG plugin summary output, Alex Bennée, 2021/07/14
- [PULL v5 20/44] tests/docker: remove mingw packages from Fedora, Alex Bennée, 2021/07/14
- [PULL v5 43/44] docs/devel: Added cache plugin to the plugins docs, Alex Bennée, 2021/07/14
- [PULL v5 41/44] plugins/cache: Enable cache parameterization,
Alex Bennée <=
- [PULL v5 31/44] meson.build: relax the libdl test to one for the function dlopen, Alex Bennée, 2021/07/14
- [PULL v5 33/44] configure: don't allow plugins to be enabled for a non-TCG build, Alex Bennée, 2021/07/14
- [PULL v5 19/44] tests/docker: fix mistakes in ubuntu package lists, Alex Bennée, 2021/07/14
- [PULL v5 25/44] tests/docker: expand opensuse-leap package list, Alex Bennée, 2021/07/14
- [PULL v5 21/44] tests/docker: expand centos8 package list, Alex Bennée, 2021/07/14
- [PULL v5 29/44] plugins: fix-up handling of internal hostaddr for 32 bit, Alex Bennée, 2021/07/14
- [PULL v5 15/44] tests/docker: remove FEATURES env var from templates, Alex Bennée, 2021/07/14
- [PULL v5 27/44] tests/vm: update openbsd to release 6.9, Alex Bennée, 2021/07/14
- [PULL v5 18/44] tests/docker: fix mistakes in fedora package list, Alex Bennée, 2021/07/14
- [PULL v5 16/44] tests/docker: fix sorting in package lists, Alex Bennée, 2021/07/14