diff options
author | Paolo Bonzini | 2017-06-05 14:39:08 +0200 |
---|---|---|
committer | Fam Zheng | 2017-06-16 01:55:00 +0200 |
commit | 5b50bf77ce6e773b04a303a2912876c9a1bfca43 (patch) | |
tree | a6b8974b2e58fb9a980c0ed19d0cd58de3f427f7 /include/block/accounting.h | |
parent | block: split BlockAcctStats creation and setup (diff) | |
download | qemu-5b50bf77ce6e773b04a303a2912876c9a1bfca43.tar.gz qemu-5b50bf77ce6e773b04a303a2912876c9a1bfca43.tar.xz qemu-5b50bf77ce6e773b04a303a2912876c9a1bfca43.zip |
block: make accounting thread-safe
I'm not trying too hard yet. Later, with multiqueue support,
this may cause mutex contention or cacheline bouncing.
Cc: Alberto Garcia <berto@igalia.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20170605123908.18777-20-pbonzini@redhat.com>
Reviewed-by: Alberto Garcia <berto@igalia.com>
Signed-off-by: Fam Zheng <famz@redhat.com>
Diffstat (limited to 'include/block/accounting.h')
-rw-r--r-- | include/block/accounting.h | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/include/block/accounting.h b/include/block/accounting.h index 55cb06fdb6..b833d26d6c 100644 --- a/include/block/accounting.h +++ b/include/block/accounting.h @@ -26,8 +26,10 @@ #define BLOCK_ACCOUNTING_H #include "qemu/timed-average.h" +#include "qemu/thread.h" typedef struct BlockAcctTimedStats BlockAcctTimedStats; +typedef struct BlockAcctStats BlockAcctStats; enum BlockAcctType { BLOCK_ACCT_READ, @@ -37,12 +39,14 @@ enum BlockAcctType { }; struct BlockAcctTimedStats { + BlockAcctStats *stats; TimedAverage latency[BLOCK_MAX_IOTYPE]; unsigned interval_length; /* in seconds */ QSLIST_ENTRY(BlockAcctTimedStats) entries; }; -typedef struct BlockAcctStats { +struct BlockAcctStats { + QemuMutex lock; uint64_t nr_bytes[BLOCK_MAX_IOTYPE]; uint64_t nr_ops[BLOCK_MAX_IOTYPE]; uint64_t invalid_ops[BLOCK_MAX_IOTYPE]; @@ -53,7 +57,7 @@ typedef struct BlockAcctStats { QSLIST_HEAD(, BlockAcctTimedStats) intervals; bool account_invalid; bool account_failed; -} BlockAcctStats; +}; typedef struct BlockAcctCookie { int64_t bytes; |