From: Yishai Hadas <yishaih-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
To: Doug Ledford <dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>,
Jason Gunthorpe
<jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
Cc: Yishai Hadas <yishaih-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>,
linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
jackm-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org,
raindel-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org,
Jack Morgenstein
<jackm-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
Subject: Re: [PATCH V3 for-next 1/3] IB/uverbs: Enable device removal when there are active user space applications
Date: Wed, 27 May 2015 23:47:31 +0300 [thread overview]
Message-ID: <55662D63.3030806@dev.mellanox.co.il> (raw)
In-Reply-To: <1432742669.28905.228.camel-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
On 5/27/2015 7:04 PM, Doug Ledford wrote:
> On Mon, 2015-05-25 at 10:54 -0600, Jason Gunthorpe wrote:
>> On Wed, May 13, 2015 at 02:10:36PM +0300, Yishai Hadas wrote:
>>
>>> + struct srcu_struct disassociate_srcu;
>>
>> There is no need for rcu for this, use a rw sem.
>
> The rcu was used becuase it's on the hot path I assume. Do we have
> numbers on whether a rwsem vs. an rcu matters performance wise? If the
> rcu actually helps performance, then I'm inclined to leave it, but if it
> doesn't, then I'd agree that a rwsem is simpler and easier to deal with.
>
That's correct, it was chosen from performance reasons to enable
parallel commands as part of ib_uverbs_write with minimum
synchronization overhead comparing the rwsem.
Most of its usage is for read, upon low level device removal there is
only one point when synchronize_srcu is used.
>>> @@ -1326,6 +1327,13 @@ ssize_t ib_uverbs_create_comp_channel(struct ib_uverbs_file *file,
>>> return -EFAULT;
>>> }
>>>
>>> + /* Taking ref count on uverbs_file to make sure that file won't be
>>> + * freed till that event file is closed. It will enable accessing the
>>> + * uverbs_device fields as part of closing the events file and making
>>> + * sure that uverbs device is available by that time as well.
>>> + * Note: similar is already done for the async event file.
>>> + */
>>> + kref_get(&file->ref);
>>
>> Is this a bug today? It doesn't look like it, but this stuff does look wrong.
>>
>> Woulnd't this would make more sense for ib_uverbs_alloc_event_file to
>> unconditionally grab the kref and unconditionally release it on
>> release?
>>
>> The existing code for this looks broken, in ib_uverbs_get_context all
>> the error paths between ib_uverbs_alloc_event_file and the
>> kref_get(file->ref) are wrong - the will result in fput() which will
>> call ib_uverbs_event_close, which will try to do kref_put and
>> ib_unregister_event_handler - which are no longer paired.
>>
>> [I recommend moving the kref_get and ib_register_event_handler into
>> ib_uverbs_alloc_event_file, so the 'create' and 'destroy' code paths
>> are clearly paired instead of being partially open coded in call
>> sites]
>>
>> Fix all this in a seperate patch to add the needed change in kref
>> semantics please.
>
> Seconded.
OK, will add a separate patch to handle that.
>
>>> - if (!try_module_get(dev->ib_dev->owner)) {
>>> - ret = -ENODEV;
>>> + mutex_lock(&dev->disassociate_mutex);
>>> + if (dev->disassociated) {
>>> + ret = -EIO;
>>> goto err;
>>> }
>>>
>>> - file = kmalloc(sizeof *file, GFP_KERNEL);
>>> + /* In case IB device supports disassociate ucontext, there is no hard
>>> + * dependency between uverbs device and its low level device.
>>> + */
>>> + module_dependent = !(dev->flags & UVERBS_FLAG_DISASSOCIATE);
>>> +
>>> + if (module_dependent) {
>>> + if (!try_module_get(dev->ib_dev->owner)) {
>>> + ret = -ENODEV;
>>> + goto err;
>>
>> Again? Why I do I keep pointing this same basic thing to Mellanox
>> people:
>>
>> If you hold a X then you hold the ref to X as well.
>>
>> So, if the core code is holding function pointers to module code, then
>> the core code holds a module ref. When the core code null's those
>> function pointers, then it can release the module ref.
>
> Seconded.
The module get/put mechanism was previously used here and wasn't
introduced by that patch.
In case the low level driver can be unloaded (e.g. rmmod mlx4_ib)
unconditionally to active uverbs clients we should prevent the module
dependency by ignoring the get/put mechanism. Hope that it clarifies the
usage here.
>
>> This might work today like this (I'm not entirely sure), but it makes
>> no sense at all.
>>
>> I'll look more closely in a few weeks once the rwsem change is done.
>
>
--
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:[~2015-05-27 20:47 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-13 11:10 [RESEND PATCH V3 for-next 0/3] HW Device hot-removal support Yishai Hadas
[not found] ` <1431515438-24042-1-git-send-email-yishaih-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2015-05-13 11:10 ` [PATCH V3 for-next 1/3] IB/uverbs: Enable device removal when there are active user space applications Yishai Hadas
[not found] ` <1431515438-24042-2-git-send-email-yishaih-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2015-05-25 16:54 ` Jason Gunthorpe
[not found] ` <20150525165449.GA4379-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2015-05-27 16:04 ` Doug Ledford
[not found] ` <1432742669.28905.228.camel-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2015-05-27 17:43 ` Jason Gunthorpe
[not found] ` <20150527174332.GC9909-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2015-05-27 21:36 ` Or Gerlitz
[not found] ` <CAJ3xEMiYbrr2mkXuywNcyYu1v0dqeM+6Lks-CL0U6fSnx=DQ+Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-05-28 0:51 ` Doug Ledford
2015-05-27 20:47 ` Yishai Hadas [this message]
[not found] ` <55662D63.3030806-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
2015-05-28 6:19 ` Jason Gunthorpe
[not found] ` <20150528061923.GA4054-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2015-05-29 10:30 ` Shachar Raindel
[not found] ` <AM3PR05MB0935AB183EA8764FD83C36A0DCC90-LOZWmgKjnYgQouBfZGh8ttqRiQSDpxhJvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
2015-05-29 17:06 ` Jason Gunthorpe
2015-05-13 11:10 ` [PATCH V3 for-next 2/3] IB/mlx4_ib: Disassociate support Yishai Hadas
2015-05-13 11:10 ` [PATCH V3 for-next 3/3] IB/ucma: HW Device hot-removal support Yishai Hadas
2015-05-13 20:55 ` [RESEND PATCH V3 for-next 0/3] " Hefty, Sean
[not found] ` <1828884A29C6694DAF28B7E6B8A82373A8FDA36D-P5GAC/sN6hkd3b2yrw5b5LfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2015-05-14 11:28 ` Yishai Hadas
[not found] ` <555486CA.8080409-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
2015-05-14 16:50 ` Hefty, Sean
[not found] ` <1828884A29C6694DAF28B7E6B8A82373A8FDA931-P5GAC/sN6hkd3b2yrw5b5LfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2015-05-17 10:33 ` Yishai Hadas
[not found] ` <55586E5D.1030801-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
2015-05-18 18:21 ` Hefty, Sean
[not found] ` <1828884A29C6694DAF28B7E6B8A82373A8FDC9A4-P5GAC/sN6hkd3b2yrw5b5LfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2015-05-19 16:17 ` Liran Liss
[not found] ` <HE1PR05MB1418D0CE0E031DA35E3DDEBAB1C30-eBadYZ65MZ87O8BmmlM1zNqRiQSDpxhJvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
2015-05-25 14:01 ` Yishai Hadas
2015-05-27 16:12 ` Doug Ledford
[not found] ` <1432743174.28905.231.camel-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2015-05-28 15:58 ` Liran Liss
2015-05-28 16:08 ` Liran Liss
-- strict thread matches above, loose matches on Subject: below --
2014-12-17 16:08 [PATCH " Yishai Hadas
[not found] ` <1418832493-31273-1-git-send-email-yishaih-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2014-12-17 16:08 ` [PATCH V3 for-next 1/3] IB/uverbs: Enable device removal when there are active user space applications 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=55662D63.3030806@dev.mellanox.co.il \
--to=yishaih-ldsdmyg8hgv8yrgs2mwiifqbs+8scbdb@public.gmane.org \
--cc=dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
--cc=jackm-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org \
--cc=jackm-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org \
--cc=jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org \
--cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=raindel-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