Discussion of the implementations of VIRTIO specification
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Parav Pandit <parav@nvidia.com>
Cc: Alvaro Karsz <alvaro.karsz@solid-run.com>,
	Heng Qi <hengqi@linux.alibaba.com>,
	Xuan Zhuo <xuanzhuo@linux.alibaba.com>,
	"virtio-comment @ lists . oasis-open . org"
	<virtio-comment@lists.oasis-open.org>,
	"virtio-dev @ lists . oasis-open . org"
	<virtio-dev@lists.oasis-open.org>,
	Jason Wang <jasowang@redhat.com>
Subject: [virtio-dev] Re: [virtio-comment] [PATCH] virtio-net: support per-queue coalescing moderation
Date: Wed, 8 Feb 2023 17:13:04 -0500	[thread overview]
Message-ID: <20230208171002-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <PH0PR12MB54810798C047E97434BCB9B4DCD89@PH0PR12MB5481.namprd12.prod.outlook.com>

On Wed, Feb 08, 2023 at 09:05:47PM +0000, Parav Pandit wrote:
> 
> > From: Michael S. Tsirkin <mst@redhat.com>
> > Sent: Wednesday, February 8, 2023 3:52 PM
> > 
> > On Wed, Feb 08, 2023 at 07:53:09PM +0200, Alvaro Karsz wrote:
> > >  > > From: Michael S. Tsirkin <mst@redhat.com>
> > > > > Sent: Wednesday, February 8, 2023 9:48 AM
> > > > >
> > > > > On Wed, Feb 08, 2023 at 02:44:37PM +0000, Parav Pandit wrote:
> > > > > >
> > > > > > > From: Michael S. Tsirkin <mst@redhat.com>
> > > > > > > Sent: Wednesday, February 8, 2023 9:43 AM
> > > > > > >
> > > > > > > On Wed, Feb 08, 2023 at 02:37:55PM +0000, Parav Pandit wrote:
> > > > > > > >
> > > > > > > > > From: Michael S. Tsirkin <mst@redhat.com>
> > > > > > > > > Sent: Wednesday, February 8, 2023 9:18 AM
> > > > > > > > >
> > > > > > > > > On Wed, Feb 08, 2023 at 07:30:34PM +0800, Heng Qi wrote:
> > > > > > > > > > > I see two options.
> > > > > > > > > > > 1. Just have per VQ params. Software has the full
> > > > > > > > > > > knowledge of in which it is
> > > > > > > > > operating, and state remains at software level.
> > > > > > > > > > > This effectively achieves both the mode.
> > > > > > > > > > >
> > > > > > > > > > > 2. Have a mode cmd,
> > > > > > > > > > > Mode = (a) per device or (b) per VQ (c) disable After
> > > > > > > > > > > the mode is set, driver can set per device or per VQ.
> > > > > > > > > >
> > > > > > > > > > I find this more clear.
> > > > > > > > > >
> > > > > > > > > > Thanks.
> > > > > > > > > >
> > > > > > > > >
> > > > > > > > > Rereading this I think I misunderstood the proposal.
> > > > > > > > > Now we are burning memory on maintaining mode, and this
> > > > > > > > > information is duplicated.
> > > > > > > > >
> > > > > > > > It is not maintained in the pci resident memory, so it doesn't hurt.
> > > > > > > >
> > > > > > > > > I'd say let's just add a new command COAL_QUEUE_SET with
> > > > > > > > > vqn as
> > > > > > > parameter.
> > > > > > > > > Existing commands are simply defined as a shortcut to
> > > > > > > > > running COAL_QUEUE_SET on all tx/rx queues respectively.
> > > > > > > > >
> > > > > > > > > Latest command dictates the parameters. To disable just
> > > > > > > > > set everything to 0 (btw we should make this explicit in
> > > > > > > > > the spec, but it can be
> > > > > > > guessed from:
> > > > > > > > > Upon reset, a device MUST initialize all coalescing parameters to 0.
> > > > > > > > > )
> > > > > > > > >
> > > > > > > > Switching between the modes (per q vs per device) implicitly
> > > > > > > > is ambiguous
> > > > > > > and it only means device may need to iterate.
> > > > > > >
> > > > > > > hmm i feel it's only ambiguous because i failed to explain in well.
> > > > > > >
> > > > > > > > This state is either better maintained in sw by always
> > > > > > > > having per vq or have
> > > > > > > clearly defined mode of what device should do.
> > > > > > > >
> > > > > > > > Per Q is very common even for several years old devices.
> > > > > > > > Last time I counted, there were at least 15 such devices supporting it.
> > > > > > > >
> > > > > > > > So actual usage wise, I practically see that most
> > > > > > > > implementations will end up
> > > > > > > with per vq mode.
> > > > > > > > I like to hear from Heng or Alvaro if they see any use of per device.
> > > > > > >
> > > > > > >
> > > > > > > Right so given this, most devices will be in per queue mode
> > > > > > > all the time. why do you want a mode then? just keep per queue.
> > > > > > > existing commands are kept around for compat but internally
> > > > > > > just translate to per-queue.
> > > > > > Since the space is not released, do we need to keep the compat?
> > > > >
> > > > > It's been accepted for half a year so we can't say for sure no one built this.
> > > > That is likely but we should have the ability to have the Errata/ECN to
> > correct it, specially for unrelease spec.
> > > >
> > > > > The way I propose is just a bit of firmware on device that scans
> > > > > all queues and copies same parameters everywhere.
> > > > This scanning loop in sw appears cheaper to me than some embedded fw.
> > > > But is not a lot of concern.
> > > >
> > > > > Seems easier than worrying about this, and we get disabling
> > > > > coalescing for free which you wanted. With an extra mode its extra
> > > > > logic in the device fast path. Maybe it's cheap on hardware side
> > > > > but in software it's an extra branch, not free.
> > > >
> > > > Most performant data path wouldn't implement and read the extra mode.
> > > > It is always fw that is going to program same value, or per queue valued or
> > disable value in each Q regardless whichever way we craft the CVQ cmd.
> > > >
> > > > The sequence that bothers me is below.
> > > > 1. driver set global params
> > > > 2. few minutes later, now driver set param for Q=1
> > > >
> > > > On this command, a device need to decide:
> > > > Should Q = 2 to N
> > > > (a) either work with previous globals, or
> > > > (b) because per Q was set for one queue, they rest of the queues implicitly
> > disable it.
> > > >
> > > > If it is (b),
> > > > When a command on Q object =1 is issued, it affects other Q objects. <- This
> > I want to avoid.
> > > > A cmd that modifies the object, should only modify that object.
> > > >
> > > > If it is (a), it is mixed mode operation, which is ambiguous definition.
> > > >
> > > > A better semantic is to define such change at device level and no extra cost
> > in the data path.
> > >
> > > I think that (a) is the way to go.
> > > I don't think that we should work with operation modes at all.
> > >
> > > In my opinion:
> > >
> > > We should have 2 features:
> > > VIRTIO_NET_F_PERQUEUE_NOTF_COAL and VIRTIO_NET_F_NOTF_COAL.
> > >
> > > VIRTIO_NET_F_PERQUEUE_NOTF_COAL sets per queue parameters, and
> > > VIRTIO_NET_F_NOTF_COAL sets parameters for all queues.
> > >
> > > VIRTIO_NET_F_NOTF_COAL has 2 commands:
> > >     VIRTIO_NET_CTRL_NOTF_COAL_RX_SET
> > >     VIRTIO_NET_CTRL_NOTF_COAL_TX_SET
> > >
> > > VIRTIO_NET_F_PERQUEUE_NOTF_COAL has 2 commands:
> > >     VIRTIO_NET_CTRL_NOTF_COAL_PER_QUEUE_TX_SET
> > >     VIRTIO_NET_CTRL_NOTF_COAL_PER_QUEUE_RX_SET
> > >
> > > We can see VIRTIO_NET_CTRL_NOTF_COAL_RX_SET as a virtio level shortcut
> > > for setting all queues with one command, exactly as intended with
> > > rx_qid= 0xFFFF, and without breaking devices following the current
> > > spec.
> > >
> > > The device's FW can decide if it stores parameters received with
> > > VIRTIO_NET_CTRL_NOTF_COAL_RX_SET in a global set, or if it iterates
> > > through all queues, but IMO the best way it to iterate through all
> > > queues.
> > >
> > > Seems like a win-win situation to me.
> > > We achieve the same functionality as described in the patch, but
> > > without breaking devices following the current spec.
> > >
> > > Now, if we follow this method,
> > > VIRTIO_NET_CTRL_NOTF_COAL_PER_QUEUE_RX_SET with rx_qid= 0xFFF
> > seems
> > > redundant.
> > > If VIRTIO_NET_F_PERQUEUE_NOTF_COAL requires
> > VIRTIO_NET_F_NOTF_COAL, a
> > > device supporting VIRTIO_NET_F_PERQUEUE_NOTF_COAL can achieve the
> > same
> > > functionality with the VIRTIO_NET_CTRL_NOTF_COAL_RX_SET command.
> > 
> > Yes. Just some comments:
> > 
> > - I don't think we need two commands. We have RX and TX because we
> >   did not have vq number previously. No we do so just pass that.
> >   It's also clearer since struct name can match command exactly.
> >
> +1. Consolidate the structure, followed by single command is good.
>  
> > - Once we do that we can use a short _VQ_ instead of the wordy
> > "PER_QUEUE".
> > 
> > - Accordingly a well understood "vqn" instead of our own "qid" which
> >   we then need to define.
> > 
> > - And yes no need for a reserved "qid" - it's a distinct command.
> 
> I want to ask one more time, is there any sw that used this?
> If not, we are better of just having single per vq command and everything is good.

I'm not so sure, I feel a command affecting all queues in one go is a
nice shortcut for ethtool to use. Maybe if we didn't include it
originally I would not bother but given we already have it, it seems a
waste to drop it now.
And sure, devices can just ignore the feature bit and the commands
if they want to.


> For extra safety, we can reserve this command value and feature bit forever, and have new per VQ as new cmd.
> 
> Alvaro,
> Do you know if any software used it? Can you get some real data?


---------------------------------------------------------------------
To unsubscribe, e-mail: virtio-dev-unsubscribe@lists.oasis-open.org
For additional commands, e-mail: virtio-dev-help@lists.oasis-open.org


  parent reply	other threads:[~2023-02-08 22:13 UTC|newest]

Thread overview: 65+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-07 11:16 [virtio-comment] [PATCH] virtio-net: support per-queue coalescing moderation Heng Qi
2023-02-07 11:25 ` [virtio-comment] " Alvaro Karsz
2023-02-07 11:50   ` Xuan Zhuo
2023-02-07 12:51     ` Parav Pandit
2023-02-07 14:29       ` [virtio-dev] " Michael S. Tsirkin
2023-02-07 14:40         ` Alvaro Karsz
2023-02-07 14:48           ` Michael S. Tsirkin
2023-02-07 14:56             ` Alvaro Karsz
2023-02-07 15:09               ` Michael S. Tsirkin
2023-02-07 15:25                 ` Parav Pandit
2023-02-07 15:28                   ` [virtio-comment] " Michael S. Tsirkin
2023-02-07 15:30                     ` [virtio-comment] " Parav Pandit
2023-02-08  1:58                     ` [virtio-comment] " Xuan Zhuo
2023-02-08  2:20         ` Heng Qi
2023-02-08  9:56           ` Michael S. Tsirkin
2023-02-08 13:51             ` Parav Pandit
2023-02-07 14:06 ` [virtio-comment] " Michael S. Tsirkin
2023-02-07 14:22   ` Michael S. Tsirkin
2023-02-08  1:45   ` Xuan Zhuo
2023-02-08  2:20     ` Parav Pandit
2023-02-08  2:24       ` Xuan Zhuo
2023-02-08  2:43         ` Parav Pandit
2023-02-08 10:07           ` Michael S. Tsirkin
2023-02-08 13:52             ` [virtio-dev] " Parav Pandit
2023-02-08 11:30           ` Heng Qi
2023-02-08 14:17             ` [virtio-dev] " Michael S. Tsirkin
2023-02-08 14:37               ` Parav Pandit
2023-02-08 14:42                 ` [virtio-dev] " Michael S. Tsirkin
2023-02-08 14:44                   ` Parav Pandit
2023-02-08 14:48                     ` Michael S. Tsirkin
2023-02-08 15:04                       ` Parav Pandit
2023-02-08 15:20                         ` Michael S. Tsirkin
2023-02-08 15:27                           ` Parav Pandit
2023-02-08 19:23                             ` [virtio-dev] " Parav Pandit
2023-02-08 20:48                               ` Michael S. Tsirkin
2023-02-08 17:53                         ` Alvaro Karsz
2023-02-08 20:52                           ` Michael S. Tsirkin
2023-02-08 21:05                             ` Parav Pandit
2023-02-08 21:55                               ` [virtio-dev] " Alvaro Karsz
2023-02-08 22:08                                 ` Parav Pandit
2023-02-08 22:15                                   ` [virtio-dev] " Michael S. Tsirkin
2023-02-08 22:23                                     ` Parav Pandit
2023-02-08 22:29                                       ` [virtio-dev] " Michael S. Tsirkin
2023-02-08 22:33                                         ` Parav Pandit
2023-02-08 22:45                                           ` Alvaro Karsz
2023-02-08 22:53                                             ` Michael S. Tsirkin
2023-02-08 22:35                                   ` [virtio-dev] " Alvaro Karsz
2023-02-08 22:57                                     ` Michael S. Tsirkin
2023-02-09  0:06                                     ` Parav Pandit
2023-02-09  3:16                                     ` [virtio-comment] Re: [virtio-dev] " Heng Qi
2023-02-08 22:13                               ` Michael S. Tsirkin [this message]
2023-02-08 21:22                             ` Alvaro Karsz
2023-02-09  3:25                             ` Heng Qi
2023-02-09  3:12                           ` [virtio-comment] Re: [virtio-dev] " Heng Qi
2023-02-09  3:28                         ` [virtio-comment] Re: [virtio-dev] " Heng Qi
2023-02-08 14:44                 ` Michael S. Tsirkin
2023-02-08  2:27       ` Xuan Zhuo
2023-02-08  2:35       ` [virtio-comment] Re: [virtio-dev] " Heng Qi
2023-02-08  2:47         ` [virtio-comment] " Parav Pandit
2023-02-08  1:57   ` [virtio-comment] Re: [virtio-dev] " Heng Qi
2023-02-08 10:04     ` Michael S. Tsirkin
2023-02-08 11:23       ` Heng Qi
2023-02-08 13:39         ` [virtio-dev] " Michael S. Tsirkin
2023-02-08 10:10     ` Michael S. Tsirkin
2023-02-08 11:24       ` Heng Qi

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=20230208171002-mutt-send-email-mst@kernel.org \
    --to=mst@redhat.com \
    --cc=alvaro.karsz@solid-run.com \
    --cc=hengqi@linux.alibaba.com \
    --cc=jasowang@redhat.com \
    --cc=parav@nvidia.com \
    --cc=virtio-comment@lists.oasis-open.org \
    --cc=virtio-dev@lists.oasis-open.org \
    --cc=xuanzhuo@linux.alibaba.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