From: wanghonghao <wanghonghao@bytedance.com>
To: qemu-devel@nongnu.org
Cc: kwolf@redhat.com, wanghonghao <wanghonghao@bytedance.com>,
stefanha@redhat.com
Subject: [PATCH 1/2] QSLIST: add atomic replace operation
Date: Thu, 13 Aug 2020 12:44:44 +0800 [thread overview]
Message-ID: <20200813044445.23233-1-wanghonghao@bytedance.com> (raw)
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 456a5b01ee..a3ff544193 100644
--- a/include/qemu/queue.h
+++ b/include/qemu/queue.h
@@ -226,6 +226,10 @@ struct { \
(dest)->slh_first = atomic_xchg(&(src)->slh_first, NULL); \
} while (/*CONSTCOND*/0)
+#define QSLIST_REPLACE_ATOMIC(dest, src) do { \
+ (src)->slh_first = atomic_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)
next reply other threads:[~2020-08-13 13:38 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-13 4:44 wanghonghao [this message]
2020-08-13 4:44 ` [PATCH 2/2] coroutine: take exactly one batch from global pool at a time wanghonghao
2020-08-24 4:31 [PATCH 1/2] QSLIST: add atomic replace operation wanghonghao
2020-08-24 15:26 ` Stefan Hajnoczi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200813044445.23233-1-wanghonghao@bytedance.com \
--to=wanghonghao@bytedance.com \
--cc=kwolf@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).