All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yishai Hadas <yishaih-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
To: Jason Gunthorpe
	<jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
Cc: Yishai Hadas <yishaih-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	roland-BHEL68pLQRGGvPXPguhicg@public.gmane.org,
	ogerlitz-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org,
	tzahio-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org,
	Sean Hefty <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Subject: Re: [PATCH V8 libibverbs 1/7] Infrastructure to support verbs extensions
Date: Fri, 26 Jul 2013 15:16:49 +0300	[thread overview]
Message-ID: <51F268B1.9040003@dev.mellanox.co.il> (raw)
In-Reply-To: <20130725171408.GA17616-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>

On 7/25/2013 8:14 PM, Jason Gunthorpe wrote:
> On Thu, Jul 25, 2013 at 11:38:02AM +0300, Yishai Hadas wrote:
>
>> +#ifndef container_of
>> +/**
>> +  * container_of - cast a member of a structure out to the containing structure
>> +  * @ptr:        the pointer to the member.
>> +  * @type:       the type of the container struct this is embedded in.
>> +  * @member:     the name of the member within the struct.
>> +  *
>> + */
>> +#define container_of(ptr, type, member) \
>> +	((type *) ((char *)(ptr) - offsetof(type, member)))
>                   ^^^^^^^^^^^^
>
> This should be 'uint8_t'
>
>> +#define vext_field_avail(type, fld, sz) (offsetof(type, fld) < (sz))
> This is never used? Should it be? Ditch it?
     It's used in further patches of libibverbs, please have a look at: 
ibv_cmd_create_qp_ex, ibv_cmd_create_srq_ex, etc.
>
>> +static inline struct verbs_context *verbs_get_ctx(
>> +					const struct ibv_context *ctx)
>                    ^^^^^^^^^^^^^
> const goes in, const goes out. Should be:
>
> static inline const struct verbs_context *verbs_get_ctx(const struct ibv_context *ctx)
>
>> +{
>> +	return (ctx->abi_compat != ((uint8_t *)NULL) - 1) ?
>                                 ^^^^^^^^^^^^^^^^^^^^^^
>
> Should this be a constant? __VERBS_ABI_IS_EXTENDED or something?
     Can you clarify your suggestion here ?
>
>> +#define verbs_get_ctx_op(ctx, op) ({ \
>> +	struct verbs_context *vctx = verbs_get_ctx(ctx); \
>             ^^^^ const
>> +	(!vctx || (vctx->sz < sizeof(*vctx) - offsetof(struct verbs_context, op)) || \
>> +	 !vctx->op) ? NULL : vctx; })
> An inline would be nicer, it will let the compiler merge these when
> using -Os.
>
> static inline const struct verbs_context *__verbs_get_ctx_op(const struct ibv_context *ctx, size_t off)
> {
>      const struct verbs_context *vctx = verbs_get_ctx(ctx);
>      if (vctx && vctx->sz < sizeof(*vctx) - off && *(void **)((uint8_t *)vctx + off))
>          return vctx;
>      return null
> }
> #define verbs_get_ctx_op(ctx, op) __verbs_get_ctx_op(ctx, offsetof(struct verbs_context, op))
>
> This also solves the problems the macro has with missing ()
     Which problems you refer to with missing () ?
>
>> +#define verbs_set_ctx_op(vctx, op, ptr) ({ \
>> +	if (vctx && (vctx->sz >= sizeof(*vctx) - offsetof(struct verbs_context, op))) \
>> +		vctx->op = ptr; })
> Lots of missing (), and no type check on vctx. This is better and
> centralizes the tricky check into __verbs_get_ctx_op:
>
> #define verbs_set_ctx_op(vctx, op, ptr) ({ \
>     struct verbs_context *__vctx = (struct verbs_context *)verbs_get_ctx_op((vctx)->context, op); \
>     if (__vctx) __vctx->op = ptr; })
>
>> +		context_ex->context.abi_compat  = ((uint8_t *)NULL) - 1;
>                                                  ^^^^^^^^^^^^^^^^^^^^^^
> Constant?
>
> Otherwise this appears to be as we discussed and agreed last year, so
> you can add my Ack to this patch.
     Thanks, any other input on V8 series ?
>
> Please confirm you have done testing with extending and shrinking
> verbs_context to test that verbs_get_ctx_op truely works properly.
     Already did, will do further testing after adapting to your 
suggestions above.
> Jason
> --
> To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
> the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2013-07-26 12:16 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-25  8:38 [PATCH V8 libibverbs 0/7] Add extension and XRC QP support Yishai Hadas
     [not found] ` <1374741488-30895-1-git-send-email-yishaih-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2013-07-25  8:38   ` [PATCH V8 libibverbs 1/7] Infrastructure to support verbs extensions Yishai Hadas
     [not found]     ` <1374741488-30895-2-git-send-email-yishaih-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2013-07-25 17:14       ` Jason Gunthorpe
     [not found]         ` <20130725171408.GA17616-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2013-07-26 12:16           ` Yishai Hadas [this message]
     [not found]             ` <51F268B1.9040003-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
2013-07-29 23:30               ` Jason Gunthorpe
     [not found]                 ` <51F821A3.1010507@dev.mellanox.co.il>
     [not found]                   ` <51F821A3.1010507-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
2013-07-30 22:15                     ` Jason Gunthorpe
     [not found]                       ` <20130730221548.GA14439-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2013-07-31  7:27                         ` Yishai Hadas
     [not found]                           ` <51F8BC4A.5010102-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
2013-07-31 16:52                             ` Jason Gunthorpe
     [not found]                               ` <20130731165205.GC27845-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2013-08-01 16:01                                 ` Yishai Hadas
2013-07-25  8:38   ` [PATCH V8 libibverbs 2/7] Introduce XRC domains Yishai Hadas
2013-07-25  8:38   ` [PATCH V8 libibverbs 3/7] Add support for XRC SRQs Yishai Hadas
2013-07-25  8:38   ` [PATCH V8 libibverbs 4/7] Add support for XRC QPs Yishai Hadas
2013-07-25  8:38   ` [PATCH V8 libibverbs 5/7] Add ibv_open_qp Yishai Hadas
2013-07-25  8:38   ` [PATCH V8 libibverbs 6/7] XRC man pages Yishai Hadas
2013-07-25  8:38   ` [PATCH V8 libibverbs 7/7] Add XRC sample application Yishai Hadas

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=51F268B1.9040003@dev.mellanox.co.il \
    --to=yishaih-ldsdmyg8hgv8yrgs2mwiifqbs+8scbdb@public.gmane.org \
    --cc=jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org \
    --cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=ogerlitz-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org \
    --cc=roland-BHEL68pLQRGGvPXPguhicg@public.gmane.org \
    --cc=sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
    --cc=tzahio-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org \
    --cc=yishaih-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.