qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 1/2] QSLIST: add atomic replace operation
@ 2020-10-16 11:26 wanghonghao
  2020-10-16 11:26 ` [PATCH v3 2/2] coroutine: take exactly one batch from global pool at a time wanghonghao
  0 siblings, 1 reply; 4+ messages in thread
From: wanghonghao @ 2020-10-16 11:26 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, pbonzini, fam, wanghonghao, stefanha

Replace a queue with another atomicly. It's useful when we need to transfer
queues between threads.

Signed-off-by: wanghonghao <wanghonghao@bytedance.com>
---
 include/qemu/queue.h | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/include/qemu/queue.h b/include/qemu/queue.h
index e029e7bf66..1f0cbdf87e 100644
--- a/include/qemu/queue.h
+++ b/include/qemu/queue.h
@@ -226,6 +226,10 @@ struct {                                                                \
         (dest)->slh_first = qatomic_xchg(&(src)->slh_first, NULL);       \
 } while (/*CONSTCOND*/0)
 
+#define QSLIST_REPLACE_ATOMIC(dest, src, old) do {                            \
+        (old)->slh_first = qatomic_xchg(&(dest)->slh_first, (src)->slh_first); \
+} while (/*CONSTCOND*/0)
+
 #define QSLIST_REMOVE_HEAD(head, field) do {                             \
         typeof((head)->slh_first) elm = (head)->slh_first;               \
         (head)->slh_first = elm->field.sle_next;                         \
-- 
2.24.3 (Apple Git-128)



^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-03-11  3:29 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-16 11:26 [PATCH v3 1/2] QSLIST: add atomic replace operation wanghonghao
2020-10-16 11:26 ` [PATCH v3 2/2] coroutine: take exactly one batch from global pool at a time wanghonghao
2021-03-08 10:27   ` Stefan Hajnoczi
2021-03-11  3:27     ` [External] " 王洪浩

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).