mesa: Add a helper function for determining the restart index.