Upstream backport. Signed-off-by: Rosen Penev <rosenp@gmail.com> (cherry picked from commit 1717048598)
1717048598