In an effort to understand some geometric rigidity theorems, I am curious about the following: let $(M,g)$ be a complete Riemannian manifold and suppose there is a nonconstant real-valued function on $M$ which has a period of 1 when restricted to any unit-speed geodesic of $M$. Does this place restrictions on $(M,g)$?

My feeling is that the vast majority of manifolds cannot support such a function. The round sphere clearly can.

edit: if I understand correctly- according to the article arxiv.org/abs/1511.07852 of Radeschi and Wilking (Invent. Math. 2017) given by Igor Belegradek in the comments, a theorem of Wadsley (J. Diff. Geom. 1975) shows that, for every Riemannian manifold all of whose geodesics are closed, every function on $M$ satisfies the above condition with some constant period; the theorem is that all lengths of closed geodesics must be multiples of a single number, when $\pi_1(M)$ is finite