From: Mahmoud Mandour <ma.mandourr@gmail.com>
To: qemu-devel@nongnu.org
Cc: "Mahmoud Mandour" <ma.mandourr@gmail.com>,
cota@braap.org, "Alex Bennée" <alex.bennee@linaro.org>
Subject: [RFC PATCH v3 3/4] plugins/cache: Enabled cache parameterization
Date: Tue, 8 Jun 2021 06:05:31 +0200 [thread overview]
Message-ID: <20210608040532.56449-4-ma.mandourr@gmail.com> (raw)
In-Reply-To: <20210608040532.56449-1-ma.mandourr@gmail.com>
Made both icache and dcache configurable through plugin arguments.
Signed-off-by: Mahmoud Mandour <ma.mandourr@gmail.com>
---
contrib/plugins/cache.c | 44 +++++++++++++++++++++++++++++++++++++++--
1 file changed, 42 insertions(+), 2 deletions(-)
diff --git a/contrib/plugins/cache.c b/contrib/plugins/cache.c
index 715e5443b0..d8e8c750b6 100644
--- a/contrib/plugins/cache.c
+++ b/contrib/plugins/cache.c
@@ -104,8 +104,17 @@ static inline uint64_t extract_set(struct Cache *cache, uint64_t addr)
return (addr & cache->set_mask) >> cache->blksize_shift;
}
+static bool bad_cache_params(int blksize, int assoc, int cachesize)
+{
+ return (cachesize % blksize) != 0 || (cachesize % (blksize * assoc) != 0);
+}
+
static struct Cache *cache_init(int blksize, int assoc, int cachesize)
{
+ if (bad_cache_params(blksize, assoc, cachesize)) {
+ return NULL;
+ }
+
struct Cache *cache;
int i;
uint64_t blk_mask;
@@ -403,8 +412,30 @@ 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=")) {
- limit = g_ascii_strtoull(opt + 6, NULL, 10);
+ if (g_str_has_prefix(opt, "I=")) {
+ gchar **toks = g_strsplit(opt + 2, " ", -1);
+ if (g_strv_length(toks) != 3) {
+ g_strfreev(toks);
+ fprintf(stderr, "option parsing failed: %s\n", opt);
+ return -1;
+ }
+ icachesize = g_ascii_strtoull(toks[0], NULL, 10);
+ iassoc = g_ascii_strtoull(toks[1], NULL, 10);
+ iblksize = g_ascii_strtoull(toks[2], NULL, 10);
+ g_strfreev(toks);
+ } else if (g_str_has_prefix(opt, "D=")) {
+ gchar **toks = g_strsplit(opt + 2, " ", -1);
+ if (g_strv_length(toks) != 3) {
+ g_strfreev(toks);
+ fprintf(stderr, "option parsing failed: %s\n", opt);
+ return -1;
+ }
+ dcachesize = g_ascii_strtoull(toks[0], NULL, 10);
+ dassoc = g_ascii_strtoull(toks[1], NULL, 10);
+ dblksize = g_ascii_strtoull(toks[2], NULL, 10);
+ g_strfreev(toks);
+ } 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);
return -1;
@@ -412,7 +443,16 @@ int qemu_plugin_install(qemu_plugin_id_t id, const qemu_info_t *info,
}
dcache = cache_init(dblksize, dassoc, dcachesize);
+ if (!dcache) {
+ fprintf(stderr, "dcache cannot be constructed from given parameters\n");
+ return -1;
+ }
+
icache = cache_init(iblksize, iassoc, icachesize);
+ if (!icache) {
+ fprintf(stderr, "icache cannot be constructed from given parameters\n");
+ return -1;
+ }
qemu_plugin_register_vcpu_tb_trans_cb(id, vcpu_tb_trans);
qemu_plugin_register_atexit_cb(id, plugin_exit, NULL);
--
2.25.1
next prev parent reply other threads:[~2021-06-08 4:09 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-08 4:05 [RFC PATCH v3 0/4] Cache TCG plugin & symbol-resolution API Mahmoud Mandour
2021-06-08 4:05 ` [RFC PATCH v3 1/4] plugins/api: expose symbol lookup to plugins Mahmoud Mandour
2021-06-08 4:05 ` [RFC PATCH v3 2/4] plugins: Added a new cache modelling plugin Mahmoud Mandour
2021-06-08 4:05 ` Mahmoud Mandour [this message]
2021-06-22 14:37 ` [RFC PATCH v3 3/4] plugins/cache: Enabled cache parameterization Alex Bennée
2021-06-08 4:05 ` [RFC PATCH v3 4/4] plugins/cache: Added FIFO and LRU eviction policies Mahmoud Mandour
2021-06-22 14:57 ` Alex Bennée
2021-06-22 14:57 ` [RFC PATCH v3 0/4] Cache TCG plugin & symbol-resolution API Alex Bennée
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210608040532.56449-4-ma.mandourr@gmail.com \
--to=ma.mandourr@gmail.com \
--cc=alex.bennee@linaro.org \
--cc=cota@braap.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.