It is necessary and sufficient that the second derivative is a function of bounded variation.
Or, in terms of distributions, the second derivative must be a measure (a difference of two non-negative
measures).