This is the mail archive of the
mailing list for the GCC project.
Re: gcov: option to instrument whole basic block graph, no use of spanning tree optimization
- From: Andi Kleen <andi at firstfloor dot org>
- To: Holger Blasum <hbl at sysgo dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Mon, 08 Nov 2010 00:01:40 +0100
- Subject: Re: gcov: option to instrument whole basic block graph, no use of spanning tree optimization
- References: <20101107215423.GA3607@laptop-hbl.localdomain>
Holger Blasum <firstname.lastname@example.org> writes:
> Rationale: gcov is not robust in a threaded environment, the patch
> makes it more robust.
> In particular, in threaded environments on can observe two effects:
> (1) underreporting when coverage counters are overwritten by another
> instance of a thread after a thread switch.
> (2) generation of arbitrary (even negative) values by subtraction when
> reconstructing the whole tree from the used by the spanning tree
> optimization mechanism. (Recall that subtraction is messy numerically.)
> With the current gcov framework (I think) one cannot do anything
> really generic about (1).
A better fix would be to make all the gcov data per thread data.
This is supported on most modern OS in a straight forward way
with a storage class modifier. This would fix all the races and give
always accurate information.
Another advantage of this is that it would speed data collection
with multiple threads -- no frequent cache line bouncing on the
counters when multiple CPUs modify them in parallel.
The only change needed would be to sum it up explicitely on
thread destruction into a global copy that is accessed atomically.
email@example.com -- Speaking for myself only.