[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 60/62] qsp: Use WITH_RCU_READ_LOCK_GUARD
From: |
Paolo Bonzini |
Subject: |
[PULL 60/62] qsp: Use WITH_RCU_READ_LOCK_GUARD |
Date: |
Mon, 16 Dec 2019 17:28:44 +0100 |
From: "Dr. David Alan Gilbert" <address@hidden>
The automatic rcu read lock maintenance works quite
nicely in this case where it previously relied on a comment to
delimit the lifetime and now has a block.
Signed-off-by: Dr. David Alan Gilbert <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
---
util/qsp.c | 22 ++++++++++------------
1 file changed, 10 insertions(+), 12 deletions(-)
diff --git a/util/qsp.c b/util/qsp.c
index 6226541..7d5147f 100644
--- a/util/qsp.c
+++ b/util/qsp.c
@@ -598,7 +598,6 @@ static void qsp_ht_delete(void *p, uint32_t h, void *htp)
static void qsp_mktree(GTree *tree, bool callsite_coalesce)
{
- QSPSnapshot *snap;
struct qht ht, coalesce_ht;
struct qht *htp;
@@ -610,20 +609,19 @@ static void qsp_mktree(GTree *tree, bool
callsite_coalesce)
* We must remain in an RCU read-side critical section until we're done
* with the snapshot.
*/
- rcu_read_lock();
- snap = atomic_rcu_read(&qsp_snapshot);
+ WITH_RCU_READ_LOCK_GUARD() {
+ QSPSnapshot *snap = atomic_rcu_read(&qsp_snapshot);
- /* Aggregate all results from the global hash table into a local one */
- qht_init(&ht, qsp_entry_no_thread_cmp, QSP_INITIAL_SIZE,
- QHT_MODE_AUTO_RESIZE | QHT_MODE_RAW_MUTEXES);
- qht_iter(&qsp_ht, qsp_aggregate, &ht);
+ /* Aggregate all results from the global hash table into a local one */
+ qht_init(&ht, qsp_entry_no_thread_cmp, QSP_INITIAL_SIZE,
+ QHT_MODE_AUTO_RESIZE | QHT_MODE_RAW_MUTEXES);
+ qht_iter(&qsp_ht, qsp_aggregate, &ht);
- /* compute the difference wrt the snapshot, if any */
- if (snap) {
- qsp_diff(&snap->ht, &ht);
+ /* compute the difference wrt the snapshot, if any */
+ if (snap) {
+ qsp_diff(&snap->ht, &ht);
+ }
}
- /* done with the snapshot; RCU can reclaim it */
- rcu_read_unlock();
htp = &ht;
if (callsite_coalesce) {
--
1.8.3.1
- [PULL 46/62] hw: replace hw/i386/pc.h with a header just for the i8259, (continued)
- [PULL 46/62] hw: replace hw/i386/pc.h with a header just for the i8259, Paolo Bonzini, 2019/12/16
- [PULL 49/62] hw/i386/pc: Convert DPRINTF() to trace events, Paolo Bonzini, 2019/12/16
- [PULL 51/62] acpi: move PC stubs out of stubs/, Paolo Bonzini, 2019/12/16
- [PULL 56/62] hw/i386/pc: Use TYPE_PORT92 instead of hardcoded string, Paolo Bonzini, 2019/12/16
- [PULL 54/62] hw/i386: Simplify ioapic_init_gsi(), Paolo Bonzini, 2019/12/16
- [PULL 55/62] hw/isa/isa-bus: cleanup irq functions, Paolo Bonzini, 2019/12/16
- [PULL 59/62] hyperv: Use auto rcu_read macros, Paolo Bonzini, 2019/12/16
- [PULL 62/62] colo: fix return without releasing RCU, Paolo Bonzini, 2019/12/16
- [PULL 57/62] hw/i386/pc: Inline port92_init(), Paolo Bonzini, 2019/12/16
- [PULL 58/62] hw/i386/pc: Extract the port92 device, Paolo Bonzini, 2019/12/16
- [PULL 60/62] qsp: Use WITH_RCU_READ_LOCK_GUARD,
Paolo Bonzini <=
- [PULL 61/62] memory: use RCU_READ_LOCK_GUARD, Paolo Bonzini, 2019/12/16
- Re: [PULL 00/62] Misc patches for 2019-12-16, Peter Maydell, 2019/12/17