From: "Xie, Huawei" <huawei.xie@intel.com>
To: Victor Kaplansky <victork@redhat.com>,
Yuanhan Liu <yuanhan.liu@linux.intel.com>
Cc: "dev@dpdk.org" <dev@dpdk.org>, "Michael S. Tsirkin" <mst@redhat.com>
Subject: Re: [dpdk-dev] [PATCH 2/4] vhost: introduce vhost_log_write
Date: Wed, 9 Dec 2015 03:33:16 +0000 [thread overview]
Message-ID: <C37D651A908B024F974696C65296B57B4BB82C2D@SHSMSX103.ccr.corp.intel.com> (raw)
In-Reply-To: <20151202153050-mutt-send-email-victork@redhat.com>
On 12/2/2015 9:53 PM, Victor Kaplansky wrote:
> On Wed, Dec 02, 2015 at 11:43:11AM +0800, Yuanhan Liu wrote:
>> Introduce vhost_log_write() helper function to log the dirty pages we
>> touched. Page size is harded code to 4096 (VHOST_LOG_PAGE), and each
>> log is presented by 1 bit.
>>
>> Therefore, vhost_log_write() simply finds the right bit for related
>> page we are gonna change, and set it to 1. dev->log_base denotes the
>> start of the dirty page bitmap.
>>
>> The page address is biased by log_guest_addr, which is derived from
>> SET_VRING_ADDR request as part of the vring related addresses.
>>
>> Signed-off-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
>> ---
>> lib/librte_vhost/rte_virtio_net.h | 34 ++++++++++++++++++++++++++++++++++
>> lib/librte_vhost/virtio-net.c | 4 ++++
>> 2 files changed, 38 insertions(+)
>>
>> diff --git a/lib/librte_vhost/rte_virtio_net.h b/lib/librte_vhost/rte_virtio_net.h
>> index 416dac2..191c1be 100644
>> --- a/lib/librte_vhost/rte_virtio_net.h
>> +++ b/lib/librte_vhost/rte_virtio_net.h
>> @@ -40,6 +40,7 @@
>> */
>>
>> #include <stdint.h>
>> +#include <linux/vhost.h>
>> #include <linux/virtio_ring.h>
>> #include <linux/virtio_net.h>
>> #include <sys/eventfd.h>
>> @@ -59,6 +60,8 @@ struct rte_mbuf;
>> /* Backend value set by guest. */
>> #define VIRTIO_DEV_STOPPED -1
>>
>> +#define VHOST_LOG_PAGE 4096
>> +
>>
>> /* Enum for virtqueue management. */
>> enum {VIRTIO_RXQ, VIRTIO_TXQ, VIRTIO_QNUM};
>> @@ -82,6 +85,7 @@ struct vhost_virtqueue {
>> struct vring_desc *desc; /**< Virtqueue descriptor ring. */
>> struct vring_avail *avail; /**< Virtqueue available ring. */
>> struct vring_used *used; /**< Virtqueue used ring. */
>> + uint64_t log_guest_addr; /**< Physical address of used ring, for logging */
>> uint32_t size; /**< Size of descriptor ring. */
>> uint32_t backend; /**< Backend value to determine if device should started/stopped. */
>> uint16_t vhost_hlen; /**< Vhost header length (varies depending on RX merge buffers. */
>> @@ -203,6 +207,36 @@ gpa_to_vva(struct virtio_net *dev, uint64_t guest_pa)
>> return vhost_va;
>> }
>>
>> +static inline void __attribute__((always_inline))
>> +vhost_log_page(uint8_t *log_base, uint64_t page)
>> +{
>> + /* TODO: to make it atomic? */
>> + log_base[page / 8] |= 1 << (page % 8);
> I think the atomic OR operation is necessary only if there can be
> more than one vhost-user back-end updating the guest's memory
> simultaneously. However probably it is pretty safe to perform
> regular OR operation, since rings are not shared between
> back-end. What about buffers pointed by descriptors? To be on
> the safe side, I would use a GCC built-in function
> __sync_fetch_and_or().
>
>> +}
>> +
>> +static inline void __attribute__((always_inline))
>> +vhost_log_write(struct virtio_net *dev, struct vhost_virtqueue *vq,
>> + uint64_t offset, uint64_t len)
>> +{
>> + uint64_t addr = vq->log_guest_addr;
>> + uint64_t page;
>> +
>> + if (unlikely(((dev->features & (1ULL << VHOST_F_LOG_ALL)) == 0) ||
>> + !dev->log_base || !len))
>> + return;
> Isn't "likely" more appropriate in above, since the whole
> expression is expected to be true most of the time?
Victor:
So we are not always logging, what is the message that tells the backend
the migration is started?
[...]
next prev parent reply other threads:[~2015-12-09 3:33 UTC|newest]
Thread overview: 98+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-02 3:43 [dpdk-dev] [PATCH 0/4 for 2.3] vhost-user live migration support Yuanhan Liu
2015-12-02 3:43 ` [dpdk-dev] [PATCH 1/4] vhost: handle VHOST_USER_SET_LOG_BASE request Yuanhan Liu
2015-12-02 13:53 ` Panu Matilainen
2015-12-02 14:31 ` Yuanhan Liu
2015-12-02 14:48 ` Panu Matilainen
2015-12-02 15:09 ` Yuanhan Liu
2015-12-02 16:58 ` Panu Matilainen
2015-12-02 17:24 ` Michael S. Tsirkin
2015-12-02 16:38 ` Thomas Monjalon
2015-12-03 1:49 ` Yuanhan Liu
2015-12-06 23:07 ` Thomas Monjalon
2015-12-07 2:00 ` Yuanhan Liu
2015-12-07 2:03 ` Thomas Monjalon
2015-12-07 2:18 ` Yuanhan Liu
2015-12-07 2:49 ` Thomas Monjalon
2015-12-07 6:29 ` Panu Matilainen
2015-12-07 11:28 ` Thomas Monjalon
2015-12-07 11:41 ` Panu Matilainen
2015-12-07 13:55 ` Thomas Monjalon
2015-12-07 16:48 ` Panu Matilainen
2015-12-07 17:47 ` Thomas Monjalon
2015-12-08 5:57 ` Xie, Huawei
2015-12-08 7:25 ` Yuanhan Liu
2015-12-02 3:43 ` [dpdk-dev] [PATCH 2/4] vhost: introduce vhost_log_write Yuanhan Liu
2015-12-02 13:53 ` Victor Kaplansky
2015-12-02 14:39 ` Yuanhan Liu
2015-12-09 3:33 ` Xie, Huawei [this message]
2015-12-09 3:42 ` Yuanhan Liu
2015-12-09 5:44 ` Xie, Huawei
2015-12-09 8:41 ` Yuanhan Liu
2015-12-02 3:43 ` [dpdk-dev] [PATCH 3/4] vhost: log vring changes Yuanhan Liu
2015-12-02 14:07 ` Victor Kaplansky
2015-12-02 14:38 ` Yuanhan Liu
2015-12-02 15:58 ` Victor Kaplansky
2015-12-02 16:26 ` Michael S. Tsirkin
2015-12-03 2:31 ` Yuanhan Liu
2015-12-09 2:45 ` Xie, Huawei
2015-12-02 3:43 ` [dpdk-dev] [PATCH 4/4] vhost: enable log_shmfd protocol feature Yuanhan Liu
2015-12-02 14:10 ` [dpdk-dev] [PATCH 0/4 for 2.3] vhost-user live migration support Victor Kaplansky
2015-12-02 14:33 ` Yuanhan Liu
2015-12-09 3:41 ` Xie, Huawei
2015-12-17 3:11 ` [dpdk-dev] [PATCH v2 0/6] " Yuanhan Liu
2015-12-17 3:11 ` [dpdk-dev] [PATCH v2 1/6] vhost: handle VHOST_USER_SET_LOG_BASE request Yuanhan Liu
2015-12-21 15:32 ` Xie, Huawei
2015-12-22 2:25 ` Yuanhan Liu
2015-12-22 2:41 ` Xie, Huawei
2015-12-22 2:55 ` Yuanhan Liu
2015-12-17 3:11 ` [dpdk-dev] [PATCH v2 2/6] vhost: introduce vhost_log_write Yuanhan Liu
2015-12-21 15:06 ` Xie, Huawei
2015-12-22 2:40 ` Yuanhan Liu
2015-12-22 2:45 ` Xie, Huawei
2015-12-22 3:04 ` Yuanhan Liu
2015-12-22 7:02 ` Xie, Huawei
2015-12-22 5:11 ` Peter Xu
2015-12-22 6:09 ` Yuanhan Liu
2015-12-17 3:11 ` [dpdk-dev] [PATCH v2 3/6] vhost: log used vring changes Yuanhan Liu
2015-12-22 6:55 ` Peter Xu
2015-12-22 7:07 ` Xie, Huawei
2015-12-22 7:59 ` Peter Xu
2015-12-22 7:13 ` Yuanhan Liu
2015-12-22 8:01 ` Peter Xu
2015-12-17 3:11 ` [dpdk-dev] [PATCH v2 4/6] vhost: log vring desc buffer changes Yuanhan Liu
2015-12-17 3:12 ` [dpdk-dev] [PATCH v2 5/6] vhost: claim that we support GUEST_ANNOUNCE feature Yuanhan Liu
2015-12-22 8:11 ` Peter Xu
2015-12-22 8:21 ` Yuanhan Liu
2015-12-22 8:24 ` Pavel Fedin
2015-12-17 3:12 ` [dpdk-dev] [PATCH v2 6/6] vhost: enable log_shmfd protocol feature Yuanhan Liu
2015-12-17 12:08 ` [dpdk-dev] [PATCH v2 0/6] vhost-user live migration support Iremonger, Bernard
2015-12-17 12:45 ` Yuanhan Liu
2015-12-21 8:17 ` Pavel Fedin
2016-01-29 4:57 ` [dpdk-dev] [PATCH v3 0/8] " Yuanhan Liu
2016-01-29 4:57 ` [dpdk-dev] [PATCH v3 1/8] vhost: handle VHOST_USER_SET_LOG_BASE request Yuanhan Liu
2016-01-29 4:57 ` [dpdk-dev] [PATCH v3 2/8] vhost: introduce vhost_log_write Yuanhan Liu
2016-02-19 14:26 ` Thomas Monjalon
2016-02-22 6:59 ` Yuanhan Liu
2016-01-29 4:57 ` [dpdk-dev] [PATCH v3 3/8] vhost: log used vring changes Yuanhan Liu
2016-01-29 4:57 ` [dpdk-dev] [PATCH v3 4/8] vhost: log vring desc buffer changes Yuanhan Liu
2016-01-29 4:58 ` [dpdk-dev] [PATCH v3 5/8] vhost: claim that we support GUEST_ANNOUNCE feature Yuanhan Liu
2016-03-11 12:39 ` Olivier MATZ
2016-03-11 13:16 ` Thomas Monjalon
2016-03-11 13:22 ` Olivier MATZ
2016-01-29 4:58 ` [dpdk-dev] [PATCH v3 6/8] vhost: handle VHOST_USER_SEND_RARP request Yuanhan Liu
2016-02-19 6:11 ` Tan, Jianfeng
2016-02-19 7:03 ` Yuanhan Liu
2016-02-19 8:55 ` Yuanhan Liu
2016-02-22 14:36 ` [dpdk-dev] [PATCH] vhost: broadcast RARP pkt by injecting it to receiving mbuf array Yuanhan Liu
2016-02-24 8:15 ` Qiu, Michael
2016-02-24 8:28 ` Yuanhan Liu
2016-02-25 7:55 ` Qiu, Michael
2016-02-29 15:56 ` Thomas Monjalon
2016-01-29 4:58 ` [dpdk-dev] [PATCH v3 7/8] vhost: enable log_shmfd protocol feature Yuanhan Liu
2016-01-29 4:58 ` [dpdk-dev] [PATCH v3 8/8] vhost: remove duplicate header include Yuanhan Liu
2016-02-01 15:54 ` [dpdk-dev] [PATCH v3 0/8] vhost-user live migration support Iremonger, Bernard
2016-02-02 1:53 ` Yuanhan Liu
2016-02-19 15:01 ` Thomas Monjalon
2016-02-22 7:08 ` Yuanhan Liu
2016-02-22 9:56 ` Thomas Monjalon
2016-02-22 14:24 ` Yuanhan Liu
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=C37D651A908B024F974696C65296B57B4BB82C2D@SHSMSX103.ccr.corp.intel.com \
--to=huawei.xie@intel.com \
--cc=dev@dpdk.org \
--cc=mst@redhat.com \
--cc=victork@redhat.com \
--cc=yuanhan.liu@linux.intel.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).