sync: improve linearity test robustness
sync: improve linearity test robustness

This change improves the robustness of the locklinear test in the
following ways:

* It removes allocations from the timing, which may be very variable if
  we're unlucky.
* It ensures that goroutines are properly cleaned up before the test
  function returns, reducing the chance that they bleed into repeat
  attempts. It also stops timing before this cleanup.

Fixes #32986.

Change-Id: I3a8096e6922f23d899ad602e2845bdfc639ed742
Reviewed-on: https://go-review.googlesource.com/c/go/+/409894
Reviewed-by: Michael Pratt <e7f1edc6d5aa9f6c8c377425db8f1a5816cbbb88@google.com>

nawawi/go,golang/go,nawawi/go,golang/go,golang/go,golang/go,nawawi/go,nawawi/go,golang/go,golang/go,nawawi/go,nawawi/go,nawawi/go,nawawi/go,golang/go,golang/go