summaryrefslogtreecommitdiffstats
path: root/include/qemu/rcu_queue.h
Commit message (Collapse)AuthorAgeFilesLines
* qemu/atomic.h: rename atomic_ to qatomic_Stefan Hajnoczi2020-09-231-49/+51
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | clang's C11 atomic_fetch_*() functions only take a C11 atomic type pointer argument. QEMU uses direct types (int, etc) and this causes a compiler error when a QEMU code calls these functions in a source file that also included <stdatomic.h> via a system header file: $ CC=clang CXX=clang++ ./configure ... && make ../util/async.c:79:17: error: address argument to atomic operation must be a pointer to _Atomic type ('unsigned int *' invalid) Avoid using atomic_*() names in QEMU's atomic.h since that namespace is used by <stdatomic.h>. Prefix QEMU's APIs with 'q' so that atomic.h and <stdatomic.h> can co-exist. I checked /usr/include on my machine and searched GitHub for existing "qatomic_" users but there seem to be none. This patch was generated using: $ git grep -h -o '\<atomic\(64\)\?_[a-z0-9_]\+' include/qemu/atomic.h | \ sort -u >/tmp/changed_identifiers $ for identifier in $(</tmp/changed_identifiers); do sed -i "s%\<$identifier\>%q$identifier%g" \ $(git grep -I -l "\<$identifier\>") done I manually fixed line-wrap issues and misaligned rST tables. Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Acked-by: Paolo Bonzini <pbonzini@redhat.com> Message-Id: <20200923105646.47864-1-stefanha@redhat.com>
* rcu_queue: add QSLIST functionsPaolo Bonzini2020-02-221-0/+47
| | | | | | | | | | QSLIST is the only family of lists for which we do not have RCU-friendly accessors, add them. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Message-id: 20200220103828.24525-1-pbonzini@redhat.com Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
* qemu/queue.h: reimplement QTAILQ without pointer-to-pointersPaolo Bonzini2019-01-111-21/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | QTAILQ is a doubly linked list, with a pointer-to-pointer to the last element from the head, and the previous element from each node. But if you squint enough, QTAILQ becomes a combination of a singly-linked forwards list, and another singly-linked list which goes backwards and is circular. This is the idea that lets QTAILQ implement reverse iteration: only, because the backwards list points inside the node, accessing the previous element needs to go two steps back and one forwards. What this patch does is implement it in these terms, without actually changing the in-memory layout at all. The coexistence of the two lists is realized by making QTAILQ_HEAD and QTAILQ_ENTRY unions of the forwards pointer and a generic QTailQLink node. Thq QTailQLink can walk the list in both directions; the union is needed so that the forwards pointer can have the correct type, as a sort of poor man's template. While there are other ways to get the same layout without a union, this one has the advantage of simpler operation in the debugger, because the fields tqh_first and tqe_next still exist as before the patch. Those fields are also used by scripts/qemugdb/mtree.py, so it's a good idea to preserve them. The advantage of the new representation is that the two-back-one-forward dance done by backwards accesses can be done all while operating on QTailQLinks. No casting to the head struct is needed anymore because, even though the QTailQLink's forward pointer is a void *, we can use typeof to recover the correct type. This patch only changes the implementation, not the interface. The next patch will remove the head struct name from the backwards visit macros. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* rcu_queue: add RCU QTAILQEmilio G. Cota2018-08-231-0/+66
| | | | | | Signed-off-by: Emilio G. Cota <cota@braap.org> Message-Id: <20180819091335.22863-5-cota@braap.org> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* rcu_queue: add RCU QSIMPLEQEmilio G. Cota2018-08-231-0/+65
| | | | | | Signed-off-by: Emilio G. Cota <cota@braap.org> Message-Id: <20180819091335.22863-4-cota@braap.org> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* rcu_queue: remove barrier from QLIST_EMPTY_RCUEmilio G. Cota2018-08-231-1/+1
| | | | | | | | It's unnecessary because the pointer isn't dereferenced. Signed-off-by: Emilio G. Cota <cota@braap.org> Message-Id: <20180819091335.22863-3-cota@braap.org> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* rcu_queue: use atomic_set in QLIST_REMOVE_RCUEmilio G. Cota2018-08-231-1/+1
| | | | | | | | To avoid undefined behaviour. Signed-off-by: Emilio G. Cota <cota@braap.org> Message-Id: <20180819091335.22863-2-cota@braap.org> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* Clean up decorations and whitespace around header guardsMarkus Armbruster2016-07-121-1/+1
| | | | | | | Cleaned up with scripts/clean-header-guards.pl. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Richard Henderson <rth@twiddle.net>
* rcu: introduce RCU-enabled QLISTMike Day2015-02-161-0/+134
Add RCU-enabled variants on the existing bsd DQ facility. Each operation has the same interface as the existing (non-RCU) version. Also, each operation is implemented as macro. Using the RCU-enabled QLIST, existing QLIST users will be able to convert to RCU without using a different list interface. Signed-off-by: Mike Day <ncmike@ncultra.org> Reviewed-by: Fam Zheng <famz@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>