lkml.org 
[lkml]   [2014]   [Apr]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] drm: make variable named "refcount" atomic, like most refcounts in the kernel.
On Sat, Apr 26, 2014 at 06:06:15PM +0200, Lionel Debroux wrote:
> Based on PaX.

Lovely - cargo-cult at its finest. "Most refcounts are atomic, must be
good medicine. Shaman has spoken".

> - int refcount;
> + atomic_t refcount;

... therefore, all places that modify that sucker will have to be visible
in the patch. And those are

> - ++item->refcount;
> + atomic_inc(&item->refcount);
> ref->object = item->object;
> mutex_unlock(&item->mutex);

and

> mutex_lock(&item->mutex);
> - BUG_ON(item->refcount == 0);
> + BUG_ON(atomic_read(&item->refcount) == 0);
> BUG_ON(ref->object != item->object);
> - if (--item->refcount == 0) {
> + if (atomic_dec_and_test(&item->refcount)) {
> ref->release(ref);
> item->object = NULL;

Mind explaining how could we manage to reach either without item->mutex
being held, serializing the modifications?

NAK, in case it's not obvious from the above...


\
 
 \ /
  Last update: 2014-04-26 19:01    [W:2.806 / U:0.288 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site