RE: [EXTERNAL] Re: [PATCH v2 2/5] tools: hv: Add vmbus_bufring

From: Saurabh Singh Sengar
Date: Tue Jun 20 2023 - 01:25:17 EST




> -----Original Message-----
> From: Greg KH <gregkh@xxxxxxxxxxxxxxxxxxx>
> Sent: Thursday, June 15, 2023 2:46 AM
> To: Saurabh Sengar <ssengar@xxxxxxxxxxxxxxxxxxx>
> Cc: KY Srinivasan <kys@xxxxxxxxxxxxx>; Haiyang Zhang
> <haiyangz@xxxxxxxxxxxxx>; wei.liu@xxxxxxxxxx; Dexuan Cui
> <decui@xxxxxxxxxxxxx>; Michael Kelley (LINUX) <mikelley@xxxxxxxxxxxxx>;
> corbet@xxxxxxx; linux-kernel@xxxxxxxxxxxxxxx; linux-hyperv@xxxxxxxxxxxxxxx;
> linux-doc@xxxxxxxxxxxxxxx
> Subject: [EXTERNAL] Re: [PATCH v2 2/5] tools: hv: Add vmbus_bufring
>
> On Wed, Jun 14, 2023 at 11:15:09AM -0700, Saurabh Sengar wrote:
> > Common userspace interface for read/write from VMBus ringbuffer.
> > This implementation is open for use by any userspace driver or
> > application seeking direct control over VMBus ring buffers.
> > A significant part of this code is borrowed from DPDK.
>
> " "?
>
> Anyway, this does not explain what this is at all.

I can elaborate more in next version.

>
> And if you "borrowed" it from DPDK, that feels odd, are you sure you are
> allowed to do so?

I will confirm this internally before sending next version.

>
> > Link:
> > https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgith
> >
> ub.com%2FDPDK%2Fdpdk%2F&data=05%7C01%7Cssengar%40microsoft.com
> %7C79975
> >
> a82b7b44c67b0b508db6d1c9301%7C72f988bf86f141af91ab2d7cd011db47%7
> C1%7C0
> >
> %7C638223741757437265%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLj
> AwMDAiLCJQ
> >
> IjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata
> =100fd
> > FVed6C5lBrikWqkWwFpfH33LHF0H8fuRb0myL0%3D&reserved=0
>
> Not what a Link: tag is for, sorry.

Will fix, thanks for pointing this.

>
> >
> > Signed-off-by: Saurabh Sengar <ssengar@xxxxxxxxxxxxxxxxxxx>
> > ---
> > [V2]
> > - simpler sysfs path, less parsing
> >
> > tools/hv/vmbus_bufring.c | 322
> > +++++++++++++++++++++++++++++++++++++++
> > tools/hv/vmbus_bufring.h | 158 +++++++++++++++++++
> > 2 files changed, 480 insertions(+)
> > create mode 100644 tools/hv/vmbus_bufring.c create mode 100644
> > tools/hv/vmbus_bufring.h
>
> You add new files to the tools directory, yet say nothing about how to use
> them or even how to build them.
>
> Why is there a .h file for a single .c file? That seems pointless, right?

This is a header file so that any userspace application can add it. This file
Is used by fcopy application in [PATCH v2 3/5] of this patch series.
If this is confusing, shall I merge 2/5 and 3/5 ? I thought better to keep the
common library code as separate patch. Please let me know your opinion.

>
> > diff --git a/tools/hv/vmbus_bufring.c b/tools/hv/vmbus_bufring.c new
> > file mode 100644 index 000000000000..d44a06d45b03
> > --- /dev/null
> > +++ b/tools/hv/vmbus_bufring.c
> > @@ -0,0 +1,322 @@
> > +// SPDX-License-Identifier: BSD-3-Clause
> > +/*
> > + * Copyright (c) 2009-2012,2016,2023 Microsoft Corp.
> > + * Copyright (c) 2012 NetApp Inc.
> > + * Copyright (c) 2012 Citrix Inc.
> > + * All rights reserved.
>
> No copyright for the work you did?

I have added 2023 Microsoft Corp. Please let me know if I need to add
anything more.

>
> > + */
> > +
> > +#include <errno.h>
> > +#include <fcntl.h>
> > +#include <emmintrin.h>
> > +#include <linux/limits.h>
> > +#include <stdbool.h>
> > +#include <stdint.h>
> > +#include <stdio.h>
> > +#include <string.h>
> > +#include <sys/mman.h>
> > +#include <sys/uio.h>
> > +#include <unistd.h>
> > +#include "vmbus_bufring.h"
> > +
> > +#define rte_compiler_barrier() ({ asm volatile ("" : : : "memory"); })
> > +
> > +#define rte_smp_rwmb() ({ asm volatile ("" : : :
> "memory"); })
>
> These aren't in any common header file already?

I see every userspace application is maintaining their separate copy of this.
Although I can remove this duplicate define and can use only one of these.

- Saurabh

>
> thanks,
>
> greg k-h