Message ID | 20200507173958.25894-7-philmd@redhat.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | exec: Shear 'exec/ram_addr.h' and make NVMe device target-agnostic | expand |
Philippe Mathieu-Daudé <philmd@redhat.com> wrote: > The ramblock_recv_bitmap_offset() function is only used once > in migration/ram.c, move it there. > > Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> Reviewed-by: Juan Quintela <quintela@redhat.com> But, if you are in the mood: > } > > +static inline unsigned long int ramblock_recv_bitmap_offset(void *host_addr, > + RAMBlock *rb) > +{ > + uint64_t host_addr_offset = > + (uint64_t)(uintptr_t)(host_addr - (void *)rb->host); > + return host_addr_offset >> TARGET_PAGE_BITS; ^^^^^^^^^^^^^^^^ That should be qemu_target_page_bits(). We are trying (not there yet) that migration code is target independent, this TARGET constant are one of the problems (not the only one, thought). And yes, I know that this file has both the function and the constant, sniff. Later, Juan.
On 5/8/20 10:07 AM, Juan Quintela wrote: > Philippe Mathieu-Daudé <philmd@redhat.com> wrote: >> The ramblock_recv_bitmap_offset() function is only used once >> in migration/ram.c, move it there. >> >> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> > > Reviewed-by: Juan Quintela <quintela@redhat.com> > > But, if you are in the mood: > >> } >> >> +static inline unsigned long int ramblock_recv_bitmap_offset(void *host_addr, >> + RAMBlock *rb) >> +{ >> + uint64_t host_addr_offset = >> + (uint64_t)(uintptr_t)(host_addr - (void *)rb->host); >> + return host_addr_offset >> TARGET_PAGE_BITS; > ^^^^^^^^^^^^^^^^ > > That should be qemu_target_page_bits(). Ah! I've been looking for this function :) > > We are trying (not there yet) that migration code is target independent, > this TARGET constant are one of the problems (not the only one, > thought). Good. > > And yes, I know that this file has both the function and the constant, > sniff. > > Later, Juan. >
diff --git a/include/exec/ram_addr.h b/include/exec/ram_addr.h index 195b67d3c8..c61d5188f7 100644 --- a/include/exec/ram_addr.h +++ b/include/exec/ram_addr.h @@ -83,14 +83,6 @@ static inline void *ramblock_ptr(RAMBlock *block, ram_addr_t offset) return (char *)block->host + offset; } -static inline unsigned long int ramblock_recv_bitmap_offset(void *host_addr, - RAMBlock *rb) -{ - uint64_t host_addr_offset = - (uint64_t)(uintptr_t)(host_addr - (void *)rb->host); - return host_addr_offset >> TARGET_PAGE_BITS; -} - bool ramblock_is_pmem(RAMBlock *rb); /** diff --git a/migration/ram.c b/migration/ram.c index 53166fc279..0cd16d0519 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -190,6 +190,14 @@ int foreach_not_ignored_block(RAMBlockIterFunc func, void *opaque) return ret; } +static inline unsigned long int ramblock_recv_bitmap_offset(void *host_addr, + RAMBlock *rb) +{ + uint64_t host_addr_offset = + (uint64_t)(uintptr_t)(host_addr - (void *)rb->host); + return host_addr_offset >> TARGET_PAGE_BITS; +} + static void ramblock_recv_map_init(void) { RAMBlock *rb;
The ramblock_recv_bitmap_offset() function is only used once in migration/ram.c, move it there. Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> --- include/exec/ram_addr.h | 8 -------- migration/ram.c | 8 ++++++++ 2 files changed, 8 insertions(+), 8 deletions(-)