<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Feb 25, 2015 at 8:59 AM, Maarten Lankhorst <span dir="ltr"><<a href="mailto:maarten.lankhorst@ubuntu.com" target="_blank">maarten.lankhorst@ubuntu.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Op 25-02-15 om 15:11 schreef Emil Velikov:<br>
> On 24 February 2015 at 09:01, Maarten Lankhorst<br>
> <<a href="mailto:maarten.lankhorst@ubuntu.com">maarten.lankhorst@ubuntu.com</a>> wrote:<br>
>> Only add wrapped bo's and bo's that have been exported through flink or dma-buf.<br>
>> This avoids a lock in the common case, and decreases traversal needed for importing<br>
>> a dma-buf or flink.<br>
>><br>
>> Signed-off-by: Maarten Lankhorst <<a href="mailto:maarten.lankhorst@ubuntu.com">maarten.lankhorst@ubuntu.com</a>><br>
>> ---<br>
>> nouveau/nouveau.c | 47 +++++++++++++++++++++++------------------------<br>
>> 1 file changed, 23 insertions(+), 24 deletions(-)<br>
>><br>
>> diff --git a/nouveau/nouveau.c b/nouveau/nouveau.c<br>
>> index 1c723b9..d411523 100644<br>
>> --- a/nouveau/nouveau.c<br>
>> +++ b/nouveau/nouveau.c<br>
>> @@ -349,8 +349,8 @@ nouveau_bo_del(struct nouveau_bo *bo)<br>
>> struct nouveau_bo_priv *nvbo = nouveau_bo(bo);<br>
>> struct drm_gem_close req = { bo->handle };<br>
>><br>
>> - pthread_mutex_lock(&nvdev->lock);<br>
>> - if (nvbo->name) {<br>
>> + if (nvbo->head.next) {<br>
>> + pthread_mutex_lock(&nvdev->lock);<br>
>> if (atomic_read(&nvbo->refcnt) == 0) {<br>
>> DRMLISTDEL(&nvbo->head);<br>
>> /*<br>
>> @@ -365,8 +365,6 @@ nouveau_bo_del(struct nouveau_bo *bo)<br>
>> }<br>
>> pthread_mutex_unlock(&nvdev->lock);<br>
>> } else {<br>
>> - DRMLISTDEL(&nvbo->head);<br>
>> - pthread_mutex_unlock(&nvdev->lock);<br>
>> drmIoctl(bo->device->fd, DRM_IOCTL_GEM_CLOSE, &req);<br>
>> }<br>
>> if (bo->map)<br>
>> @@ -379,7 +377,6 @@ nouveau_bo_new(struct nouveau_device *dev, uint32_t flags, uint32_t align,<br>
>> uint64_t size, union nouveau_bo_config *config,<br>
>> struct nouveau_bo **pbo)<br>
>> {<br>
>> - struct nouveau_device_priv *nvdev = nouveau_device(dev);<br>
>> struct nouveau_bo_priv *nvbo = calloc(1, sizeof(*nvbo));<br>
>> struct nouveau_bo *bo = &nvbo->base;<br>
>> int ret;<br>
>> @@ -397,10 +394,6 @@ nouveau_bo_new(struct nouveau_device *dev, uint32_t flags, uint32_t align,<br>
>> return ret;<br>
>> }<br>
>><br>
>> - pthread_mutex_lock(&nvdev->lock);<br>
>> - DRMLISTADD(&nvbo->head, &nvdev->bo_list);<br>
>> - pthread_mutex_unlock(&nvdev->lock);<br>
>> -<br>
>> *pbo = bo;<br>
>> return 0;<br>
>> }<br>
>> @@ -457,6 +450,18 @@ nouveau_bo_wrap_locked(struct nouveau_device *dev, uint32_t handle,<br>
>> return -ENOMEM;<br>
>> }<br>
>><br>
>> +static void<br>
>> +nouveau_bo_make_global(struct nouveau_bo_priv *nvbo)<br>
>> +{<br>
>> + if (!nvbo->head.next) {<br>
>> + struct nouveau_device_priv *nvdev = nouveau_device(nvbo->base.device);<br>
>> + pthread_mutex_lock(&nvdev->lock);<br>
>> + if (!nvbo->head.next)<br></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
I guess the bo_make_global call is not particularly sensitive, so removing's fine with me.<br></blockquote><div>I would be worried about the duplicated check. It seems like a "smart" compiler could cache the value of "nvbo->head.next" (unless marked as volatile), rendering the second if() useless. If the field is marked volatile, then of course, this does not apply.<br><br></div><div>-Patrick<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
~Maarten<br>
_______________________________________________<br>
Nouveau mailing list<br>
<a href="mailto:Nouveau@lists.freedesktop.org">Nouveau@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/nouveau" target="_blank">http://lists.freedesktop.org/mailman/listinfo/nouveau</a><br>
</blockquote></div><br></div></div>