From patchwork Mon Apr 15 13:38:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heng Qi X-Patchwork-Id: 13630074 X-Patchwork-Delegate: kuba@kernel.org Received: from out30-98.freemail.mail.aliyun.com (out30-98.freemail.mail.aliyun.com [115.124.30.98]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 20961745CB for ; Mon, 15 Apr 2024 13:38:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.98 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713188299; cv=none; b=s6G0Ej5qDxiar97UbWNzF+0IuBSwRopHly24K3f5+lAqiuUODsch7LpKp+/MXsYeu9wuOW4rBcJbL4B4vKZBWgHtxBqpJILudcfU8aEJruKgDeE1jYoxMeoGayc5r6F/pyVcvsAeF+0DDkvHsCTFj5MK9W73o5nw+6vy2d5CSFc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713188299; c=relaxed/simple; bh=Y7aVU+Yvd42Ru644LJeGMg1Z6uAGCvMyrYuVbR2AZ2E=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=of4TUTAWnw5towr8pHkQxgPgKgUJQAuYPVK8MXnAQ22xOnyNFYrJqbvzcsWry/5KWRknpMxKM6y7i1psNnpE8c45ZgDCaT2eADD+/3SP1XBAjAIqm9YUucAVoBgOd0e5cWrCjAHOe1PPXHquGAGQr/Qzy1EQDF2vQi3HVG6hE9s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com; spf=pass smtp.mailfrom=linux.alibaba.com; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b=pyd4Ia1p; arc=none smtp.client-ip=115.124.30.98 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b="pyd4Ia1p" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1713188293; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=pD4eGjoRhd08IwOJQU2fyyVO7s5eSR6uO/l4PM+ufGE=; b=pyd4Ia1pNdUO3sbdpJpKrKK767XRHY2zyj1+1xL0ozZW/HQw19vAhAT3Tr/kvDg1VTA1J5i32WIvCUaH7OvW+HlMSxAQF0M/B5HkRrJH4RrVbi1aWMU+SjyGRbpiJOVriMd133/49zNeZj6XEfP9GFTzs1PrVP35qGFAGUf4k00= X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R771e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046050;MF=hengqi@linux.alibaba.com;NM=1;PH=DS;RN=12;SR=0;TI=SMTPD_---0W4ea7o6_1713188292; Received: from localhost(mailfrom:hengqi@linux.alibaba.com fp:SMTPD_---0W4ea7o6_1713188292) by smtp.aliyun-inc.com; Mon, 15 Apr 2024 21:38:12 +0800 From: Heng Qi To: netdev@vger.kernel.org, virtualization@lists.linux.dev Cc: Jakub Kicinski , "David S . Miller" , Eric Dumazet , Paolo Abeni , Jason Wang , "Michael S . Tsirkin" , Brett Creeley , Ratheesh Kannoth , Alexander Lobakin , Xuan Zhuo Subject: [PATCH RESEND net-next v7 4/4] virtio-net: support dim profile fine-tuning Date: Mon, 15 Apr 2024 21:38:07 +0800 Message-Id: <20240415133807.116394-5-hengqi@linux.alibaba.com> X-Mailer: git-send-email 2.32.0.3.g01195cf9f In-Reply-To: <20240415133807.116394-1-hengqi@linux.alibaba.com> References: <20240415133807.116394-1-hengqi@linux.alibaba.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Virtio-net has different types of back-end device implementations. In order to effectively optimize the dim library's gains for different device implementations, let's use the new interface params to fine-tune the profile list. Since the profile now exists in netdevice, adding a function similar to net_dim_get_rx_moderation_dev() with netdevice as argument is nice, but this would be better along with cleaning up the rest of the drivers, which we can get to very soon after this set. Signed-off-by: Heng Qi --- drivers/net/virtio_net.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index 858d7ab89e34..1f7201b82be6 100644 --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c @@ -3584,7 +3584,7 @@ static void virtnet_rx_dim_work(struct work_struct *work) if (!rq->dim_enabled) continue; - update_moder = net_dim_get_rx_moderation(dim->mode, dim->profile_ix); + update_moder = dev->moderation->rx_eqe_profile[dim->profile_ix]; if (update_moder.usec != rq->intr_coal.max_usecs || update_moder.pkts != rq->intr_coal.max_packets) { err = virtnet_send_rx_ctrl_coal_vq_cmd(vi, qnum, @@ -3884,7 +3884,8 @@ static int virtnet_set_rxnfc(struct net_device *dev, struct ethtool_rxnfc *info) static const struct ethtool_ops virtnet_ethtool_ops = { .supported_coalesce_params = ETHTOOL_COALESCE_MAX_FRAMES | - ETHTOOL_COALESCE_USECS | ETHTOOL_COALESCE_USE_ADAPTIVE_RX, + ETHTOOL_COALESCE_USECS | ETHTOOL_COALESCE_USE_ADAPTIVE_RX | + ETHTOOL_COALESCE_RX_EQE_PROFILE, .get_drvinfo = virtnet_get_drvinfo, .get_link = ethtool_op_get_link, .get_ringparam = virtnet_get_ringparam, @@ -4440,6 +4441,7 @@ static int virtnet_find_vqs(struct virtnet_info *vi) static void virtnet_dim_init(struct virtnet_info *vi) { + struct netdev_profile_moder *moder = vi->dev->moderation; int i; if (!virtio_has_feature(vi->vdev, VIRTIO_NET_F_VQ_NOTF_COAL)) @@ -4449,6 +4451,8 @@ static void virtnet_dim_init(struct virtnet_info *vi) INIT_WORK(&vi->rq[i].dim.work, virtnet_rx_dim_work); vi->rq[i].dim.mode = DIM_CQ_PERIOD_MODE_START_FROM_EQE; } + + moder->flags |= NETDEV_PROFILE_USEC | NETDEV_PROFILE_PKTS; } static int virtnet_alloc_queues(struct virtnet_info *vi)