runtime: fix preemption of root marking jobs
runtime: fix preemption of root marking jobs

The current logic in gcDrain conflates non-blocking with preemptible
draining for root jobs. As a result, if you do a non-blocking (but
*not* preemptible) drain, like dedicated workers do, the root job
drain will stop if preempted and fall through to heap marking jobs,
which won't stop until it fails to get a heap marking job.

This commit fixes the condition on root marking jobs so they only stop
when preempted if the drain is preemptible.

Coincidentally, this also fixes a nil pointer dereference if we call
gcDrain with gcDrainNoBlock and without a user G, since it tries to
get the preempt flag from the nil user G. This combination never
happens right now, but will in the future.

Change-Id: Ia910ec20a9b46237f7926969144a33b1b4a7b2f9
Reviewed-on: https://go-review.googlesource.com/32291
Run-TryBot: Austin Clements <7ea35d812706d9213868749011af1ed4fa2f6aa0@google.com>
TryBot-Result: Gobot Gobot <66cb808b70d30c07676d5e946fee83fd561249e5@golang.org>
Reviewed-by: Russ Cox <5ad239cb8a44f659eaaee0aa1ea5b94947abe557@golang.org>

polyverse-security/go,akutz/go,codestation/go,josharian/go,polyverse-security/go,codestation/go,goodlang/good,nawawi/go,codestation/go,derekmarcotte/go,akutz/go,nawawi/go,codestation/go,suncycheng/go,suncycheng/go,cloudflare/go,codestation/go,josharian/go,polyverse-security/go,linux-on-ibm-z/go,ImJasonH/go,golang/go,vsekhar/elastic-go,derekmarcotte/go,cloudflare/go,polyverse-security/go,derekmarcotte/go,vsekhar/elastic-go,goodlang/good,derekmarcotte/go,Cofyc/go,josharian/go,CAFxX/go,josharian/go,polyverse-security/go,suncycheng/go,nawawi/go,golang/go,ImJasonH/go,goodlang/good,nawawi/go,derekmarcotte/go,ImJasonH/go,golang/go,suncycheng/go,cloudflare/go,cloudflare/go,derekmarcotte/go,akutz/go,CAFxX/go,linux-on-ibm-z/go,akutz/go,Cofyc/go,Cofyc/go,suncycheng/go,ImJasonH/go,Cofyc/go,vsekhar/elastic-go,CAFxX/go,vsekhar/elastic-go,goodlang/good,linux-on-ibm-z/go,vsekhar/elastic-go,suncycheng/go,Cofyc/go,golang/go,goodlang/good,goodlang/good,golang/go,nawawi/go,suncycheng/go,polyverse-security/go,josharian/go,cloudflare/go,golang/go,vsekhar/elastic-go,goodlang/good,akutz/go,Cofyc/go,CAFxX/go,linux-on-ibm-z/go,nawawi/go,josharian/go,codestation/go,derekmarcotte/go,goodlang/good,CAFxX/go,golang/go,cloudflare/go,ImJasonH/go,linux-on-ibm-z/go,vsekhar/elastic-go,codestation/go,cloudflare/go,akutz/go,polyverse-security/go,derekmarcotte/go,Cofyc/go,golang/go,Cofyc/go,christopher-henderson/Go,akutz/go,ImJasonH/go,suncycheng/go,codestation/go,vsekhar/elastic-go,linux-on-ibm-z/go,linux-on-ibm-z/go,josharian/go,linux-on-ibm-z/go,CAFxX/go,ImJasonH/go,CAFxX/go,josharian/go,polyverse-security/go,CAFxX/go,nawawi/go,cloudflare/go,nawawi/go,akutz/go,ImJasonH/go