[RFC PATCH v3 0/4] Cache TCG plugin & symbol-resolution API

Mahmoud Mandour posted 4 patches 2 years, 11 months ago
Test checkpatch passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20210608040532.56449-1-ma.mandourr@gmail.com
Maintainers: "Alex Bennée" <alex.bennee@linaro.org>
contrib/plugins/Makefile   |   1 +
contrib/plugins/cache.c    | 642 +++++++++++++++++++++++++++++++++++++
include/qemu/qemu-plugin.h |   9 +
plugins/api.c              |   6 +
4 files changed, 658 insertions(+)
create mode 100644 contrib/plugins/cache.c
[RFC PATCH v3 0/4] Cache TCG plugin & symbol-resolution API
Posted by Mahmoud Mandour 2 years, 11 months ago
This RFC series introduces a new cache TCG plugin that models separate
L1 data cache and L1 instruction cache and uses one shared cache for
all the cores.

It also includes a commit by Alex that adds an API call that resolves
the symbol of an insn.

The original RFC patch posted by Alex Bennée included incorporating
symbol resolution into the cache plugin that caused conflicts, so I
dropped the plugin additions from that and introduced them afterwards.

v2 -> v3:
    Precomputed the value of block size shift once and stored in the
    cache.

    Removed tag shifting since it's okay to leave the tag in the
    high-order bits and mask out set index and block offset.

    Used one hashtable to store InsnData structs and made the structs
    have separate counters for data misses and instruction misses.

    Used a boolean to indicate whether an access resulted in a hit or a
    miss.

    Inserted an InsnData struct into the hashtable on translation-time
    and made sure we do so once so that we don't rewrite the struct if
    an instruction is translated multiple times.

    Made the output format for most-missing instructions more
    machine-readable.

    Removed trace-generation.

    Freed tokenized strings after argument parsing.

    Returned null from cache_init() if argument cache config is bad.

    Used one enum to indicate the chosen eviction policy.

    Added function pointers for cache update and metadata initialization
    and destroying. Those pointers are assigned to policy-specific
    functions.

    Remade LRU. Assigned a generation number that is incremented on each
    set access to the currently-accessed block's priority. On miss, 
    evicted the block with the least generation number.

    Allowed to give multiple "evict" arguments and sticked to the last
    one.

Alex Bennée (1):
  plugins/api: expose symbol lookup to plugins

Mahmoud Mandour (3):
  plugins: Added a new cache modelling plugin.
  plugins/cache: Enabled cache parameterization
  plugins/cache: Added FIFO and LRU eviction policies.

 contrib/plugins/Makefile   |   1 +
 contrib/plugins/cache.c    | 642 +++++++++++++++++++++++++++++++++++++
 include/qemu/qemu-plugin.h |   9 +
 plugins/api.c              |   6 +
 4 files changed, 658 insertions(+)
 create mode 100644 contrib/plugins/cache.c

-- 
2.25.1


Re: [RFC PATCH v3 0/4] Cache TCG plugin & symbol-resolution API
Posted by Alex Bennée 2 years, 10 months ago
Mahmoud Mandour <ma.mandourr@gmail.com> writes:

> This RFC series introduces a new cache TCG plugin that models separate
> L1 data cache and L1 instruction cache and uses one shared cache for
> all the cores.
>
> It also includes a commit by Alex that adds an API call that resolves
> the symbol of an insn.
>
> The original RFC patch posted by Alex Bennée included incorporating
> symbol resolution into the cache plugin that caused conflicts, so I
> dropped the plugin additions from that and introduced them afterwards.

Queued patches 1-2 to plugins/next, will queue the rest from next
revision. Could you please also add a section to
docs/devel/tcg-plugins.rst to detail the argument options.

>
> v2 -> v3:
>     Precomputed the value of block size shift once and stored in the
>     cache.
>
>     Removed tag shifting since it's okay to leave the tag in the
>     high-order bits and mask out set index and block offset.
>
>     Used one hashtable to store InsnData structs and made the structs
>     have separate counters for data misses and instruction misses.
>
>     Used a boolean to indicate whether an access resulted in a hit or a
>     miss.
>
>     Inserted an InsnData struct into the hashtable on translation-time
>     and made sure we do so once so that we don't rewrite the struct if
>     an instruction is translated multiple times.
>
>     Made the output format for most-missing instructions more
>     machine-readable.
>
>     Removed trace-generation.
>
>     Freed tokenized strings after argument parsing.
>
>     Returned null from cache_init() if argument cache config is bad.
>
>     Used one enum to indicate the chosen eviction policy.
>
>     Added function pointers for cache update and metadata initialization
>     and destroying. Those pointers are assigned to policy-specific
>     functions.
>
>     Remade LRU. Assigned a generation number that is incremented on each
>     set access to the currently-accessed block's priority. On miss, 
>     evicted the block with the least generation number.
>
>     Allowed to give multiple "evict" arguments and sticked to the last
>     one.
>
> Alex Bennée (1):
>   plugins/api: expose symbol lookup to plugins
>
> Mahmoud Mandour (3):
>   plugins: Added a new cache modelling plugin.
>   plugins/cache: Enabled cache parameterization
>   plugins/cache: Added FIFO and LRU eviction policies.
>
>  contrib/plugins/Makefile   |   1 +
>  contrib/plugins/cache.c    | 642 +++++++++++++++++++++++++++++++++++++
>  include/qemu/qemu-plugin.h |   9 +
>  plugins/api.c              |   6 +
>  4 files changed, 658 insertions(+)
>  create mode 100644 contrib/plugins/cache.c


-- 
Alex Bennée