diff options
author | Michael Neuling <mikey@neuling.org> | 2007-11-19 23:18:40 -0500 |
---|---|---|
committer | Paul Mackerras <paulus@samba.org> | 2007-11-20 00:10:28 -0500 |
commit | 2b46b5673ca67d23302c2afac045def988a3cade (patch) | |
tree | 02b291c7d8fe862e2ac76b22a4fc361e4620f0a3 /arch/powerpc | |
parent | c443acab2eebf12dce7e78fe29e76786f55ad1be (diff) |
[POWERPC] Fix possible division by zero in scaled time accounting
If we get no user time and no system time allocated since the last
account_system_vtime, the system to user time ratio estimate can end
up dividing by zero.
This was causing a problem noticed by Balbir Singh.
Signed-off-by: Michael Neuling <mikey@neuling.org>
Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'arch/powerpc')
-rw-r--r-- | arch/powerpc/kernel/time.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/arch/powerpc/kernel/time.c b/arch/powerpc/kernel/time.c index c0d77723ba11..a925a8eae121 100644 --- a/arch/powerpc/kernel/time.c +++ b/arch/powerpc/kernel/time.c | |||
@@ -241,8 +241,9 @@ void account_system_vtime(struct task_struct *tsk) | |||
241 | /* deltascaled includes both user and system time. | 241 | /* deltascaled includes both user and system time. |
242 | * Hence scale it based on the purr ratio to estimate | 242 | * Hence scale it based on the purr ratio to estimate |
243 | * the system time */ | 243 | * the system time */ |
244 | deltascaled = deltascaled * get_paca()->system_time / | 244 | if (get_paca()->user_time) |
245 | (get_paca()->system_time + get_paca()->user_time); | 245 | deltascaled = deltascaled * get_paca()->system_time / |
246 | (get_paca()->system_time + get_paca()->user_time); | ||
246 | delta += get_paca()->system_time; | 247 | delta += get_paca()->system_time; |
247 | get_paca()->system_time = 0; | 248 | get_paca()->system_time = 0; |
248 | } | 249 | } |