Re: [RFC PATCH 02/11] refcount: Implement inc/decrement-and-return functions

From: David Howells
Date: Fri Sep 01 2017 - 18:52:08 EST


Peter Zijlstra <peterz@xxxxxxxxxxxxx> wrote:

> if (obj) {
> /* use obj */
> refcount_dec(&obj->refs); /* should never hit 0 */
> }

You've missed a bit: We need to tell the gc to run when we reduce the refcount
to 1:

if (obj) {
...
if (refcount_dec_return(&obj->refs) == 1)
schedule_gc();
}

David