qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@redhat.com>
To: wanghonghao <wanghonghao@bytedance.com>
Cc: kwolf@redhat.com, pbonzini@redhat.com, fam@euphon.net,
	qemu-devel@nongnu.org
Subject: Re: [PATCH 1/2] QSLIST: add atomic replace operation
Date: Mon, 24 Aug 2020 16:26:59 +0100	[thread overview]
Message-ID: <20200824152659.GA7124@stefanha-x1.localdomain> (raw)
In-Reply-To: <20200824043121.13421-1-wanghonghao@bytedance.com>

[-- Attachment #1: Type: text/plain, Size: 1089 bytes --]

On Mon, Aug 24, 2020 at 12:31:20PM +0800, wanghonghao wrote:
> 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)

This is atomic for dest but not src.

Maybe the name should make this clear: QSLIST_REPLACE_ATOMIC_DEST().

Please also add a doc comment mentioning that the modification to src is
not atomic.

Stefan

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  parent reply	other threads:[~2020-08-24 15:28 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-24  4:31 [PATCH 1/2] QSLIST: add atomic replace operation wanghonghao
2020-08-24  4:31 ` [PATCH 2/2] coroutine: take exactly one batch from global pool at a time wanghonghao
2020-08-25 14:52   ` Stefan Hajnoczi
2020-08-26  6:06     ` [External] " 王洪浩
2020-09-29  3:24       ` PING: " 王洪浩
2020-10-13 10:04         ` Stefan Hajnoczi
2020-08-24 15:26 ` Stefan Hajnoczi [this message]
2020-08-25  3:33   ` [External] Re: [PATCH 1/2] QSLIST: add atomic replace operation 王洪浩
2020-08-25  3:37   ` [PATCH v2 " wanghonghao
2020-08-25  3:37     ` [PATCH v2 2/2] coroutine: take exactly one batch from global pool at a time wanghonghao
  -- strict thread matches above, loose matches on Subject: below --
2020-08-13  4:44 [PATCH 1/2] QSLIST: add atomic replace operation wanghonghao

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=20200824152659.GA7124@stefanha-x1.localdomain \
    --to=stefanha@redhat.com \
    --cc=fam@euphon.net \
    --cc=kwolf@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=wanghonghao@bytedance.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).