From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
To: Juan Quintela <quintela@redhat.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 51/54] ram: Use ramblock and page offset instead of absolute offset
Date: Fri, 7 Apr 2017 11:53:22 +0100 [thread overview]
Message-ID: <20170407105321.GI2138@work-vm> (raw)
In-Reply-To: <20170406130913.2232-52-quintela@redhat.com>
* Juan Quintela (quintela@redhat.com) wrote:
> This removes the needto pass also the absolute offset.
>
> Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
> ---
> migration/ram.c | 65 ++++++++++++++++++++++++---------------------------------
> 1 file changed, 27 insertions(+), 38 deletions(-)
>
> diff --git a/migration/ram.c b/migration/ram.c
> index 4132503..fc1f08f 100644
> --- a/migration/ram.c
> +++ b/migration/ram.c
> @@ -609,12 +609,10 @@ static int save_xbzrle_page(RAMState *rs, uint8_t **current_data,
> * @rs: current RAM state
> * @rb: RAMBlock where to search for dirty pages
> * @start: page where we start the search
> - * @page_abs: pointer into where to store the dirty page
> */
> static inline
> unsigned long migration_bitmap_find_dirty(RAMState *rs, RAMBlock *rb,
> - unsigned long start,
> - unsigned long *page_abs)
> + unsigned long start)
> {
> unsigned long base = rb->offset >> TARGET_PAGE_BITS;
> unsigned long nr = base + start;
> @@ -631,17 +629,18 @@ unsigned long migration_bitmap_find_dirty(RAMState *rs, RAMBlock *rb,
> next = find_next_bit(bitmap, size, nr);
> }
>
> - *page_abs = next;
> return next - base;
> }
>
> static inline bool migration_bitmap_clear_dirty(RAMState *rs,
> - unsigned long page_abs)
> + RAMBlock *rb,
> + unsigned long page)
> {
> bool ret;
> unsigned long *bitmap = atomic_rcu_read(&rs->ram_bitmap)->bmap;
> + unsigned long nr = (rb->offset >> TARGET_PAGE_BITS) + page;
>
> - ret = test_and_clear_bit(page_abs, bitmap);
> + ret = test_and_clear_bit(nr, bitmap);
>
> if (ret) {
> rs->migration_dirty_pages--;
> @@ -1053,13 +1052,10 @@ static int ram_save_compressed_page(RAMState *rs, PageSearchStatus *pss,
> * @rs: current RAM state
> * @pss: data about the state of the current dirty page scan
> * @again: set to false if the search has scanned the whole of RAM
> - * @page_abs: pointer into where to store the dirty page
> */
> -static bool find_dirty_block(RAMState *rs, PageSearchStatus *pss,
> - bool *again, unsigned long *page_abs)
> +static bool find_dirty_block(RAMState *rs, PageSearchStatus *pss, bool *again)
> {
> - pss->page = migration_bitmap_find_dirty(rs, pss->block, pss->page,
> - page_abs);
> + pss->page = migration_bitmap_find_dirty(rs, pss->block, pss->page);
> if (pss->complete_round && pss->block == rs->last_seen_block &&
> pss->page >= rs->last_page) {
> /*
> @@ -1106,10 +1102,8 @@ static bool find_dirty_block(RAMState *rs, PageSearchStatus *pss,
> *
> * @rs: current RAM state
> * @offset: used to return the offset within the RAMBlock
> - * @page_abs: pointer into where to store the dirty page
> */
> -static RAMBlock *unqueue_page(RAMState *rs, ram_addr_t *offset,
> - unsigned long *page_abs)
> +static RAMBlock *unqueue_page(RAMState *rs, ram_addr_t *offset)
> {
> RAMBlock *block = NULL;
>
> @@ -1119,7 +1113,6 @@ static RAMBlock *unqueue_page(RAMState *rs, ram_addr_t *offset,
> QSIMPLEQ_FIRST(&rs->src_page_requests);
> block = entry->rb;
> *offset = entry->offset;
> - *page_abs = (entry->offset + entry->rb->offset) >> TARGET_PAGE_BITS;
>
> if (entry->len > TARGET_PAGE_SIZE) {
> entry->len -= TARGET_PAGE_SIZE;
> @@ -1144,17 +1137,15 @@ static RAMBlock *unqueue_page(RAMState *rs, ram_addr_t *offset,
> *
> * @rs: current RAM state
> * @pss: data about the state of the current dirty page scan
> - * @page_abs: pointer into where to store the dirty page
> */
> -static bool get_queued_page(RAMState *rs, PageSearchStatus *pss,
> - unsigned long *page_abs)
> +static bool get_queued_page(RAMState *rs, PageSearchStatus *pss)
> {
> RAMBlock *block;
> ram_addr_t offset;
> bool dirty;
>
> do {
> - block = unqueue_page(rs, &offset, page_abs);
> + block = unqueue_page(rs, &offset);
> /*
> * We're sending this page, and since it's postcopy nothing else
> * will dirty it, and we must make sure it doesn't get sent again
> @@ -1163,16 +1154,18 @@ static bool get_queued_page(RAMState *rs, PageSearchStatus *pss,
> */
> if (block) {
> unsigned long *bitmap;
> + unsigned long page;
> +
> bitmap = atomic_rcu_read(&rs->ram_bitmap)->bmap;
> - dirty = test_bit(*page_abs, bitmap);
> + page = (block->offset + offset) >> TARGET_PAGE_BITS;
> + dirty = test_bit(page, bitmap);
> if (!dirty) {
> trace_get_queued_page_not_dirty(block->idstr, (uint64_t)offset,
> - *page_abs,
> - test_bit(*page_abs,
> + page,
> + test_bit(page,
> atomic_rcu_read(&rs->ram_bitmap)->unsentmap));
> } else {
> - trace_get_queued_page(block->idstr, (uint64_t)offset,
> - *page_abs);
> + trace_get_queued_page(block->idstr, (uint64_t)offset, page);
> }
> }
>
> @@ -1300,22 +1293,22 @@ err:
> * @ms: current migration state
> * @pss: data about the page we want to send
> * @last_stage: if we are at the completion stage
> - * @page_abs: page number of the dirty page
> */
> static int ram_save_target_page(RAMState *rs, PageSearchStatus *pss,
> - bool last_stage, unsigned long page_abs)
> + bool last_stage)
> {
> int res = 0;
>
> /* Check the pages is dirty and if it is send it */
> - if (migration_bitmap_clear_dirty(rs, page_abs)) {
> + if (migration_bitmap_clear_dirty(rs, pss->block, pss->page)) {
> unsigned long *unsentmap;
> /*
> * If xbzrle is on, stop using the data compression after first
> * round of migration even if compression is enabled. In theory,
> * xbzrle can do better than compression.
> */
> -
> + unsigned long page =
> + (pss->block->offset >> TARGET_PAGE_BITS) + pss->page;
> if (migrate_use_compression()
> && (rs->ram_bulk_stage || !migrate_use_xbzrle())) {
> res = ram_save_compressed_page(rs, pss, last_stage);
> @@ -1328,7 +1321,7 @@ static int ram_save_target_page(RAMState *rs, PageSearchStatus *pss,
> }
> unsentmap = atomic_rcu_read(&rs->ram_bitmap)->unsentmap;
> if (unsentmap) {
> - clear_bit(page_abs, unsentmap);
> + clear_bit(page, unsentmap);
> }
> }
>
> @@ -1350,25 +1343,22 @@ static int ram_save_target_page(RAMState *rs, PageSearchStatus *pss,
> * @ms: current migration state
> * @pss: data about the page we want to send
> * @last_stage: if we are at the completion stage
> - * @page_abs: Page number of the dirty page
> */
> static int ram_save_host_page(RAMState *rs, PageSearchStatus *pss,
> - bool last_stage,
> - unsigned long page_abs)
> + bool last_stage)
> {
> int tmppages, pages = 0;
> size_t pagesize_bits =
> qemu_ram_pagesize(pss->block) >> TARGET_PAGE_BITS;
>
> do {
> - tmppages = ram_save_target_page(rs, pss, last_stage, page_abs);
> + tmppages = ram_save_target_page(rs, pss, last_stage);
> if (tmppages < 0) {
> return tmppages;
> }
>
> pages += tmppages;
> pss->page++;
> - page_abs++;
> } while (pss->page & (pagesize_bits - 1));
>
> /* The offset we leave with is the last one we looked at */
> @@ -1395,7 +1385,6 @@ static int ram_find_and_save_block(RAMState *rs, bool last_stage)
> PageSearchStatus pss;
> int pages = 0;
> bool again, found;
> - unsigned long page_abs; /* Page number of the dirty page */
>
> /* No dirty page as there is zero RAM */
> if (!ram_bytes_total()) {
> @@ -1412,15 +1401,15 @@ static int ram_find_and_save_block(RAMState *rs, bool last_stage)
>
> do {
> again = true;
> - found = get_queued_page(rs, &pss, &page_abs);
> + found = get_queued_page(rs, &pss);
>
> if (!found) {
> /* priority queue empty, so just search for something dirty */
> - found = find_dirty_block(rs, &pss, &again, &page_abs);
> + found = find_dirty_block(rs, &pss, &again);
> }
>
> if (found) {
> - pages = ram_save_host_page(rs, &pss, last_stage, page_abs);
> + pages = ram_save_host_page(rs, &pss, last_stage);
> }
> } while (!pages && again);
>
> --
> 2.9.3
>
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
next prev parent reply other threads:[~2017-04-07 10:53 UTC|newest]
Thread overview: 70+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-06 13:08 [Qemu-devel] [PATCH v3 00/54] Creating RAMState for migration Juan Quintela
2017-04-06 13:08 ` [Qemu-devel] [PATCH 01/54] ram: Update all functions comments Juan Quintela
2017-04-06 13:08 ` [Qemu-devel] [PATCH 02/54] ram: Rename flush_page_queue() to migration_page_queue_free() Juan Quintela
2017-04-07 9:25 ` Dr. David Alan Gilbert
2017-04-11 3:44 ` Peter Xu
2017-04-06 13:08 ` [Qemu-devel] [PATCH 03/54] ram: Rename block_name to rbname Juan Quintela
2017-04-06 13:08 ` [Qemu-devel] [PATCH 04/54] ram: Create RAMState Juan Quintela
2017-04-06 13:08 ` [Qemu-devel] [PATCH 05/54] ram: Add dirty_rate_high_cnt to RAMState Juan Quintela
2017-04-06 13:08 ` [Qemu-devel] [PATCH 06/54] ram: Move bitmap_sync_count into RAMState Juan Quintela
2017-04-06 13:08 ` [Qemu-devel] [PATCH 07/54] ram: Move start time " Juan Quintela
2017-04-06 13:08 ` [Qemu-devel] [PATCH 08/54] ram: Move bytes_xfer_prev " Juan Quintela
2017-04-11 3:47 ` Peter Xu
2017-04-06 13:08 ` [Qemu-devel] [PATCH 09/54] ram: Change byte_xfer_now type to uint64_t Juan Quintela
2017-04-07 9:39 ` Dr. David Alan Gilbert
2017-04-11 3:49 ` Peter Xu
2017-04-06 13:08 ` [Qemu-devel] [PATCH 10/54] ram: Move num_dirty_pages_period into RAMState Juan Quintela
2017-04-06 13:08 ` [Qemu-devel] [PATCH 11/54] ram: Change num_dirty_pages_period type to uint64_t Juan Quintela
2017-04-07 9:44 ` Dr. David Alan Gilbert
2017-04-11 4:08 ` Peter Xu
2017-04-06 13:08 ` [Qemu-devel] [PATCH 12/54] ram: Move xbzrle_cache_miss_prev into RAMState Juan Quintela
2017-04-06 13:08 ` [Qemu-devel] [PATCH 13/54] ram: Move iterations_prev " Juan Quintela
2017-04-06 13:08 ` [Qemu-devel] [PATCH 14/54] ram: Move dup_pages " Juan Quintela
2017-04-06 13:08 ` [Qemu-devel] [PATCH 15/54] ram: Remove unused dup_mig_bytes_transferred() Juan Quintela
2017-04-06 13:08 ` [Qemu-devel] [PATCH 16/54] ram: Remove unused pages_skipped variable Juan Quintela
2017-04-06 13:08 ` [Qemu-devel] [PATCH 17/54] ram: Move norm_pages to RAMState Juan Quintela
2017-04-06 13:08 ` [Qemu-devel] [PATCH 18/54] ram: Remove norm_mig_bytes_transferred Juan Quintela
2017-04-06 13:08 ` [Qemu-devel] [PATCH 19/54] ram: Move iterations into RAMState Juan Quintela
2017-04-06 13:08 ` [Qemu-devel] [PATCH 20/54] ram: Move xbzrle_bytes " Juan Quintela
2017-04-06 13:08 ` [Qemu-devel] [PATCH 21/54] ram: Move xbzrle_pages " Juan Quintela
2017-04-06 13:08 ` [Qemu-devel] [PATCH 22/54] ram: Move xbzrle_cache_miss " Juan Quintela
2017-04-06 13:08 ` [Qemu-devel] [PATCH 23/54] ram: Move xbzrle_cache_miss_rate " Juan Quintela
2017-04-06 13:08 ` [Qemu-devel] [PATCH 24/54] ram: Move xbzrle_overflows " Juan Quintela
2017-04-06 13:08 ` [Qemu-devel] [PATCH 25/54] ram: Move migration_dirty_pages to RAMState Juan Quintela
2017-04-06 13:08 ` [Qemu-devel] [PATCH 26/54] ram: Everything was init to zero, so use memset Juan Quintela
2017-04-06 13:08 ` [Qemu-devel] [PATCH 27/54] ram: Move migration_bitmap_mutex into RAMState Juan Quintela
2017-04-06 13:08 ` [Qemu-devel] [PATCH 28/54] ram: Move migration_bitmap_rcu " Juan Quintela
2017-04-06 13:08 ` [Qemu-devel] [PATCH 29/54] ram: Move bytes_transferred " Juan Quintela
2017-04-06 13:08 ` [Qemu-devel] [PATCH 30/54] ram: Use the RAMState bytes_transferred parameter Juan Quintela
2017-04-06 13:08 ` [Qemu-devel] [PATCH 31/54] ram: Remove ram_save_remaining Juan Quintela
2017-04-06 13:08 ` [Qemu-devel] [PATCH 32/54] ram: Move last_req_rb to RAMState Juan Quintela
2017-04-06 13:08 ` [Qemu-devel] [PATCH 33/54] ram: Move src_page_req* " Juan Quintela
2017-04-06 13:08 ` [Qemu-devel] [PATCH 34/54] ram: Create ram_dirty_sync_count() Juan Quintela
2017-04-06 13:08 ` [Qemu-devel] [PATCH 35/54] ram: Remove dirty_bytes_rate Juan Quintela
2017-04-06 13:08 ` [Qemu-devel] [PATCH 36/54] ram: Move dirty_pages_rate to RAMState Juan Quintela
2017-04-06 13:08 ` [Qemu-devel] [PATCH 37/54] ram: Move postcopy_requests into RAMState Juan Quintela
2017-04-06 13:08 ` [Qemu-devel] [PATCH 38/54] ram: Add QEMUFile to RAMState Juan Quintela
2017-04-06 13:08 ` [Qemu-devel] [PATCH 39/54] ram: Move QEMUFile into RAMState Juan Quintela
2017-04-06 13:08 ` [Qemu-devel] [PATCH 40/54] ram: Remove compression_switch and inline its logic Juan Quintela
2017-04-07 9:46 ` Dr. David Alan Gilbert
2017-04-11 4:14 ` Peter Xu
2017-04-18 18:17 ` Juan Quintela
2017-04-06 13:09 ` [Qemu-devel] [PATCH 41/54] migration: Remove MigrationState from migration_in_postcopy Juan Quintela
2017-04-06 13:09 ` [Qemu-devel] [PATCH 42/54] ram: We don't need MigrationState parameter anymore Juan Quintela
2017-04-06 13:09 ` [Qemu-devel] [PATCH 43/54] ram: Rename qemu_target_page_bits() to qemu_target_page_size() Juan Quintela
2017-04-06 13:09 ` [Qemu-devel] [PATCH 44/54] ram: Add page-size to output in 'info migrate' Juan Quintela
2017-04-06 13:09 ` [Qemu-devel] [PATCH 45/54] ram: Pass RAMBlock to bitmap_sync Juan Quintela
2017-04-07 10:01 ` Dr. David Alan Gilbert
2017-04-06 13:09 ` [Qemu-devel] [PATCH 46/54] ram: ram_discard_range() don't use the mis parameter Juan Quintela
2017-04-06 13:09 ` [Qemu-devel] [PATCH 47/54] ram: reorganize last_sent_block Juan Quintela
2017-04-06 13:09 ` [Qemu-devel] [PATCH 48/54] ram: Use page number instead of an address for the bitmap operations Juan Quintela
2017-04-07 10:26 ` Dr. David Alan Gilbert
2017-04-18 19:18 ` Juan Quintela
2017-04-06 13:09 ` [Qemu-devel] [PATCH 49/54] ram: Remember last_page instead of last_offset Juan Quintela
2017-04-07 10:39 ` Dr. David Alan Gilbert
2017-04-06 13:09 ` [Qemu-devel] [PATCH 50/54] ram: Change offset field in PageSearchStatus to page Juan Quintela
2017-04-06 13:09 ` [Qemu-devel] [PATCH 51/54] ram: Use ramblock and page offset instead of absolute offset Juan Quintela
2017-04-07 10:53 ` Dr. David Alan Gilbert [this message]
2017-04-06 13:09 ` [Qemu-devel] [PATCH 52/54] ram: rename last_ram_offset() last_ram_pages() Juan Quintela
2017-04-06 13:09 ` [Qemu-devel] [PATCH 53/54] ram: Use RAMBitmap type for coherence Juan Quintela
2017-04-06 13:09 ` [Qemu-devel] [PATCH 54/54] migration: Remove MigrationState parameter from migration_is_idle() Juan Quintela
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=20170407105321.GI2138@work-vm \
--to=dgilbert@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=quintela@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).