Re: [PATCH 1/5] pid: Implement task references.
From: Kyle Moffett
Date: Mon Jan 30 2006 - 00:38:37 EST
On Jan 30, 2006, at 00:19, Eric Dumazet wrote:
- if (atomic_dec_and_test(&kref->refcount)) {
+ /*
+ * if current count is one, we are the last user and can release
object
+ * right now, avoiding an atomic operation on 'refcount'
+ */
+ if ((atomic_read(&kref->refcount) == 1) ||
Uhh, I think you got this test reversed. Didn't you mean != 1?
Otherwise you only do the dec_and_test when the refcount is one,
which means that you leak everything kref-ed.
+ (atomic_dec_and_test(&kref->refcount))) {
release(kref);
return 1;
}
Cheers,
Kyle Moffett
--
There are two ways of constructing a software design. One way is to
make it so simple that there are obviously no deficiencies. And the
other way is to make it so complicated that there are no obvious
deficiencies. The first method is far more difficult.
-- C.A.R. Hoare
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/