From: Maarten Lankhorst <maarten.lankhorst-GeWIH/nMZzLQT0dZR+AlfA@public.gmane.org>
To: Emil Velikov <emil.l.velikov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: ML nouveau <nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org>
Subject: Re: [PATCH 2/2] nouveau: Do not add most bo's to the global bo list.
Date: Wed, 25 Feb 2015 15:59:32 +0100 [thread overview]
Message-ID: <54EDE354.6030700@ubuntu.com> (raw)
In-Reply-To: <CACvgo53DRfa9JkweCRVB9va7oD5RoKVM9KFkXk99rQwO=vxi0g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
Op 25-02-15 om 15:11 schreef Emil Velikov:
> On 24 February 2015 at 09:01, Maarten Lankhorst
> <maarten.lankhorst@ubuntu.com> wrote:
>> Only add wrapped bo's and bo's that have been exported through flink or dma-buf.
>> This avoids a lock in the common case, and decreases traversal needed for importing
>> a dma-buf or flink.
>>
>> Signed-off-by: Maarten Lankhorst <maarten.lankhorst@ubuntu.com>
>> ---
>> nouveau/nouveau.c | 47 +++++++++++++++++++++++------------------------
>> 1 file changed, 23 insertions(+), 24 deletions(-)
>>
>> diff --git a/nouveau/nouveau.c b/nouveau/nouveau.c
>> index 1c723b9..d411523 100644
>> --- a/nouveau/nouveau.c
>> +++ b/nouveau/nouveau.c
>> @@ -349,8 +349,8 @@ nouveau_bo_del(struct nouveau_bo *bo)
>> struct nouveau_bo_priv *nvbo = nouveau_bo(bo);
>> struct drm_gem_close req = { bo->handle };
>>
>> - pthread_mutex_lock(&nvdev->lock);
>> - if (nvbo->name) {
>> + if (nvbo->head.next) {
>> + pthread_mutex_lock(&nvdev->lock);
>> if (atomic_read(&nvbo->refcnt) == 0) {
>> DRMLISTDEL(&nvbo->head);
>> /*
>> @@ -365,8 +365,6 @@ nouveau_bo_del(struct nouveau_bo *bo)
>> }
>> pthread_mutex_unlock(&nvdev->lock);
>> } else {
>> - DRMLISTDEL(&nvbo->head);
>> - pthread_mutex_unlock(&nvdev->lock);
>> drmIoctl(bo->device->fd, DRM_IOCTL_GEM_CLOSE, &req);
>> }
>> if (bo->map)
>> @@ -379,7 +377,6 @@ nouveau_bo_new(struct nouveau_device *dev, uint32_t flags, uint32_t align,
>> uint64_t size, union nouveau_bo_config *config,
>> struct nouveau_bo **pbo)
>> {
>> - struct nouveau_device_priv *nvdev = nouveau_device(dev);
>> struct nouveau_bo_priv *nvbo = calloc(1, sizeof(*nvbo));
>> struct nouveau_bo *bo = &nvbo->base;
>> int ret;
>> @@ -397,10 +394,6 @@ nouveau_bo_new(struct nouveau_device *dev, uint32_t flags, uint32_t align,
>> return ret;
>> }
>>
>> - pthread_mutex_lock(&nvdev->lock);
>> - DRMLISTADD(&nvbo->head, &nvdev->bo_list);
>> - pthread_mutex_unlock(&nvdev->lock);
>> -
>> *pbo = bo;
>> return 0;
>> }
>> @@ -457,6 +450,18 @@ nouveau_bo_wrap_locked(struct nouveau_device *dev, uint32_t handle,
>> return -ENOMEM;
>> }
>>
>> +static void
>> +nouveau_bo_make_global(struct nouveau_bo_priv *nvbo)
>> +{
>> + if (!nvbo->head.next) {
>> + struct nouveau_device_priv *nvdev = nouveau_device(nvbo->base.device);
>> + pthread_mutex_lock(&nvdev->lock);
>> + if (!nvbo->head.next)
> Something looks a bit strange here. The list is modified under a lock,
> so there should be no need for the second if above. Did you have
> something else in mind ?
The unlocked if check could be removed, but checking is cheaper than locking. :P
I guess the bo_make_global call is not particularly sensitive, so removing's fine with me.
~Maarten
_______________________________________________
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau
next prev parent reply other threads:[~2015-02-25 14:59 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-24 9:01 [PATCH 1/2] nouveau: make nouveau importing global buffers completely thread-safe, with tests Maarten Lankhorst
[not found] ` <1424768511-25156-1-git-send-email-maarten.lankhorst-GeWIH/nMZzLQT0dZR+AlfA@public.gmane.org>
2015-02-24 9:01 ` [PATCH 2/2] nouveau: Do not add most bo's to the global bo list Maarten Lankhorst
[not found] ` <1424768511-25156-2-git-send-email-maarten.lankhorst-GeWIH/nMZzLQT0dZR+AlfA@public.gmane.org>
2015-02-25 14:11 ` Emil Velikov
[not found] ` <CACvgo53DRfa9JkweCRVB9va7oD5RoKVM9KFkXk99rQwO=vxi0g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-02-25 14:59 ` Maarten Lankhorst [this message]
[not found] ` <54EDE354.6030700-GeWIH/nMZzLQT0dZR+AlfA@public.gmane.org>
2015-02-25 15:04 ` Patrick Baggett
[not found] ` <CAEk2Stmr7k+Tq_JH+9iuo8iz+NouhJ8tG3RaX9vJA-FHzewBAw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-02-25 15:07 ` Maarten Lankhorst
[not found] ` <54EDE51B.1070000-GeWIH/nMZzLQT0dZR+AlfA@public.gmane.org>
2015-02-25 15:28 ` Patrick Baggett
[not found] ` <CAEk2Stk1x86MM0x6FLFutgBGC+0ksG+VKFLoEH=z+zLGKvYyRg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-02-25 15:43 ` Maarten Lankhorst
[not found] ` <54EDED9B.3000303-GeWIH/nMZzLQT0dZR+AlfA@public.gmane.org>
2015-02-25 16:14 ` Emil Velikov
2015-02-25 16:28 ` Patrick Baggett
[not found] ` <CAEk2StmOwhMecfkNsVj7j3PbmnazNQ7CAPMs-VNvv-QtrSEmCQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-02-25 16:35 ` Ilia Mirkin
[not found] ` <CAKb7UvhinRCVezUKwVpJR2V4hwTs+8mgQZBvEtHE0MVp7PYc9A-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-02-25 16:59 ` Patrick Baggett
[not found] ` <CAEk2St=hxYL7QTnC=7=EnAyD8Bw4KJER4Dd+9pYKYckM5m+4Jg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-02-25 17:05 ` Ilia Mirkin
[not found] ` <CAKb7UvgnB-Tvy1EFF-8ERfOFUBGCzBbPjL0Yv1TZAWRm1Be0wg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-02-25 17:13 ` Maarten Lankhorst
[not found] ` <54EE02A8.2040004-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>
2015-02-25 17:26 ` Patrick Baggett
[not found] ` <CAEk2St=0LWc-E-O-2DOHWvDtQYJiRe=+7yz7UaGy2KWNTCsbmA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-02-25 17:55 ` Maarten Lankhorst
[not found] ` <54EE0C88.4010509-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>
2015-02-25 19:04 ` Patrick Baggett
2015-02-25 14:14 ` [PATCH 1/2] nouveau: make nouveau importing global buffers completely thread-safe, with tests Emil Velikov
[not found] ` <CACvgo529aHY=pbBUqjvw4ecGE_Y3VD0M=p47MdZkuPdM-UYT6g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-02-25 21:59 ` Maarten Lankhorst
[not found] ` <54EE45D6.9030604-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>
2015-02-26 9:52 ` Emil Velikov
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=54EDE354.6030700@ubuntu.com \
--to=maarten.lankhorst-gewih/nmzzlqt0dzr+alfa@public.gmane.org \
--cc=emil.l.velikov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@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.