runtime: use atomic.Cas to change timerRemoved to timerWaiting
runtime: use atomic.Cas to change timerRemoved to timerWaiting

If multiple goroutines call time.(*Timer).Reset then the timer will go
from timerWaiting to timerDeleted to timerModifying to timerModifiedLater.
The timer can be on a different P, meaning that simultaneously cleantimers
could change it from timerDeleted to timerRemoving to timerRemoved.
If Reset sees timerRemoved, it was doing an atomic.Store of timerWaiting,
meaning that it did not necessarily see the other values set in the timer,
so the timer could appear to be in an inconsistent state. Use atomic.Cas
to avoid that possibility.

Updates #6239
Updates #27707
Fixes #35272

Change-Id: I1d59a13dc4f2ff4af110fc6e032c8c9d59cfc270
Reviewed-on: https://go-review.googlesource.com/c/go/+/204717
Run-TryBot: Ian Lance Taylor <87e9c6d529889242b7e184afb632328636553ab4@golang.org>
TryBot-Result: Gobot Gobot <66cb808b70d30c07676d5e946fee83fd561249e5@golang.org>
Reviewed-by: Michael Knyszek <4473450dc5c88f06e1fb787f303d7805ec2aee65@google.com>

golang/go,CAFxX/go,akutz/go,cloudflare/go,cloudflare/go,akutz/go,golang/go,nawawi/go,golang/go,cloudflare/go,nawawi/go,CAFxX/go,akutz/go,akutz/go,golang/go,nawawi/go,akutz/go,akutz/go,CAFxX/go,golang/go,golang/go,akutz/go,golang/go,cloudflare/go,CAFxX/go,cloudflare/go,akutz/go,CAFxX/go,cloudflare/go,nawawi/go,cloudflare/go,CAFxX/go,nawawi/go,cloudflare/go,golang/go,nawawi/go,CAFxX/go,CAFxX/go,nawawi/go,nawawi/go