  Motivated by recent developments in the fields of large deviations for
interacting particle system and mean field control, we establish a comparison
principle for the Hamilton--Jacobi equation corresponding to linearly
controlled gradient flows of an energy function $\cE$ defined on a metric space
$(E,d)$. Our analysis is based on a systematic use of the regularizing
properties of gradient flows in evolutional variational inequality (EVI)
formulation, that we exploit for constructing rigorous upper and lower bounds
for the formal Hamiltonian at hand and, in combination with the use of the
Tataru's distance, for establishing the key estimates needed to bound the
difference of the Hamiltonians in the proof of the comparison principle. Our
abstract results apply to a large class of examples only partially covered by
the existing theory, including gradient flows on Hilbert spaces and the
Wasserstein space equipped with a displacement convex energy functional $\cE$
satisfying McCann's condition.
