From: Jason Gunthorpe <jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
To: Matan Barak <matanb-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
Cc: Doug Ledford <dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>,
linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Liran Liss <liranl-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>,
Sean Hefty <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
Leon Romanovsky <leonro-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>,
Majd Dibbiny <majd-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>,
Tal Alon <talal-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>,
Yishai Hadas <yishaih-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>,
Ira Weiny <ira.weiny-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
Haggai Eran <haggaie-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>,
Christoph Lameter <cl-vYTEC60ixJUAvxtiuMwx3w@public.gmane.org>
Subject: Re: [PATCH V1 for-next 4/7] IB/core: Change idr objects to use the new schema
Date: Fri, 10 Feb 2017 13:30:48 -0700 [thread overview]
Message-ID: <20170210203048.GD4335@obsidianresearch.com> (raw)
In-Reply-To: <1485952745-58476-5-git-send-email-matanb-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
On Wed, Feb 01, 2017 at 02:39:02PM +0200, Matan Barak wrote:
> +#define idr_get_xxxx(_type, _write, _handle, _context) ({ \
> + const struct uverbs_obj_idr_type * const type = \
> + &uverbs_type_attrs_##_type; \
> + struct ib_uobject *uobj = type->type.ops->lookup_get(&type->type, \
> + _context, _handle, _write); \
> + \
> + IS_ERR(uobj) ? NULL : uobj->object; })
I think you should follow the usual convention and have a full
suite of accessor helpers in a header. This header could even be in
patch #2
static struct ib_uobject *__uobj_get(const struct uverbs_obj_type *type, bool write, struct ib_ucontext *ucontext, int id)
{
[..]
}
#define uobj_get_read(_type,...) ((struct ib_##_type *)_uobj_get(&uverbs_type_attrs_##_type, false, __VA_ARGS__))
#define uobj_get_write(_type,...) ((struct ib_##_type *)_uobj_get(&uverbs_type_attrs_##_type, false, __VA_ARGS__))
static inline void uobj_put_write(struct ib_uobject *uobj)
{
uobj->type->ops->lookup_put(uobj, true);
}
static inline void uobj_put_read(struct ib_uobject *uobj)
{
uobj->type->ops->lookup_put(uobj, false);
}
static inline struct ib_uobject *__uobj_alloc(const struct uverbs_obj_type *type,struct ib_ucontext *ucontext)
{
return type->alloc_begin(type, ucontext);
}
#define uobj_alloc_begin(_type, ...) ((struct ib_##_type *)_uobj_alloc(&uverbs_type_attrs_##_type, __VA_ARGS__))
and so on
> static struct ib_pd *idr_read_pd(int pd_handle, struct ib_ucontext *context)
> {
> - return idr_read_obj(pd_handle, context, 0);
> + return idr_get_xxxx(pd, false, pd_handle, context);
> }
And you can just totally drop all of these inlines and use
uobj_get_read(pd, pd_handle, context);
At the call site.
> static struct ib_xrcd *idr_read_xrcd(int xrcd_handle, struct ib_ucontext *context,
> struct ib_uobject **uobj)
> {
> - *uobj = idr_read_uobj(xrcd_handle, context, 0);
> - return *uobj ? (*uobj)->object : NULL;
> + *uobj = uverbs_type_attrs_xrcd.type.ops->lookup_get(&uverbs_type_attrs_xrcd.type,
> + context, xrcd_handle,
> + false);
> + return IS_ERR(*uobj) ? NULL : (*uobj)->object;
Why didn't this use idr_get_xxx ? Why is it so weird?
>
> @@ -621,9 +439,11 @@ ssize_t ib_uverbs_dealloc_pd(struct ib_uverbs_file *file,
> if (copy_from_user(&cmd, buf, sizeof cmd))
> return -EFAULT;
>
> - uobj = idr_write_uobj(cmd.pd_handle, file->ucontext);
> - if (!uobj)
> - return -EINVAL;
> + uobj = uverbs_type_attrs_pd.type.ops->lookup_get(&uverbs_type_attrs_pd.type,
> + file->ucontext,
> + cmd.pd_handle, true);
> + if (IS_ERR(uobj))
> + return PTR_ERR(uobj);
> pd = uobj->object;
>
> if (atomic_read(&pd->usecnt)) {
> @@ -636,21 +456,12 @@ ssize_t ib_uverbs_dealloc_pd(struct ib_uverbs_file *file,
> if (ret)
> goto err_put;
>
> - uobj->live = 0;
> - put_uobj_write(uobj);
> -
> - idr_remove_uobj(uobj);
> -
> - mutex_lock(&file->mutex);
> - list_del(&uobj->list);
> - mutex_unlock(&file->mutex);
> -
> - put_uobj(uobj);
> + uobj->type->ops->destroy_commit(uobj);
And here I think you should move the pd->device_dealloc_pd into
destroy_commit by having it call what you called hot_plug, and turn
this simply into:
return uobj_remove_or_put(uobj, RDMA_REMOVE_DESTROY);
static inline int uobj_remove_or_put(struct ib_uobject *uobj, enum rdma_remove_reason why)
{
int rc = uobj->type->ops->remove(uobj, why);
if (!rc)
uverbs_uobject_put(uobj);
/* If we are using a forced destruction mode then the driver is
not permitted to fail. */
WARN_ON(!rc && why != RDMA_REMOVE_DESTROY);
return rc;
}
And generally use this pattern for all the destroy verbs.
I didn't study this patch closely since it will change a lot, but I
think this:
4 files changed, 260 insertions(+), 788 deletions(-)
Pretty much confirms this is the right overall approach.
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
next prev parent reply other threads:[~2017-02-10 20:30 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-01 12:38 [PATCH V1 for-next 0/7] Change IDR usage and locking in uverbs Matan Barak
[not found] ` <1485952745-58476-1-git-send-email-matanb-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2017-02-01 12:38 ` [PATCH V1 for-next 1/7] IB/core: Refactor idr to be per uverbs_file Matan Barak
[not found] ` <1485952745-58476-2-git-send-email-matanb-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2017-02-10 17:53 ` Jason Gunthorpe
[not found] ` <20170210175320.GA4335-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2017-02-15 13:41 ` Matan Barak
2017-02-01 12:39 ` [PATCH V1 for-next 2/7] IB/core: Add support for idr types Matan Barak
[not found] ` <1485952745-58476-3-git-send-email-matanb-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2017-02-10 19:56 ` Jason Gunthorpe
[not found] ` <20170210195604.GB4335-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2017-02-15 13:43 ` Matan Barak
[not found] ` <CAAKD3BBFiayiM_=7bo2y52hL=7uMDk8nsz+7jY_+qoPdo05P9g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-02-15 18:06 ` Jason Gunthorpe
2017-02-01 12:39 ` [PATCH V1 for-next 3/7] IB/core: Add idr based standard types Matan Barak
[not found] ` <1485952745-58476-4-git-send-email-matanb-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2017-02-10 20:08 ` Jason Gunthorpe
[not found] ` <20170210200849.GC4335-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2017-02-15 13:44 ` Matan Barak
[not found] ` <CAAKD3BDyg04Y0c9Pn1YbxZyxR8PpRFYbpF8UokFcgi7CdUcj3A-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-02-15 18:09 ` Jason Gunthorpe
2017-02-01 12:39 ` [PATCH V1 for-next 4/7] IB/core: Change idr objects to use the new schema Matan Barak
[not found] ` <1485952745-58476-5-git-send-email-matanb-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2017-02-10 20:30 ` Jason Gunthorpe [this message]
[not found] ` <20170210203048.GD4335-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2017-02-15 13:45 ` Matan Barak
[not found] ` <CAAKD3BAUZpf5pr4G3Uv=ikD3WGgOgmbcz2WnrPm3FCJiSFCVJg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-02-15 18:11 ` Jason Gunthorpe
2017-02-01 12:39 ` [PATCH V1 for-next 5/7] IB/core: Add lock to multicast handlers Matan Barak
2017-02-01 12:39 ` [PATCH V1 for-next 6/7] IB/core: Add support for fd objects Matan Barak
[not found] ` <1485952745-58476-7-git-send-email-matanb-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2017-02-10 21:03 ` Jason Gunthorpe
[not found] ` <20170210210350.GE4335-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2017-02-15 13:48 ` Matan Barak
[not found] ` <CAAKD3BDbQVfC06Kzud=j=+a32YFxwcxrqm41SyhL0uWXm0O0Hw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-02-15 18:54 ` Jason Gunthorpe
[not found] ` <20170215185448.GE19162-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2017-02-19 12:47 ` Matan Barak
[not found] ` <CAAKD3BD-Uyg9bN=EaB3GbqhaKsKUszKXD6YaVAUxBp8cQcJgbQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-02-21 19:24 ` Jason Gunthorpe
2017-02-01 12:39 ` [PATCH V1 for-next 7/7] IB/core: Change completion channel to use the reworked objects schema Matan Barak
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=20170210203048.GD4335@obsidianresearch.com \
--to=jgunthorpe-epgobjl8dl3ta4ec/59zmfatqe2ktcn/@public.gmane.org \
--cc=cl-vYTEC60ixJUAvxtiuMwx3w@public.gmane.org \
--cc=dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
--cc=haggaie-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org \
--cc=ira.weiny-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
--cc=leonro-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org \
--cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=liranl-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org \
--cc=majd-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org \
--cc=matanb-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org \
--cc=sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
--cc=talal-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.