[dpdk-dev,2/4] vhost: avoid function call in data path

Message ID 1518580892-32656-3-git-send-email-jianfeng.tan@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Maxime Coquelin
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Jianfeng Tan Feb. 14, 2018, 4:01 a.m. UTC
  Previously, get_device() is a function call. It's OK for slow path
configuration, but takes some cycles for data path.

To avoid that, we turn this function to inline type.

Cc: maxime.coquelin@redhat.com
Cc: yliu@fridaylinux.org

Signed-off-by: Jianfeng Tan <jianfeng.tan@intel.com>
---
 lib/librte_vhost/vhost.c | 13 -------------
 lib/librte_vhost/vhost.h | 13 ++++++++++++-
 2 files changed, 12 insertions(+), 14 deletions(-)
  

Comments

Maxime Coquelin Feb. 19, 2018, 8:48 p.m. UTC | #1
On 02/14/2018 05:01 AM, Jianfeng Tan wrote:
> Previously, get_device() is a function call. It's OK for slow path
> configuration, but takes some cycles for data path.
> 
> To avoid that, we turn this function to inline type.
> 
> Cc: maxime.coquelin@redhat.com
> Cc: yliu@fridaylinux.org
> 
> Signed-off-by: Jianfeng Tan <jianfeng.tan@intel.com>
> ---
>   lib/librte_vhost/vhost.c | 13 -------------
>   lib/librte_vhost/vhost.h | 13 ++++++++++++-
>   2 files changed, 12 insertions(+), 14 deletions(-)

Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>

Thanks,
Maxime
  
Maxime Coquelin Feb. 21, 2018, 7:32 a.m. UTC | #2
On 02/19/2018 09:48 PM, Maxime Coquelin wrote:
> 
> 
> On 02/14/2018 05:01 AM, Jianfeng Tan wrote:
>> Previously, get_device() is a function call. It's OK for slow path
>> configuration, but takes some cycles for data path.
>>
>> To avoid that, we turn this function to inline type.
>>
>> Cc: maxime.coquelin@redhat.com
>> Cc: yliu@fridaylinux.org
>>
>> Signed-off-by: Jianfeng Tan <jianfeng.tan@intel.com>
>> ---
>>   lib/librte_vhost/vhost.c | 13 -------------
>>   lib/librte_vhost/vhost.h | 13 ++++++++++++-
>>   2 files changed, 12 insertions(+), 14 deletions(-)
> 
> Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>

Applied to dpdk-next-virtio/master.

Thanks,
Maxime
  

Patch

diff --git a/lib/librte_vhost/vhost.c b/lib/librte_vhost/vhost.c
index a407067..f6f12a0 100644
--- a/lib/librte_vhost/vhost.c
+++ b/lib/librte_vhost/vhost.c
@@ -68,19 +68,6 @@  __vhost_iova_to_vva(struct virtio_net *dev, struct vhost_virtqueue *vq,
 	return 0;
 }
 
-struct virtio_net *
-get_device(int vid)
-{
-	struct virtio_net *dev = vhost_devices[vid];
-
-	if (unlikely(!dev)) {
-		RTE_LOG(ERR, VHOST_CONFIG,
-			"(%d) device not found.\n", vid);
-	}
-
-	return dev;
-}
-
 void
 cleanup_vq(struct vhost_virtqueue *vq, int destroy)
 {
diff --git a/lib/librte_vhost/vhost.h b/lib/librte_vhost/vhost.h
index ecd5b7b..3fce13b 100644
--- a/lib/librte_vhost/vhost.h
+++ b/lib/librte_vhost/vhost.h
@@ -343,7 +343,18 @@  gpa_to_hpa(struct virtio_net *dev, uint64_t gpa, uint64_t size)
 	return 0;
 }
 
-struct virtio_net *get_device(int vid);
+static __rte_always_inline struct virtio_net *
+get_device(int vid)
+{
+	struct virtio_net *dev = vhost_devices[vid];
+
+	if (unlikely(!dev)) {
+		RTE_LOG(ERR, VHOST_CONFIG,
+			"(%d) device not found.\n", vid);
+	}
+
+	return dev;
+}
 
 int vhost_new_device(void);
 void cleanup_device(struct virtio_net *dev, int destroy);