qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Chenyi Qiang <chenyi.qiang@intel.com>
Cc: David Hildenbrand <david@redhat.com>, qemu-devel@nongnu.org
Subject: Re: [PATCH] virtio-mem: Fix the bitmap index of the section offset
Date: Mon, 19 Dec 2022 05:51:51 -0500	[thread overview]
Message-ID: <20221219055124-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <20221216062231.11181-1-chenyi.qiang@intel.com>

On Fri, Dec 16, 2022 at 02:22:31PM +0800, Chenyi Qiang wrote:
> vmem->bitmap indexes the memory region of the virtio-mem backend at a
> granularity of block_size. To calculate the index of target section offset,
> the block_size should be divided instead of the bitmap_size.
> 
> Fixes: 2044969f0b ("virtio-mem: Implement RamDiscardManager interface")
> Signed-off-by: Chenyi Qiang <chenyi.qiang@intel.com>

Reviewed-by: Michael S. Tsirkin <mst@redhat.com>

I see David's queueing this.

> ---
>  hw/virtio/virtio-mem.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/hw/virtio/virtio-mem.c b/hw/virtio/virtio-mem.c
> index ed170def48..e19ee817fe 100644
> --- a/hw/virtio/virtio-mem.c
> +++ b/hw/virtio/virtio-mem.c
> @@ -235,7 +235,7 @@ static int virtio_mem_for_each_plugged_section(const VirtIOMEM *vmem,
>      uint64_t offset, size;
>      int ret = 0;
>  
> -    first_bit = s->offset_within_region / vmem->bitmap_size;
> +    first_bit = s->offset_within_region / vmem->block_size;
>      first_bit = find_next_bit(vmem->bitmap, vmem->bitmap_size, first_bit);
>      while (first_bit < vmem->bitmap_size) {
>          MemoryRegionSection tmp = *s;
> @@ -267,7 +267,7 @@ static int virtio_mem_for_each_unplugged_section(const VirtIOMEM *vmem,
>      uint64_t offset, size;
>      int ret = 0;
>  
> -    first_bit = s->offset_within_region / vmem->bitmap_size;
> +    first_bit = s->offset_within_region / vmem->block_size;
>      first_bit = find_next_zero_bit(vmem->bitmap, vmem->bitmap_size, first_bit);
>      while (first_bit < vmem->bitmap_size) {
>          MemoryRegionSection tmp = *s;
> -- 
> 2.17.1



      parent reply	other threads:[~2022-12-19 10:52 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-16  6:22 [PATCH] virtio-mem: Fix the bitmap index of the section offset Chenyi Qiang
2022-12-16  8:52 ` David Hildenbrand
2022-12-16 10:30   ` David Hildenbrand
2022-12-19  1:21     ` Chenyi Qiang
2022-12-19  9:01       ` David Hildenbrand
2022-12-19 10:51 ` Michael S. Tsirkin [this message]

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=20221219055124-mutt-send-email-mst@kernel.org \
    --to=mst@redhat.com \
    --cc=chenyi.qiang@intel.com \
    --cc=david@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /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).