qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Fam Zheng <famz@redhat.com>
To: qemu-devel@nongnu.org
Cc: kwolf@redhat.com, stefanha@redhat.com
Subject: [Qemu-devel] [PATCH 1/3] HBitmap: move struct HBitmap to header
Date: Wed, 30 Oct 2013 15:08:10 +0800	[thread overview]
Message-ID: <1383116892-11047-2-git-send-email-famz@redhat.com> (raw)
In-Reply-To: <1383116892-11047-1-git-send-email-famz@redhat.com>

The struct field will be used outside of hbitmap.c once become a list,
move it to public header.

Signed-off-by: Fam Zheng <famz@redhat.com>
---
 include/qemu/hbitmap.h | 39 +++++++++++++++++++++++++++++++++++++++
 util/hbitmap.c         | 38 --------------------------------------
 2 files changed, 39 insertions(+), 38 deletions(-)

diff --git a/include/qemu/hbitmap.h b/include/qemu/hbitmap.h
index 550d7ce..b6ea5c7 100644
--- a/include/qemu/hbitmap.h
+++ b/include/qemu/hbitmap.h
@@ -19,6 +19,7 @@
 #include "host-utils.h"
 
 typedef struct HBitmap HBitmap;
+
 typedef struct HBitmapIter HBitmapIter;
 
 #define BITS_PER_LEVEL         (BITS_PER_LONG == 32 ? 5 : 6)
@@ -51,6 +52,44 @@ struct HBitmapIter {
     unsigned long cur[HBITMAP_LEVELS];
 };
 
+struct HBitmap {
+    /* Number of total bits in the bottom level.  */
+    uint64_t size;
+
+    /* Number of set bits in the bottom level.  */
+    uint64_t count;
+
+    /* A scaling factor.  Given a granularity of G, each bit in the bitmap will
+     * will actually represent a group of 2^G elements.  Each operation on a
+     * range of bits first rounds the bits to determine which group they land
+     * in, and then affect the entire page; iteration will only visit the first
+     * bit of each group.  Here is an example of operations in a size-16,
+     * granularity-1 HBitmap:
+     *
+     *    initial state            00000000
+     *    set(start=0, count=9)    11111000 (iter: 0, 2, 4, 6, 8)
+     *    reset(start=1, count=3)  00111000 (iter: 4, 6, 8)
+     *    set(start=9, count=2)    00111100 (iter: 4, 6, 8, 10)
+     *    reset(start=5, count=5)  00000000
+     *
+     * From an implementation point of view, when setting or resetting bits,
+     * the bitmap will scale bit numbers right by this amount of bits.  When
+     * iterating, the bitmap will scale bit numbers left by this amount of
+     * bits.
+     */
+    int granularity;
+
+    /* A number of progressively less coarse bitmaps (i.e. level 0 is the
+     * coarsest).  Each bit in level N represents a word in level N+1 that
+     * has a set bit, except the last level where each bit represents the
+     * actual bitmap.
+     *
+     * Note that all bitmaps have the same number of levels.  Even a 1-bit
+     * bitmap will still allocate HBITMAP_LEVELS arrays.
+     */
+    unsigned long *levels[HBITMAP_LEVELS];
+};
+
 /**
  * hbitmap_alloc:
  * @size: Number of bits in the bitmap.
diff --git a/util/hbitmap.c b/util/hbitmap.c
index d936831..5dddd05 100644
--- a/util/hbitmap.c
+++ b/util/hbitmap.c
@@ -54,44 +54,6 @@
  * O(logB n) as in the non-amortized complexity).
  */
 
-struct HBitmap {
-    /* Number of total bits in the bottom level.  */
-    uint64_t size;
-
-    /* Number of set bits in the bottom level.  */
-    uint64_t count;
-
-    /* A scaling factor.  Given a granularity of G, each bit in the bitmap will
-     * will actually represent a group of 2^G elements.  Each operation on a
-     * range of bits first rounds the bits to determine which group they land
-     * in, and then affect the entire page; iteration will only visit the first
-     * bit of each group.  Here is an example of operations in a size-16,
-     * granularity-1 HBitmap:
-     *
-     *    initial state            00000000
-     *    set(start=0, count=9)    11111000 (iter: 0, 2, 4, 6, 8)
-     *    reset(start=1, count=3)  00111000 (iter: 4, 6, 8)
-     *    set(start=9, count=2)    00111100 (iter: 4, 6, 8, 10)
-     *    reset(start=5, count=5)  00000000
-     *
-     * From an implementation point of view, when setting or resetting bits,
-     * the bitmap will scale bit numbers right by this amount of bits.  When
-     * iterating, the bitmap will scale bit numbers left by this amount of
-     * bits.
-     */
-    int granularity;
-
-    /* A number of progressively less coarse bitmaps (i.e. level 0 is the
-     * coarsest).  Each bit in level N represents a word in level N+1 that
-     * has a set bit, except the last level where each bit represents the
-     * actual bitmap.
-     *
-     * Note that all bitmaps have the same number of levels.  Even a 1-bit
-     * bitmap will still allocate HBITMAP_LEVELS arrays.
-     */
-    unsigned long *levels[HBITMAP_LEVELS];
-};
-
 static inline int popcountl(unsigned long l)
 {
     return BITS_PER_LONG == 32 ? ctpop32(l) : ctpop64(l);
-- 
1.8.3.1

  reply	other threads:[~2013-10-30  7:08 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-30  7:08 [Qemu-devel] [PATCH 0/3] block: per caller dirty bitmap Fam Zheng
2013-10-30  7:08 ` Fam Zheng [this message]
2013-10-30  7:08 ` [Qemu-devel] [PATCH 2/3] HBitmap: add QLIST_ENTRY to HBitmap Fam Zheng
2013-10-30  7:49   ` Paolo Bonzini
2013-10-30  7:08 ` [Qemu-devel] [PATCH 3/3] block: per caller dirty bitmap Fam Zheng
2013-10-30  7:26   ` Fam Zheng
2013-10-30  7:49   ` Paolo Bonzini
2013-11-04  6:59     ` Fam Zheng
2013-11-04 10:34       ` Paolo Bonzini

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=1383116892-11047-2-git-send-email-famz@redhat.com \
    --to=famz@redhat.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).