Rebase flexible-workgroup-scheduling.patch on r1586 and rewrite borrowlocality policy