From: Dan Jurgens <danielj@nvidia.com>
To: Eric Dumazet <edumazet@google.com>
Cc: "netdev@vger.kernel.org" <netdev@vger.kernel.org>,
"mst@redhat.com" <mst@redhat.com>,
"jasowang@redhat.com" <jasowang@redhat.com>,
"xuanzhuo@linux.alibaba.com" <xuanzhuo@linux.alibaba.com>,
"virtualization@lists.linux.dev" <virtualization@lists.linux.dev>,
"davem@davemloft.net" <davem@davemloft.net>,
"kuba@kernel.org" <kuba@kernel.org>,
"pabeni@redhat.com" <pabeni@redhat.com>,
Jiri Pirko <jiri@nvidia.com>
Subject: RE: [PATCH net-next v6 2/6] virtio_net: Remove command data from control_buf
Date: Wed, 15 May 2024 13:27:43 +0000 [thread overview]
Message-ID: <CH0PR12MB858041D6E8A46B12E4E795F9C9EC2@CH0PR12MB8580.namprd12.prod.outlook.com> (raw)
In-Reply-To: <CANn89iLazVaUCvhPm6RPJJ0owra_oFnx7Fhc8d60gV-65ad3WQ@mail.gmail.com>
> From: Eric Dumazet <edumazet@google.com>
> Sent: Wednesday, May 15, 2024 7:45 AM
> To: Dan Jurgens <danielj@nvidia.com>
> Cc: netdev@vger.kernel.org; mst@redhat.com; jasowang@redhat.com;
> xuanzhuo@linux.alibaba.com; virtualization@lists.linux.dev;
> davem@davemloft.net; kuba@kernel.org; pabeni@redhat.com; Jiri Pirko
> <jiri@nvidia.com>
> Subject: Re: [PATCH net-next v6 2/6] virtio_net: Remove command data
> from control_buf
>
> On Fri, May 3, 2024 at 10:25 PM Daniel Jurgens <danielj@nvidia.com> wrote:
> >
> > Allocate memory for the data when it's used. Ideally the struct could
> > be on the stack, but we can't DMA stack memory. With this change only
> > the header and status memory are shared between commands, which will
> > allow using a tighter lock than RTNL.
> >
> > Signed-off-by: Daniel Jurgens <danielj@nvidia.com>
> > Reviewed-by: Jiri Pirko <jiri@nvidia.com>
> > ---
> > drivers/net/virtio_net.c | 124
> > +++++++++++++++++++++++++++------------
> > 1 file changed, 85 insertions(+), 39 deletions(-)
> >
> > diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index
> > 9cf93a8a4446..451879d570a8 100644
> > --- a/drivers/net/virtio_net.c
> > +++ b/drivers/net/virtio_net.c
> > @@ -368,15 +368,6 @@ struct virtio_net_ctrl_rss { struct control_buf
> > {
> > struct virtio_net_ctrl_hdr hdr;
> > virtio_net_ctrl_ack status;
> > - struct virtio_net_ctrl_mq mq;
> > - u8 promisc;
> > - u8 allmulti;
> > - __virtio16 vid;
> > - __virtio64 offloads;
> > - struct virtio_net_ctrl_coal_tx coal_tx;
> > - struct virtio_net_ctrl_coal_rx coal_rx;
> > - struct virtio_net_ctrl_coal_vq coal_vq;
> > - struct virtio_net_stats_capabilities stats_cap;
> > };
> >
> > struct virtnet_info {
> > @@ -2828,14 +2819,19 @@ static void virtnet_ack_link_announce(struct
> > virtnet_info *vi)
> >
> > static int _virtnet_set_queues(struct virtnet_info *vi, u16
> > queue_pairs) {
> > + struct virtio_net_ctrl_mq *mq __free(kfree) = NULL;
> > struct scatterlist sg;
> > struct net_device *dev = vi->dev;
> >
> > if (!vi->has_cvq || !virtio_has_feature(vi->vdev, VIRTIO_NET_F_MQ))
> > return 0;
> >
> > - vi->ctrl->mq.virtqueue_pairs = cpu_to_virtio16(vi->vdev,
> queue_pairs);
> > - sg_init_one(&sg, &vi->ctrl->mq, sizeof(vi->ctrl->mq));
> > + mq = kzalloc(sizeof(*mq), GFP_KERNEL);
> > + if (!mq)
> > + return -ENOMEM;
> > +
> > + mq->virtqueue_pairs = cpu_to_virtio16(vi->vdev, queue_pairs);
> > + sg_init_one(&sg, mq, sizeof(*mq));
> >
> > if (!virtnet_send_command(vi, VIRTIO_NET_CTRL_MQ,
> > VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET,
> > &sg)) { @@ -2864,6 +2860,7 @@ static int virtnet_set_queues(struct
> > virtnet_info *vi, u16 queue_pairs)
> >
> > static int virtnet_close(struct net_device *dev) {
> > + u8 *promisc_allmulti __free(kfree) = NULL;
> > struct virtnet_info *vi = netdev_priv(dev);
> > int i;
> >
> > @@ -2888,6 +2885,7 @@ static void virtnet_rx_mode_work(struct
> work_struct *work)
> > struct scatterlist sg[2];
> > struct virtio_net_ctrl_mac *mac_data;
> > struct netdev_hw_addr *ha;
> > + u8 *promisc_allmulti;
> > int uc_count;
> > int mc_count;
> > void *buf;
> > @@ -2899,22 +2897,27 @@ static void virtnet_rx_mode_work(struct
> > work_struct *work)
> >
> > rtnl_lock();
> >
> > - vi->ctrl->promisc = ((dev->flags & IFF_PROMISC) != 0);
> > - vi->ctrl->allmulti = ((dev->flags & IFF_ALLMULTI) != 0);
> > + promisc_allmulti = kzalloc(sizeof(*promisc_allmulti), GFP_ATOMIC);
> > + if (!promisc_allmulti) {
>
> There is a missing rtnl_unlock() here ?
Yes, you're right. Will send a patch soon.
>
> > + dev_warn(&dev->dev, "Failed to set RX mode, no memory.\n");
> > + return;
> > + }
> >
> >
next prev parent reply other threads:[~2024-05-15 13:27 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-03 20:24 [PATCH net-next v6 0/6] Remove RTNL lock protection of CVQ Daniel Jurgens
2024-05-03 20:24 ` [PATCH net-next v6 1/6] virtio_net: Store RSS setting in virtnet_info Daniel Jurgens
2024-05-03 20:24 ` [PATCH net-next v6 2/6] virtio_net: Remove command data from control_buf Daniel Jurgens
2024-05-15 12:44 ` Eric Dumazet
2024-05-15 13:27 ` Dan Jurgens [this message]
2024-05-03 20:24 ` [PATCH net-next v6 3/6] virtio_net: Add a lock for the command VQ Daniel Jurgens
2024-05-03 20:24 ` [PATCH net-next v6 4/6] virtio_net: Do DIM update for specified queue only Daniel Jurgens
2024-05-03 20:24 ` [PATCH net-next v6 5/6] virtio_net: Add a lock for per queue RX coalesce Daniel Jurgens
2024-05-03 20:24 ` [PATCH net-next v6 6/6] virtio_net: Remove rtnl lock protection of command buffers Daniel Jurgens
2024-05-06 6:16 ` [PATCH net-next v6 0/6] Remove RTNL lock protection of CVQ Heng Qi
2024-05-07 6:29 ` Jason Wang
2024-05-07 10:50 ` patchwork-bot+netdevbpf
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=CH0PR12MB858041D6E8A46B12E4E795F9C9EC2@CH0PR12MB8580.namprd12.prod.outlook.com \
--to=danielj@nvidia.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=jasowang@redhat.com \
--cc=jiri@nvidia.com \
--cc=kuba@kernel.org \
--cc=mst@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=virtualization@lists.linux.dev \
--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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).