Re: [PATCH RFC] perf_counter: Don't swap contexts containinglocked mutex

From: Paul Mackerras
Date: Fri May 29 2009 - 04:25:40 EST

Peter Zijlstra writes:

> > - && ctx1->parent_gen == ctx2->parent_gen;
> > + && ctx1->parent_gen == ctx2->parent_gen
> > + && ctx1->parent_gen != ~0ull;
> > }
> There's a nasty surprise for people a few generations down the line. All
> of a sudden performance drops for a while for some unknown reason, and
> then its good again,.. how odd ;-)

If you can add a counter every microsecond (which I don't think any
current processor can do) it'll still be more than half a million
years before we get that far...

> But yeah, seems fine, given that the alternative is yet another
> variable.

Actually, having a 1-bit flag might be cleaner since we can then just
clear it, rather than having to put the old parent_gen back.

> <snip all the other WARN_ON_ONCEs>
> How about:
> #define ASSERT_CTX_STABLE(ctx) \
> WARN_ON_ONCE((ctx)->parent_gen != ~0ull || ctx->parent_ctx)
> which would deal with both a 'locked' context and uncloned one?

Yeah, all right.

> Could we maybe write this as:
> static struct perf_counter_ctx *pin_ctx(struct perf_counter *counter, u64 *old_gen)

Yep, good idea.

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at