Hi Jan,
Technically, the patch I posted is not a really good one. It only works for the measurement that lasts not too long (long enough for more than 1 overflow occurs), and it is hard to tell whether the numbers are right because it won't generate crazy numbers which could be helpful to detect overflow. It works for me because my workloads are typically around 10 minutes.
I think one way to do this perfectly is to read the msr file every certain period of time, which is not long enough for an overflow, and accumulates the numbers to get the total energy consumption.
Thanks!
Yunqi