From: Paolo Bonzini <pbonzini@redhat.com>
To: Stefan Hajnoczi <stefanha@redhat.com>, qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>,
rth@redhat.com, Juan Quintela <quintela@redhat.com>
Subject: Re: [Qemu-devel] [RFC 1/6] bitmap: add atomic set functions
Date: Thu, 27 Nov 2014 17:42:41 +0100 [thread overview]
Message-ID: <54775481.9020605@redhat.com> (raw)
In-Reply-To: <1417091366-4469-2-git-send-email-stefanha@redhat.com>
On 27/11/2014 13:29, Stefan Hajnoczi wrote:
> +void bitmap_set_atomic(unsigned long *map, long start, long nr)
> +{
> + unsigned long *p = map + BIT_WORD(start);
> + const long size = start + nr;
> + int bits_to_set = BITS_PER_LONG - (start % BITS_PER_LONG);
> + unsigned long mask_to_set = BITMAP_FIRST_WORD_MASK(start);
> +
> + while (nr - bits_to_set >= 0) {
> + atomic_or(p, mask_to_set);
atomic_or is unnecessary while mask_to_set is ~0UL. I think not even a
smp_wmb() is necessary.
Paolo
> + nr -= bits_to_set;
> + bits_to_set = BITS_PER_LONG;
> + mask_to_set = ~0UL;
> + p++;
> + }
> + if (nr) {
> + mask_to_set &= BITMAP_LAST_WORD_MASK(size);
> + atomic_or(p, mask_to_set);
> + }
> +}
> +
next prev parent reply other threads:[~2014-11-27 16:43 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-27 12:29 [Qemu-devel] [RFC 0/6] memory: make dirty_memory[] accesses atomic Stefan Hajnoczi
2014-11-27 12:29 ` [Qemu-devel] [RFC 1/6] bitmap: add atomic set functions Stefan Hajnoczi
2014-11-27 16:42 ` Paolo Bonzini [this message]
2014-12-01 13:52 ` Stefan Hajnoczi
2014-11-27 12:29 ` [Qemu-devel] [RFC 2/6] bitmap: add atomic test and clear Stefan Hajnoczi
2014-11-27 16:43 ` Paolo Bonzini
2014-12-01 13:53 ` Stefan Hajnoczi
2014-11-27 12:29 ` [Qemu-devel] [RFC 3/6] memory: use atomic ops for setting dirty memory bits Stefan Hajnoczi
2014-11-27 12:29 ` [Qemu-devel] [RFC 4/6] migration: move dirty bitmap sync to ram_addr.h Stefan Hajnoczi
2014-11-27 16:29 ` Dr. David Alan Gilbert
2014-12-01 14:01 ` Stefan Hajnoczi
2014-12-01 14:49 ` Dr. David Alan Gilbert
2014-11-27 12:29 ` [Qemu-devel] [RFC 5/6] memory: replace cpu_physical_memory_reset_dirty() with test-and-clear Stefan Hajnoczi
2014-11-27 12:29 ` [Qemu-devel] [RFC 6/6] memory: make cpu_physical_memory_sync_dirty_bitmap() fully atomic Stefan Hajnoczi
2014-11-27 13:21 ` [Qemu-devel] [RFC 0/6] memory: make dirty_memory[] accesses atomic Peter Maydell
2014-11-28 12:44 ` Stefan Hajnoczi
2015-03-23 11:09 ` Paolo Bonzini
2015-03-24 16:48 ` 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=54775481.9020605@redhat.com \
--to=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=quintela@redhat.com \
--cc=rth@redhat.com \
--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).