Re: [PATCH 04/10] RDMA: Add ib_is_udata_in_empty()

Jason Gunthorpe
2026-02-13T12:56:37Z

On Fri, Feb 13, 2026 at 12:22:40PM +0200, Leon Romanovsky wrote:
> On Thu, Feb 05, 2026 at 09:45:38PM -0400, Jason Gunthorpe wrote:
> > If the driver doesn't yet support any request driver data it should check
> > that it is all zeroed. This is a common pattern, add a helper to do this.
> >
> > Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
> > ---
> > include/rdma/ib_verbs.h | 14 ++++++++++++++
> > 1 file changed, 14 insertions(+)
> >
> > diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
> > index c0dd82a77e7a13..973d9ec6875e63 100644
> > --- a/include/rdma/ib_verbs.h
> > +++ b/include/rdma/ib_verbs.h
> > @@ -3119,6 +3119,20 @@ static inline bool ib_is_udata_cleared(struct ib_udata *udata,
> > return ib_is_buffer_cleared(udata->inbuf + offset, len);
> > }
> >
> > +/**
> > + * ib_is_udata_in_empty - Check if the udata is empty
> > + * @udata: The system calls ib_udata struct
> > + *
> > + * This should be used if the driver does not currently define a driver data
> > + * struct.
> > + */
> > +static inline bool ib_is_udata_in_empty(struct ib_udata *udata)
> > +{
> > + if (udata && udata->inlen != 0)
> > + return ib_is_buffer_cleared(udata->inbuf, udata->inlen);
>
> The number of existing callers of ib_is_buffer_cleared() and very
> similar ib_is_udata_cleared() check caused me to think that udata->inlen
> != 0 needs to be checked in ib_is_buffer_cleared().

There is probably something that could be slightly improved here, but
I'm going to leave it for another day.

It should also be using check_zeroed_user() not what it has there..

After my next series there are only two remaining callers of
ib_is_buffer_cleared() and two of ib_is_udata_cleared().

Jason