DPDK patches and discussions
 help / color / mirror / Atom feed
From: Tiwei Bie <tiwei.bie@intel.com>
To: Maxime Coquelin <maxime.coquelin@redhat.com>
Cc: dev@dpdk.org, jianfeng.tan@intel.com, yliu@fridaylinux.org,
	zhihong.wang@intel.com, xiao.w.wang@intel.com,
	cunming.liang@intel.com, dan.daly@intel.com
Subject: Re: [dpdk-dev] [PATCH 3/3] vhost: support VFIO based accelerator
Date: Wed, 7 Mar 2018 16:59:05 +0800	[thread overview]
Message-ID: <20180307085905.pist45rli7kysokg@debian> (raw)
In-Reply-To: <4a4025f9-6886-8adc-51ed-c8508d81a003@redhat.com>

On Tue, Mar 06, 2018 at 03:24:27PM +0100, Maxime Coquelin wrote:
> On 03/06/2018 11:43 AM, Tiwei Bie wrote:
[...]
> > +
> > +static int vhost_user_slave_set_vring_file(struct virtio_net *dev,
> > +					   uint32_t request,
> > +					   struct vhost_vring_file *file)
> Why passing the request as an argument?
> It seems to be called only with the same request ID.

I thought there may be other requests that also need to
send a file descriptor for a ring in the future. So I
made this a common routine. Maybe it's not really helpful.
I won't pass the request as an argument in next version.

> 
> > +{
> > +	int *fdp = NULL;
> > +	size_t fd_num = 0;
> > +	int ret;
> > +	struct VhostUserMsg msg = {
> > +		.request.slave = request,
> > +		.flags = VHOST_USER_VERSION | VHOST_USER_NEED_REPLY,
> > +		.payload.u64 = file->index & VHOST_USER_VRING_IDX_MASK,
> > +		.size = sizeof(msg.payload.u64),
> > +	};
> > +
> > +	if (file->fd < 0)
> > +		msg.payload.u64 |= VHOST_USER_VRING_NOFD_MASK;
> > +	else {
> > +		fdp = &file->fd;
> > +		fd_num = 1;
> > +	}
> > +
> > +	ret = send_vhost_message(dev->slave_req_fd, &msg, fdp, fd_num);
> > +	if (ret < 0) {
> > +		RTE_LOG(ERR, VHOST_CONFIG,
> > +			"Failed to send slave message %u (%d)\n",
> > +			request, ret);
> > +		return ret;
> > +	}
> > +
> > +	return process_slave_message_reply(dev, &msg);
> 
> Maybe not needed right now, but we'll need a lock to avoid concurrent
> requests sending and waiting for reply.

Yeah, probably, we need a lock for each slave channel. I didn't
check the code of Linux. Maybe it will cause problems when two
threads send e.g. below messages at the same time:

thread A:
 IOTLB miss message

thread B:
 VFIO group message which has a file descriptor

Thanks for the comments! :)

Best regards,
Tiwei Bie

  reply	other threads:[~2018-03-07  9:00 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-06 10:43 [dpdk-dev] [PATCH 0/3] Extend vhost to " Tiwei Bie
2018-03-06 10:43 ` [dpdk-dev] [PATCH 1/3] vhost: do not generate signal when sendmsg fails Tiwei Bie
2018-03-29 12:19   ` Maxime Coquelin
2018-03-29 13:25     ` Tiwei Bie
2018-03-29 13:41       ` Maxime Coquelin
2018-03-29 13:46         ` Tiwei Bie
2018-03-29 13:46   ` Maxime Coquelin
2018-03-06 10:43 ` [dpdk-dev] [PATCH 2/3] vhost: support sending fds via send_vhost_message() Tiwei Bie
2018-03-29 12:23   ` Maxime Coquelin
2018-03-29 12:27   ` Maxime Coquelin
2018-03-06 10:43 ` [dpdk-dev] [PATCH 3/3] vhost: support VFIO based accelerator Tiwei Bie
2018-03-06 14:24   ` Maxime Coquelin
2018-03-07  8:59     ` Tiwei Bie [this message]
2018-04-18  5:49 ` [dpdk-dev] [PATCH v2] " Tiwei Bie

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=20180307085905.pist45rli7kysokg@debian \
    --to=tiwei.bie@intel.com \
    --cc=cunming.liang@intel.com \
    --cc=dan.daly@intel.com \
    --cc=dev@dpdk.org \
    --cc=jianfeng.tan@intel.com \
    --cc=maxime.coquelin@redhat.com \
    --cc=xiao.w.wang@intel.com \
    --cc=yliu@fridaylinux.org \
    --cc=zhihong.wang@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).