Discussion:
[UM] Long loop in __getnsdayoftime() after resume from ram
Thomas Meyer
2014-10-19 12:39:16 UTC
Permalink
Hello,

in UML kernel I get a long cpu using loop in __getnstimeofday()
(kernel/time/timekeeping.c:315) in the call of timespec_add_ns(),
when I left the host kernel suspended to ram for a few hours and resume
again.
this is because it seems like the tk->xtime_sec wasn't updated yet, but
the nsecs were. nsecs can be as high as 8111000111000111000l

the function timespec_add_ns() (include/linux/time.h:266) will call
__iter_div_u64_rem() which has an optimized loop for the case
that the dividend is not much bigger as the divisior.
but this isn't the case for resume from ram on the host kernel.

any ideas how to fix this? is it possible to intercept the resume from
ram and update the timekeeper->xtime_sec somehow?
or can the um arch somehow overwrite timespec_add_ns() to always use
div_u64_rem() instead?

with kind regards

PS: repost on these lists, because nobody did respond to my original
email.
Richard Weinberger
2014-10-20 08:27:50 UTC
Permalink
Post by Thomas Meyer
Hello,
in UML kernel I get a long cpu using loop in __getnstimeofday()
(kernel/time/timekeeping.c:315) in the call of timespec_add_ns(),
when I left the host kernel suspended to ram for a few hours and resume
again.
this is because it seems like the tk->xtime_sec wasn't updated yet, but
the nsecs were. nsecs can be as high as 8111000111000111000l
the function timespec_add_ns() (include/linux/time.h:266) will call
__iter_div_u64_rem() which has an optimized loop for the case
that the dividend is not much bigger as the divisior.
but this isn't the case for resume from ram on the host kernel.
any ideas how to fix this? is it possible to intercept the resume from
ram and update the timekeeper->xtime_sec somehow?
or can the um arch somehow overwrite timespec_add_ns() to always use
div_u64_rem() instead?
Hmm, does this always happen?
At least on my notebook it did not happen. I've started an UML yesterday
suspended it and after more than 12h it worked fine today.

BTW: Do you see the issue also then freezing UML using the freezer cgroup?
Would be easier to debug. :)
--
Thanks,
//richard
Thomas Meyer
2014-10-20 09:51:33 UTC
Permalink
Post by Richard Weinberger
Post by Thomas Meyer
Hello,
in UML kernel I get a long cpu using loop in __getnstimeofday()
(kernel/time/timekeeping.c:315) in the call of timespec_add_ns(),
when I left the host kernel suspended to ram for a few hours and resume
again.
this is because it seems like the tk->xtime_sec wasn't updated yet, but
the nsecs were. nsecs can be as high as 8111000111000111000l
the function timespec_add_ns() (include/linux/time.h:266) will call
__iter_div_u64_rem() which has an optimized loop for the case
that the dividend is not much bigger as the divisior.
but this isn't the case for resume from ram on the host kernel.
any ideas how to fix this? is it possible to intercept the resume from
ram and update the timekeeper->xtime_sec somehow?
or can the um arch somehow overwrite timespec_add_ns() to always use
div_u64_rem() instead?
Hmm, does this always happen?
Yes, my single core system seems to trigger this every time after resume from ram.
Post by Richard Weinberger
At least on my notebook it did not happen. I've started an UML yesterday
suspended it and after more than 12h it worked fine today.
BTW: Do you see the issue also then freezing UML using the freezer cgroup?
I'm not sure what do you mean by this. Do I need to enable some special configs for this in the host or uml kernel?
Post by Richard Weinberger
Would be easier to debug. :)
Richard Weinberger
2014-10-20 09:56:15 UTC
Permalink
Post by Thomas Meyer
Post by Richard Weinberger
Hmm, does this always happen?
Yes, my single core system seems to trigger this every time after resume from ram.
What is your host kernel?
Post by Thomas Meyer
Post by Richard Weinberger
At least on my notebook it did not happen. I've started an UML yesterday
suspended it and after more than 12h it worked fine today.
BTW: Do you see the issue also then freezing UML using the freezer cgroup?
I'm not sure what do you mean by this. Do I need to enable some special configs for this in the host or uml kernel?
Create on the host side a new freezer cgroup, put UML into it and freeze/thaw it.
i.e. mkdir /sys/fs/cgroup/freezer/uml ; echo <pid of a shell> > /sys/fs/cgroup/freezer/uml/tasks.
In the said shell run UML and then freeze it using echo FROZEN > /sys/fs/cgroup/freezer/uml/freezer.state.
Later thaw it: echo THAWED > /sys/fs/cgroup/freezer/uml/freezer.state

Thanks,
//richard

Loading...