From: Petr Tesarik <ptesarik@suse.cz>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Frank Mayhar <fmayhar@google.com>,
Christoph Lameter <cl@linux-foundation.org>,
Doug Chapman <doug.chapman@hp.com>,
mingo@elte.hu, roland@redhat.com, adobriyan@gmail.com,
akpm@linux-foundation.org,
linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: regression introduced by - timers: fix itimer/many thread hang
Date: Mon, 24 Nov 2008 13:32:48 +0100 [thread overview]
Message-ID: <1227529968.4487.45.camel@nathan.suse.cz> (raw)
In-Reply-To: <1227519208.7685.21951.camel@twins>
Peter Zijlstra píše v Po 24. 11. 2008 v 10:33 +0100:
> On Mon, 2008-11-24 at 09:46 +0100, Petr Tesarik wrote:
> > Peter Zijlstra píše v Ne 23. 11. 2008 v 15:24 +0100:
> > >[...]
> > > The current (per-cpu) code is utterly broken on large machines too, I've
> > > asked SGI to run some tests on real numa machines (something multi-brick
> > > altix) and even moderately small machines with 256 cpus in them grind to
> > > a halt (or make progress at a snails pace) when the itimer stuff is
> > > enabled.
> > >
> > > Furthermore, I really dislike the per-process-per-cpu memory cost, it
> > > bloats applications and makes the new per-cpu alloc work rather more
> > > difficult than it already is.
> > >
> > > I basically think the whole process wide itimer stuff is broken by
> > > design, there is no way to make it work on reasonably large machines,
> > > the whole problem space just doesn't scale. You simply cannot maintain a
> > > global count without bouncing cachelines like mad, so you might as well
> > > accept it and do the process wide counter and bounce only a single line,
> > > instead of bouncing a line per-cpu.
> >
> > Very true. Unfortunately per-process itimers are prescribed by the
> > Single Unix Specification, so we have to cope with them in some way,
> > while not permitting a non-privileged process a DoS attack. This is
> > going to be hard, and we'll probably have to twist the specification a
> > bit to still conform to its wording. :((
>
> Feel like reading the actual spec and trying to come up with a creative
> interpretation? :-)
Yes, I've just spent a few hours doing that... And I feel very
depressed, as expected.
> > I really don't think it's a good idea to set a per-process ITIMER_PROF
> > to one timer tick on a large machine, but the kernel does allow any
> > process to do it, and then it can even cause hard freeze on some
> > hardware. This is _not_ acceptable.
> >
> > What is worse, we can't just limit the granularity of itimers, because
> > threads can come into being _after_ the itimer was set.
>
> Currently it has jiffy granularity, right? And jiffies are different
> depending on some compile time constant (HZ), so can't we, for the sake
> of per-process itimers, pretend to have a 1 minute jiffie?
>
> That should be as compliant as we are now, and utterly useless for
> everybody, thereby discouraging its use, hmm? :-)
I've got a copy of IEEE Std 10003.1-2004 here, and it suggests that this
should be generally possible. In particular, the description for
itimer_set says:
Implementations may place limitations on the granularity of timer values. For
each interval timer, if the requested timer value requires a finer granularity
than the implementation supports, the actual timer value shall be rounded up
to the next supported value.
However, it seems to be vaguely linked to CLOCK_PROCESS_CPUTIME_ID,
which is defined as:
The identifier of the CPU-time clock associated with the process making a
clock ( ) or timer*( ) function call.
POSIX does not specify whether this clock is identical to the one used
for setitimer et al., or not, but it seems logical that it should. Then,
the kernel should probably return the coarse granularity in
clock_getres(), too.
I tried to find out how this is currently implemented in Linux, and it's
broken. How else. :-/
1. clock_getres() always returns a resolution of 1ns
This is actually good news, because it means that nobody really cares
whether the actual granularity is greater, so I guess we can safely
return any bogus number in clock_getres().
What about using an actual granularity of NR_CPUS*HZ, which should be
safe for any (at least remotely) sane usage?
2. clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &ts) returns -EINVAL
Should not happen. Looking further into it, I think this line in
cpu_clock_sample_group():
switch (which_clock) {
should look like a similar line in cpu_clock_sample(), ie:
switch (CPUCLOCK_WHICH(which_clock)) {
Shall I send a patch?
Petr Tesarik
next prev parent reply other threads:[~2008-11-24 12:33 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1224694989.8431.23.camel@oberon>
[not found] ` <1225132746.14792.13.camel@bobble.smo.corp.google.com>
[not found] ` <1225219114.24204.37.camel@oberon>
2008-11-06 1:58 ` Frank Mayhar
2008-11-06 11:03 ` Peter Zijlstra
2008-11-06 15:03 ` Christoph Lameter
2008-11-06 15:08 ` Peter Zijlstra
2008-11-06 16:08 ` Christoph Lameter
2008-11-06 23:52 ` Frank Mayhar
2008-11-07 8:35 ` Ingo Molnar
2008-11-07 10:29 ` Peter Zijlstra
2008-11-07 18:10 ` Frank Mayhar
2008-11-07 20:26 ` Peter Zijlstra
2008-11-10 14:38 ` Christoph Lameter
2008-11-10 14:42 ` Peter Zijlstra
2008-11-10 15:41 ` Christoph Lameter
2008-11-10 18:00 ` Frank Mayhar
2008-11-14 2:42 ` Roland McGrath
2008-11-14 16:41 ` Oleg Nesterov
2008-11-17 14:36 ` Oleg Nesterov
2008-11-17 18:16 ` Roland McGrath
2008-11-17 22:18 ` Oleg Nesterov
2008-11-17 21:49 ` Roland McGrath
2008-11-11 0:20 ` Ingo Oeser
2008-11-11 13:58 ` Christoph Lameter
2008-11-21 18:42 ` Petr Tesarik
2008-11-21 19:26 ` Frank Mayhar
2008-11-23 14:24 ` Peter Zijlstra
2008-11-24 8:46 ` Petr Tesarik
2008-11-24 9:33 ` Peter Zijlstra
2008-11-24 12:32 ` Petr Tesarik [this message]
2008-11-24 12:59 ` Peter Zijlstra
2008-11-24 16:06 ` Peter Zijlstra
2008-11-06 16:31 ` [PATCH] revert: " Peter Zijlstra
2008-11-06 21:44 ` Ingo Molnar
2008-11-06 21:53 ` Christoph Lameter
2008-11-07 10:19 ` Peter Zijlstra
2008-11-13 16:00 ` Doug Chapman
2008-11-13 16:08 ` Ingo Molnar
2008-11-14 14:10 ` Doug Chapman
[not found] <20081105191211.c0316b94.akpm@linux-foundation.org>
2008-11-06 12:59 ` regression introduced by - " Oleg Nesterov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1227529968.4487.45.camel@nathan.suse.cz \
--to=ptesarik@suse.cz \
--cc=adobriyan@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=cl@linux-foundation.org \
--cc=doug.chapman@hp.com \
--cc=fmayhar@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=peterz@infradead.org \
--cc=roland@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome