lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAFTL4hy9akOVvR=9erBx+4DzKS0x0D69vtVz0TO3op9+PH=euA@mail.gmail.com>
Date:	Wed, 23 Jan 2013 16:58:14 +0100
From:	Frederic Weisbecker <fweisbec@...il.com>
To:	Stanislaw Gruszka <sgruszka@...hat.com>
Cc:	Peter Zijlstra <peterz@...radead.org>,
	Ingo Molnar <mingo@...hat.com>, linux-kernel@...r.kernel.org,
	Oleg Nesterov <oleg@...hat.com>, akpm@...ux-foundation.org,
	Steven Rostedt <rostedt@...dmis.org>
Subject: Re: [PATCH v2 repost] sched: cputime: avoid multiplication overflow
 (in common cases)

2013/1/10 Stanislaw Gruszka <sgruszka@...hat.com>:
> On Wed, Jan 09, 2013 at 07:33:03PM +0100, Frederic Weisbecker wrote:
>> On Mon, Jan 07, 2013 at 12:31:45PM +0100, Stanislaw Gruszka wrote:
>> > We scale stime, utime values based on rtime (sum_exec_runtime converted
>> > to jiffies). During scaling we multiple rtime * utime, what seems to be
>> > fine, since both values are converted to u64, but is not.
>> >
>> > Let assume HZ is 1000 - 1ms tick. Process consist of 64 threads, run
>> > for 1 day, threads utilize 100% cpu on user space. Machine has 64 cpus.
>> >
>> > Process rtime = utime will be 64 * 24 * 60 * 60 * 1000 jiffies, what is
>> > 0x149970000. Multiplication rtime * utime result is 0x1a855771100000000,
>> > which can not be covered in 64 bits.
>> >
>> > Result of overflow is stall of utime values visible in user space
>> > (prev_utime in kernel), even if application still consume lot of CPU
>> > time.
>> >
>> > Probably good fix for the problem, will be using 128 bit variable and
>> > proper mul128 and div_u128_u64 primitives. While mul128 is on it's
>> > way to kernel, there is no 128 bit division yet. I'm not sure, if we
>> > want to add it to kernel. Perhaps we could also change the way how
>> > stime and utime are calculated, but I don't know how, so I come with
>> > the below solution for the problem.
>> >
>> > To avoid overflow patch change value we scale to min(stime, utime). This
>> > is more like workaround, but will work for processes, which perform
>> > mostly on user space or mostly on kernel space. Unfortunately processes,
>> > which perform on kernel and user space equally, and additionally utilize
>> > lot of CPU time, still will hit this overflow pretty quickly. However
>> > such processes seems to be uncommon.
>> >
>> > Signed-off-by: Stanislaw Gruszka <sgruszka@...hat.com>
>>
>> I can easily imagine that overflow to happen with user time on intensive
>> CPU bound loads, or may be guests.
>>
>> But can we easily reach the same for system time? Even on intensive I/O bound
>> loads we shouldn't spend that much time in the kernel. Most of it probably goes
>> to idle.
>>
>> What do you think?
>
> I think you are right :-)
>
>> If that assumption is right in most cases, the following patch should solve the
>> issue:
>
> I'm fine with this patch, it achives the same effect as my patch, but is simpler.

Cool! So I can add your acked-by, right? I'll send this patch to Ingo soon.

Thanks!
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ