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,
Yishai Hadas <yishaih-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>,
Sean Hefty <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
Ira Weiny <ira.weiny-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
Christoph Lameter <cl-vYTEC60ixJUAvxtiuMwx3w@public.gmane.org>,
Majd Dibbiny <majd-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>,
Tal Alon <talal-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>,
Leon Romanovsky <leonro-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>,
Liran Liss <liranl-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>,
Haggai Eran <haggaie-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
Subject: Re: [PATCH for-next 3/7] IB/core: Add support for fd objects
Date: Wed, 11 Jan 2017 16:58:01 -0700 [thread overview]
Message-ID: <20170111235801.GC31682@obsidianresearch.com> (raw)
In-Reply-To: <1484132033-3346-4-git-send-email-matanb-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
On Wed, Jan 11, 2017 at 12:53:49PM +0200, Matan Barak wrote:
> This commit adds the necessary mechanism to support FD based objects
> like their IDR counterparts. FD objects release need to be synchronized
> with context release. Since FDs could outlives their context, we use
> a kref on this lock. We initialize the lock and the kref in downstream
> patches. This is acceptable, as we don't use this infrastructure until
> a later point in this series.
This seems unnecessarily complicated. Just hold the kref on the
ucontext in the fd. There isn't a problem with a dummy version of that
struct hanging around..
> +static struct ib_uobject *uverbs_get_uobject_from_fd(const struct uverbs_type_alloc_action *type_alloc,
> + struct ib_ucontext *ucontext,
> + enum uverbs_idr_access access,
> + unsigned int fd)
> +{
> + if (access == UVERBS_ACCESS_NEW) {
> + int _fd;
Something has gone terribly wrong if you need _ to disambiguate with a
function argument...
> + } else if (access == UVERBS_ACCESS_READ) {
> + struct file *f = fget(fd);
> + struct ib_uobject *uobject;
> +
> + if (!f)
> + return ERR_PTR(-EBADF);
> +
> + uobject = uverbs_priv_fd_to_uobject(f->private_data);
> + if (f->f_op != type_alloc->fd.fops ||
> + !uobject->context) {
I think the if should be split, if fops isn't correct then do not even
call uverbs_priv_fd_to_uobject.
> +void uverbs_cleanup_fd(void *private_data)
> +{
> + struct ib_uobject *uobject = uverbs_priv_fd_to_uobject(private_data);
> +
> + kfree(uobject);
> +}
Woah, this is not OK at this point in the series. There is really too
much stuff bundled into patch 7 to make proper sense of this.
I don't like this design. Do not implicitly prepend ib_uobject to
structures. Require the users to include the struct as is common in
linux.
Do not drop the kref out of ib_uobject, that should be the master
kref, drop the kref out of ib_uverbs_event_file instead.
> +static inline void *uverbs_fd_uobj_to_priv(struct ib_uobject *uobj)
> +{
> + return uobj + 1;
> +}
Which means stuff like this can go away..
> - int id; /* index into kernel idr */
> + int id; /* index into kernel idr/fd */
Why do we need to store the fd number at all? We can *never* use it in
the kernel except as the argument to fdinstall. For that reason we
should never store it.
Can you move the fdallocate into finalize? At the very least 0 the
value after fdinstall so people don't get the wrong idea down the
road.
> int order;
> size_t obj_size;
> free_type free_fn;
> + struct {
> + const struct file_operations *fops;
> + const char *name;
Maybe name should be common
This idea also seems reasonable to me in general, but again, I'd
rather see it more completely implemented in this patch instead of
deferring so much stuff in to the giant #7 patch.
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-01-11 23:58 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-11 10:53 [PATCH for-next 0/7] Change IDR usage and locking in uverbs Matan Barak
[not found] ` <1484132033-3346-1-git-send-email-matanb-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2017-01-11 10:53 ` [PATCH for-next 1/7] IB/core: Refactor IDR to be per-device Matan Barak
[not found] ` <1484132033-3346-2-git-send-email-matanb-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2017-01-11 22:39 ` Jason Gunthorpe
[not found] ` <20170111223917.GA31682-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2017-01-17 17:08 ` Matan Barak
[not found] ` <CAAKD3BDMDyahSu1uFPE_bA=QXAy9Q+qdMPoVw-hJTrFN3um9rg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-01-17 18:09 ` Jason Gunthorpe
2017-01-11 10:53 ` [PATCH for-next 2/7] IB/core: Add support for custom types Matan Barak
[not found] ` <1484132033-3346-3-git-send-email-matanb-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2017-01-11 23:28 ` Jason Gunthorpe
[not found] ` <20170111232811.GB31682-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2017-01-17 17:23 ` Matan Barak
[not found] ` <CAAKD3BBkzoLuY3TF=bDK3U=rnLzK0uWmDL2tgsUwmBoGTXAqrw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-01-17 19:01 ` Jason Gunthorpe
2017-01-11 10:53 ` [PATCH for-next 3/7] IB/core: Add support for fd objects Matan Barak
[not found] ` <1484132033-3346-4-git-send-email-matanb-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2017-01-11 23:58 ` Jason Gunthorpe [this message]
[not found] ` <20170111235801.GC31682-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2017-01-17 17:24 ` Matan Barak
[not found] ` <CAAKD3BBQLxnh-keng+LjZEyWBYKbXN_Sszk1BcGnyVeZU_45nw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-01-17 19:11 ` Jason Gunthorpe
2017-01-11 10:53 ` [PATCH for-next 4/7] IB/core: Add generic ucontext initialization and teardown Matan Barak
[not found] ` <1484132033-3346-5-git-send-email-matanb-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2017-01-12 0:09 ` Jason Gunthorpe
2017-01-11 10:53 ` [PATCH for-next 5/7] IB/core: Add macros for declaring types and type groups Matan Barak
[not found] ` <1484132033-3346-6-git-send-email-matanb-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2017-01-12 0:10 ` Jason Gunthorpe
[not found] ` <20170112001029.GE31682-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2017-01-17 17:25 ` Matan Barak
[not found] ` <CAAKD3BCvEP4MdvSy6dD0DDjfyd+PO8Y=7O+qFwPO5rjGDW_nfA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-01-17 19:13 ` Jason Gunthorpe
2017-01-11 10:53 ` [PATCH for-next 6/7] IB/core: Declare all common IB types Matan Barak
[not found] ` <1484132033-3346-7-git-send-email-matanb-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2017-01-12 0:19 ` Jason Gunthorpe
[not found] ` <20170112001955.GF31682-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2017-01-12 6:48 ` Matan Barak
2017-01-17 17:37 ` Matan Barak
[not found] ` <CAAKD3BBKnJRNF+iqRSkjmGVcff=Hd68wVvXW7y+=pnnc4=yDfA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-01-17 19:15 ` Jason Gunthorpe
2017-01-11 10:53 ` [PATCH for-next 7/7] IB/core: Use the new IDR and locking infrastructure in uverbs_cmd Matan Barak
[not found] ` <1484132033-3346-8-git-send-email-matanb-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2017-01-11 22:49 ` kbuild test robot
2017-01-11 23:43 ` kbuild test robot
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=20170111235801.GC31682@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).