* Re: [PATCH] proc: Add RLIMIT_RTTIME to /proc/<pid>/limits
2008-02-28 15:21 ` Peter Zijlstra
@ 2008-02-28 15:44 ` Michael Kerrisk
2008-02-28 15:50 ` Peter Zijlstra
2008-02-29 12:32 ` Neil Horman
2008-04-11 8:56 ` Michael Kerrisk
2 siblings, 1 reply; 25+ messages in thread
From: Michael Kerrisk @ 2008-02-28 15:44 UTC (permalink / raw)
To: Peter Zijlstra
Cc: Michael Kerrisk, Eugene Teo, linux-kernel, Neil Horman,
Ingo Molnar
Peter,
Thanks for the text.
On Thu, Feb 28, 2008 at 4:21 PM, Peter Zijlstra <a.p.zijlstra@chello.nl> wrote:
>
> On Thu, 2008-02-28 at 16:12 +0100, Michael Kerrisk wrote:
> > Peter,
> >
> > Could you please provide some text describing RLIMIT_RTTIMEfor the
> > getrlimit.2 man page.
>
> The rlimit sets a timeout in [us] for SCHED_RR and SCHED_FIFO tasks.
> This time is measured between sleeps, so a schedule in RR or a
> preemption in either is not a sleep - the task needs to be dequeued and
> enqueued for the timer to reset.
Just to clarify: sleep here means a call to some blocking syscall
(e.g., nanosleep(), read(), select(), etc.), right? Is there anything
else that falls under the category of "sleep"? What about a call to
sched_yield() where the process explicitly lets go of the CPU?
Also, is this limit per-thread or per-process? I assume the latter --
but can you confirm please.
Cheers,
Michael
> Upon reaching the cur limit we start giving SIGXCPU every second, upon
> reaching the hard limit we give SIGKILL - matching RLIMIT_CPU.
>
> Time is measured in tick granularity (for now).
>
>
>
> > Cheers,
> >
> > Michael
> >
> > On Fri, Feb 8, 2008 at 4:10 PM, Peter Zijlstra <a.p.zijlstra@chello.nl> wrote:
> > >
> > > On Fri, 2008-02-08 at 22:59 +0800, Eugene Teo wrote:
> > > > RLIMIT_RTTIME was introduced to allow the user to set a runtime timeout on
> > > > real-time tasks: http://lkml.org/lkml/2007/12/18/218. This patch updates
> > > > /proc/<pid>/limits with the new rlimit.
> > >
> > > Ah, didn't know about that file, thanks!
> > >
> > > > Signed-off-by: Eugene Teo <eugeneteo@kernel.sg>
> > >
> > > Acked-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
> > >
> > >
> > > > ---
> > > > fs/proc/base.c | 1 +
> > > > 1 files changed, 1 insertions(+), 0 deletions(-)
> > > >
> > > > diff --git a/fs/proc/base.c b/fs/proc/base.c
> > > > index c59852b..dcf7be8 100644
> > > > --- a/fs/proc/base.c
> > > > +++ b/fs/proc/base.c
> > > > @@ -412,6 +412,7 @@ static const struct limit_names lnames[RLIM_NLIMITS] = {
> > > > [RLIMIT_MSGQUEUE] = {"Max msgqueue size", "bytes"},
> > > > [RLIMIT_NICE] = {"Max nice priority", NULL},
> > > > [RLIMIT_RTPRIO] = {"Max realtime priority", NULL},
> > > > + [RLIMIT_RTTIME] = {"Max realtime timeout", "us"},
> > > > };
> > > >
> > > > /* Display limits for a process */
> > >
> > > --
> > > To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> > > the body of a message to majordomo@vger.kernel.org
> > > More majordomo info at http://vger.kernel.org/majordomo-info.html
> > > Please read the FAQ at http://www.tux.org/lkml/
> > >
> >
> >
> >
>
>
--
Michael Kerrisk
Maintainer of the Linux man-pages project
http://www.kernel.org/doc/man-pages/
Want to report a man-pages bug? Look here:
http://www.kernel.org/doc/man-pages/reporting_bugs.html
^ permalink raw reply [flat|nested] 25+ messages in thread* Re: [PATCH] proc: Add RLIMIT_RTTIME to /proc/<pid>/limits
2008-02-28 15:44 ` Michael Kerrisk
@ 2008-02-28 15:50 ` Peter Zijlstra
2008-04-11 7:38 ` Michael Kerrisk
0 siblings, 1 reply; 25+ messages in thread
From: Peter Zijlstra @ 2008-02-28 15:50 UTC (permalink / raw)
To: Michael Kerrisk
Cc: Michael Kerrisk, Eugene Teo, linux-kernel, Neil Horman,
Ingo Molnar
On Thu, 2008-02-28 at 16:44 +0100, Michael Kerrisk wrote:
> Peter,
>
> Thanks for the text.
>
> On Thu, Feb 28, 2008 at 4:21 PM, Peter Zijlstra <a.p.zijlstra@chello.nl> wrote:
> >
> > On Thu, 2008-02-28 at 16:12 +0100, Michael Kerrisk wrote:
> > > Peter,
> > >
> > > Could you please provide some text describing RLIMIT_RTTIMEfor the
> > > getrlimit.2 man page.
> >
> > The rlimit sets a timeout in [us] for SCHED_RR and SCHED_FIFO tasks.
> > This time is measured between sleeps, so a schedule in RR or a
> > preemption in either is not a sleep - the task needs to be dequeued and
> > enqueued for the timer to reset.
>
> Just to clarify: sleep here means a call to some blocking syscall
> (e.g., nanosleep(), read(), select(), etc.), right? Is there anything
> else that falls under the category of "sleep"? What about a call to
> sched_yield() where the process explicitly lets go of the CPU?
Yes, and yes, others would be blocking on futexes and the like.
> Also, is this limit per-thread or per-process? I assume the latter --
> but can you confirm please.
Per process. Requests have been made to allow for per thread, but
rlimits are not.
Its really not meant as a fine-grained deadline notification mechanism,
we have posix timers for that, but as a watchdog to ensure we behave
'well'.
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH] proc: Add RLIMIT_RTTIME to /proc/<pid>/limits
2008-02-28 15:50 ` Peter Zijlstra
@ 2008-04-11 7:38 ` Michael Kerrisk
2008-04-11 7:45 ` Peter Zijlstra
0 siblings, 1 reply; 25+ messages in thread
From: Michael Kerrisk @ 2008-04-11 7:38 UTC (permalink / raw)
To: Peter Zijlstra
Cc: Michael Kerrisk, Eugene Teo, linux-kernel, Neil Horman,
Ingo Molnar
On Thu, Feb 28, 2008 at 5:50 PM, Peter Zijlstra <a.p.zijlstra@chello.nl> wrote:
>
> On Thu, 2008-02-28 at 16:44 +0100, Michael Kerrisk wrote:
> > Peter,
> >
> > Thanks for the text.
> >
> > On Thu, Feb 28, 2008 at 4:21 PM, Peter Zijlstra <a.p.zijlstra@chello.nl> wrote:
> > >
> > > On Thu, 2008-02-28 at 16:12 +0100, Michael Kerrisk wrote:
> > > > Peter,
> > > >
> > > > Could you please provide some text describing RLIMIT_RTTIMEfor the
> > > > getrlimit.2 man page.
> > >
> > > The rlimit sets a timeout in [us] for SCHED_RR and SCHED_FIFO tasks.
> > > This time is measured between sleeps, so a schedule in RR or a
> > > preemption in either is not a sleep - the task needs to be dequeued and
> > > enqueued for the timer to reset.
> >
> > Just to clarify: sleep here means a call to some blocking syscall
> > (e.g., nanosleep(), read(), select(), etc.), right? Is there anything
> > else that falls under the category of "sleep"? What about a call to
> > sched_yield() where the process explicitly lets go of the CPU?
>
> Yes, and yes, others would be blocking on futexes and the like.
Peter,
I've been testing this patch. Above you seemed to be saying that
doing a sched_yield() would be equivalent to a sleep, causing the rt
counter to be reset to zero. Howver, the results I'm seeing suggest
that a sched_yield() does not cause the counter to be reset to zero
(i.e., despite calling sched_yield() at frequent intervals, the
process still encounters the RLIM_RTTIME soft limit and gets SIGXCPU).
Can you comment?
Cheers,
Michael
--
Michael Kerrisk
Maintainer of the Linux man-pages project
http://www.kernel.org/doc/man-pages/
Want to report a man-pages bug? Look here:
http://www.kernel.org/doc/man-pages/reporting_bugs.html
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH] proc: Add RLIMIT_RTTIME to /proc/<pid>/limits
2008-04-11 7:38 ` Michael Kerrisk
@ 2008-04-11 7:45 ` Peter Zijlstra
2008-04-11 8:01 ` Michael Kerrisk
0 siblings, 1 reply; 25+ messages in thread
From: Peter Zijlstra @ 2008-04-11 7:45 UTC (permalink / raw)
To: Michael Kerrisk
Cc: Michael Kerrisk, Eugene Teo, linux-kernel, Neil Horman,
Ingo Molnar
On Fri, 2008-04-11 at 09:38 +0200, Michael Kerrisk wrote:
> On Thu, Feb 28, 2008 at 5:50 PM, Peter Zijlstra <a.p.zijlstra@chello.nl> wrote:
> >
> > On Thu, 2008-02-28 at 16:44 +0100, Michael Kerrisk wrote:
> > > Peter,
> > >
> > > Thanks for the text.
> > >
> > > On Thu, Feb 28, 2008 at 4:21 PM, Peter Zijlstra <a.p.zijlstra@chello.nl> wrote:
> > > >
> > > > On Thu, 2008-02-28 at 16:12 +0100, Michael Kerrisk wrote:
> > > > > Peter,
> > > > >
> > > > > Could you please provide some text describing RLIMIT_RTTIMEfor the
> > > > > getrlimit.2 man page.
> > > >
> > > > The rlimit sets a timeout in [us] for SCHED_RR and SCHED_FIFO tasks.
> > > > This time is measured between sleeps, so a schedule in RR or a
> > > > preemption in either is not a sleep - the task needs to be dequeued and
> > > > enqueued for the timer to reset.
> > >
> > > Just to clarify: sleep here means a call to some blocking syscall
> > > (e.g., nanosleep(), read(), select(), etc.), right? Is there anything
> > > else that falls under the category of "sleep"? What about a call to
> > > sched_yield() where the process explicitly lets go of the CPU?
> >
> > Yes, and yes, others would be blocking on futexes and the like.
>
> Peter,
>
> I've been testing this patch. Above you seemed to be saying that
> doing a sched_yield() would be equivalent to a sleep, causing the rt
> counter to be reset to zero. Howver, the results I'm seeing suggest
> that a sched_yield() does not cause the counter to be reset to zero
> (i.e., despite calling sched_yield() at frequent intervals, the
> process still encounters the RLIM_RTTIME soft limit and gets SIGXCPU).
> Can you comment?
It appears you are right. I must have been staring at something else
than code when I said that :-(, yield() will indeed _not_ reset the
counter.
Now, I think it makes some sense to reset it, because we do try to play
nice by calling yield. OTOH we don't actually block and become
unrunnable - we'll still be contending for CPU time.
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH] proc: Add RLIMIT_RTTIME to /proc/<pid>/limits
2008-04-11 7:45 ` Peter Zijlstra
@ 2008-04-11 8:01 ` Michael Kerrisk
0 siblings, 0 replies; 25+ messages in thread
From: Michael Kerrisk @ 2008-04-11 8:01 UTC (permalink / raw)
To: Peter Zijlstra
Cc: Michael Kerrisk, Eugene Teo, linux-kernel, Neil Horman,
Ingo Molnar
On 4/11/08, Michael Kerrisk <mtk.manpages@googlemail.com> wrote:
> On Thu, Feb 28, 2008 at 5:50 PM, Peter Zijlstra <a.p.zijlstra@chello.nl> wrote:
> >
> > On Thu, 2008-02-28 at 16:44 +0100, Michael Kerrisk wrote:
[...]
> > I've been testing this patch. Above you seemed to be saying that
> > doing a sched_yield() would be equivalent to a sleep, causing the rt
> > counter to be reset to zero. Howver, the results I'm seeing suggest
> > that a sched_yield() does not cause the counter to be reset to zero
> > (i.e., despite calling sched_yield() at frequent intervals, the
> > process still encounters the RLIM_RTTIME soft limit and gets SIGXCPU).
> > Can you comment?
>
>
> It appears you are right. I must have been staring at something else
> than code when I said that :-(, yield() will indeed _not_ reset the
> counter.
>
> Now, I think it makes some sense to reset it, because we do try to play
> nice by calling yield. OTOH we don't actually block and become
> unrunnable - we'll still be contending for CPU time.
On the one hand, it seems reasonable to reset the counter. The POSIX
definition of sched_yield() says that it "shall force the running
thread to relinquish the processor until it again becomes the head of
its thread list".
On the other hand, what if this is the only runnable real-time
process? Then sched_yield() is effectively a no-op, and a runaway
process could lock up the system (which I gather is what RLIMIT_RTTIME
was primarily designed to prevent).
I don't really have a strong leaning either way about what should be
done, other than that we should probably make a specific choice, and
document it in the setrlimit(2) man page.
Cheers,
Michael
--
I'll likely only see replies if they are CCed to mtk.manpages at gmail dot com
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH] proc: Add RLIMIT_RTTIME to /proc/<pid>/limits
2008-02-28 15:21 ` Peter Zijlstra
2008-02-28 15:44 ` Michael Kerrisk
@ 2008-02-29 12:32 ` Neil Horman
2008-04-11 8:56 ` Michael Kerrisk
2 siblings, 0 replies; 25+ messages in thread
From: Neil Horman @ 2008-02-29 12:32 UTC (permalink / raw)
To: Peter Zijlstra; +Cc: Michael Kerrisk, Eugene Teo, linux-kernel, Ingo Molnar
On Thu, Feb 28, 2008 at 04:21:40PM +0100, Peter Zijlstra wrote:
>
> On Thu, 2008-02-28 at 16:12 +0100, Michael Kerrisk wrote:
> > Peter,
> >
> > Could you please provide some text describing RLIMIT_RTTIMEfor the
> > getrlimit.2 man page.
>
> The rlimit sets a timeout in [us] for SCHED_RR and SCHED_FIFO tasks.
> This time is measured between sleeps, so a schedule in RR or a
> preemption in either is not a sleep - the task needs to be dequeued and
> enqueued for the timer to reset.
>
> Upon reaching the cur limit we start giving SIGXCPU every second, upon
> reaching the hard limit we give SIGKILL - matching RLIMIT_CPU.
>
> Time is measured in tick granularity (for now).
>
> > Cheers,
> >
> > Michael
> >
> > On Fri, Feb 8, 2008 at 4:10 PM, Peter Zijlstra <a.p.zijlstra@chello.nl> wrote:
> > >
> > > On Fri, 2008-02-08 at 22:59 +0800, Eugene Teo wrote:
> > > > RLIMIT_RTTIME was introduced to allow the user to set a runtime timeout on
> > > > real-time tasks: http://lkml.org/lkml/2007/12/18/218. This patch updates
> > > > /proc/<pid>/limits with the new rlimit.
> > >
> > > Ah, didn't know about that file, thanks!
> > >
> > > > Signed-off-by: Eugene Teo <eugeneteo@kernel.sg>
> > >
> > > Acked-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Acked-by: Neil Horman <nhorman@tuxdriver.com>
--
/****************************************************
* Neil Horman <nhorman@tuxdriver.com>
* Software Engineer, Red Hat
****************************************************/
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH] proc: Add RLIMIT_RTTIME to /proc/<pid>/limits
2008-02-28 15:21 ` Peter Zijlstra
2008-02-28 15:44 ` Michael Kerrisk
2008-02-29 12:32 ` Neil Horman
@ 2008-04-11 8:56 ` Michael Kerrisk
2008-04-11 9:01 ` Peter Zijlstra
2 siblings, 1 reply; 25+ messages in thread
From: Michael Kerrisk @ 2008-04-11 8:56 UTC (permalink / raw)
To: Peter Zijlstra
Cc: Michael Kerrisk, Eugene Teo, linux-kernel, Neil Horman,
Ingo Molnar
On Thu, Feb 28, 2008 at 5:21 PM, Peter Zijlstra <a.p.zijlstra@chello.nl> wrote:
>
> On Thu, 2008-02-28 at 16:12 +0100, Michael Kerrisk wrote:
> > Peter,
> >
> > Could you please provide some text describing RLIMIT_RTTIMEfor the
> > getrlimit.2 man page.
>
> The rlimit sets a timeout in [us] for SCHED_RR and SCHED_FIFO tasks.
> This time is measured between sleeps, so a schedule in RR or a
> preemption in either is not a sleep - the task needs to be dequeued and
> enqueued for the timer to reset.
>
> Upon reaching the cur limit we start giving SIGXCPU every second, upon
> reaching the hard limit we give SIGKILL - matching RLIMIT_CPU.
>
> Time is measured in tick granularity (for now).
So I have another question: why is the granularity of this rlimit
microseconds? On the one hand, specifying limits down at the
microsecond level seems (to my naive eye) unlikely to be useful. (But
perhaps I have missed a thread where this was explained.) On the
other hand, it means that on 32-bit the largest time limit we can set
is ~4000 seconds, and I wonder if there are scenarios where it might
be useful to have larger limits than that.
Why not, for example, have a granularity of milliseconds?
Cheers,
Michael
> > On Fri, Feb 8, 2008 at 4:10 PM, Peter Zijlstra <a.p.zijlstra@chello.nl> wrote:
> > >
> > > On Fri, 2008-02-08 at 22:59 +0800, Eugene Teo wrote:
> > > > RLIMIT_RTTIME was introduced to allow the user to set a runtime timeout on
> > > > real-time tasks: http://lkml.org/lkml/2007/12/18/218. This patch updates
> > > > /proc/<pid>/limits with the new rlimit.
> > >
> > > Ah, didn't know about that file, thanks!
> > >
> > > > Signed-off-by: Eugene Teo <eugeneteo@kernel.sg>
> > >
> > > Acked-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
> > >
> > >
> > > > ---
> > > > fs/proc/base.c | 1 +
> > > > 1 files changed, 1 insertions(+), 0 deletions(-)
> > > >
> > > > diff --git a/fs/proc/base.c b/fs/proc/base.c
> > > > index c59852b..dcf7be8 100644
> > > > --- a/fs/proc/base.c
> > > > +++ b/fs/proc/base.c
> > > > @@ -412,6 +412,7 @@ static const struct limit_names lnames[RLIM_NLIMITS] = {
> > > > [RLIMIT_MSGQUEUE] = {"Max msgqueue size", "bytes"},
> > > > [RLIMIT_NICE] = {"Max nice priority", NULL},
> > > > [RLIMIT_RTPRIO] = {"Max realtime priority", NULL},
> > > > + [RLIMIT_RTTIME] = {"Max realtime timeout", "us"},
> > > > };
> > > >
> > > > /* Display limits for a process */
> > >
> > > --
> > > To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> > > the body of a message to majordomo@vger.kernel.org
> > > More majordomo info at http://vger.kernel.org/majordomo-info.html
> > > Please read the FAQ at http://www.tux.org/lkml/
> > >
> >
> >
> >
>
>
--
Michael Kerrisk
Maintainer of the Linux man-pages project
http://www.kernel.org/doc/man-pages/
Want to report a man-pages bug? Look here:
http://www.kernel.org/doc/man-pages/reporting_bugs.html
^ permalink raw reply [flat|nested] 25+ messages in thread* Re: [PATCH] proc: Add RLIMIT_RTTIME to /proc/<pid>/limits
2008-04-11 8:56 ` Michael Kerrisk
@ 2008-04-11 9:01 ` Peter Zijlstra
2008-04-11 9:16 ` Michael Kerrisk
0 siblings, 1 reply; 25+ messages in thread
From: Peter Zijlstra @ 2008-04-11 9:01 UTC (permalink / raw)
To: Michael Kerrisk
Cc: Michael Kerrisk, Eugene Teo, linux-kernel, Neil Horman,
Ingo Molnar
On Fri, 2008-04-11 at 10:56 +0200, Michael Kerrisk wrote:
> On Thu, Feb 28, 2008 at 5:21 PM, Peter Zijlstra <a.p.zijlstra@chello.nl> wrote:
> >
> > On Thu, 2008-02-28 at 16:12 +0100, Michael Kerrisk wrote:
> > > Peter,
> > >
> > > Could you please provide some text describing RLIMIT_RTTIMEfor the
> > > getrlimit.2 man page.
> >
> > The rlimit sets a timeout in [us] for SCHED_RR and SCHED_FIFO tasks.
> > This time is measured between sleeps, so a schedule in RR or a
> > preemption in either is not a sleep - the task needs to be dequeued and
> > enqueued for the timer to reset.
> >
> > Upon reaching the cur limit we start giving SIGXCPU every second, upon
> > reaching the hard limit we give SIGKILL - matching RLIMIT_CPU.
> >
> > Time is measured in tick granularity (for now).
>
> So I have another question: why is the granularity of this rlimit
> microseconds? On the one hand, specifying limits down at the
> microsecond level seems (to my naive eye) unlikely to be useful. (But
> perhaps I have missed a thread where this was explained.) On the
> other hand, it means that on 32-bit the largest time limit we can set
> is ~4000 seconds, and I wonder if there are scenarios where it might
> be useful to have larger limits than that.
>
> Why not, for example, have a granularity of milliseconds?
The us scale seemed the best fit in that it allows sub-ms granularity
while still allowing for quite long periods too. I'd preferred ns scale
as that is what we use throughout the scheduler where possible - but
that seemed too restrictive at the high end.
No real hard arguments either way.
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH] proc: Add RLIMIT_RTTIME to /proc/<pid>/limits
2008-04-11 9:01 ` Peter Zijlstra
@ 2008-04-11 9:16 ` Michael Kerrisk
2008-04-11 9:21 ` Peter Zijlstra
0 siblings, 1 reply; 25+ messages in thread
From: Michael Kerrisk @ 2008-04-11 9:16 UTC (permalink / raw)
To: Peter Zijlstra
Cc: Michael Kerrisk, Eugene Teo, linux-kernel, Neil Horman,
Ingo Molnar
On Fri, Apr 11, 2008 at 11:01 AM, Peter Zijlstra <a.p.zijlstra@chello.nl> wrote:
> On Fri, 2008-04-11 at 10:56 +0200, Michael Kerrisk wrote:
> > On Thu, Feb 28, 2008 at 5:21 PM, Peter Zijlstra <a.p.zijlstra@chello.nl> wrote:
> > >
> > > On Thu, 2008-02-28 at 16:12 +0100, Michael Kerrisk wrote:
> > > > Peter,
> > > >
> > > > Could you please provide some text describing RLIMIT_RTTIMEfor the
> > > > getrlimit.2 man page.
> > >
> > > The rlimit sets a timeout in [us] for SCHED_RR and SCHED_FIFO tasks.
> > > This time is measured between sleeps, so a schedule in RR or a
> > > preemption in either is not a sleep - the task needs to be dequeued and
> > > enqueued for the timer to reset.
> > >
> > > Upon reaching the cur limit we start giving SIGXCPU every second, upon
> > > reaching the hard limit we give SIGKILL - matching RLIMIT_CPU.
> > >
> > > Time is measured in tick granularity (for now).
> >
> > So I have another question: why is the granularity of this rlimit
> > microseconds? On the one hand, specifying limits down at the
> > microsecond level seems (to my naive eye) unlikely to be useful. (But
> > perhaps I have missed a thread where this was explained.) On the
> > other hand, it means that on 32-bit the largest time limit we can set
> > is ~4000 seconds, and I wonder if there are scenarios where it might
> > be useful to have larger limits than that.
> >
> > Why not, for example, have a granularity of milliseconds?
>
> The us scale seemed the best fit in that it allows sub-ms granularity
> while still allowing for quite long periods too. I'd preferred ns scale
> as that is what we use throughout the scheduler where possible - but
> that seemed too restrictive at the high end.
>
> No real hard arguments either way.
I'm curious: what scenarios require sub-millisecond timeouts?
--
Michael Kerrisk
Maintainer of the Linux man-pages project
http://www.kernel.org/doc/man-pages/
Want to report a man-pages bug? Look here:
http://www.kernel.org/doc/man-pages/reporting_bugs.html
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH] proc: Add RLIMIT_RTTIME to /proc/<pid>/limits
2008-04-11 9:16 ` Michael Kerrisk
@ 2008-04-11 9:21 ` Peter Zijlstra
2008-04-11 9:27 ` Michael Kerrisk
0 siblings, 1 reply; 25+ messages in thread
From: Peter Zijlstra @ 2008-04-11 9:21 UTC (permalink / raw)
To: Michael Kerrisk
Cc: Michael Kerrisk, Eugene Teo, linux-kernel, Neil Horman,
Ingo Molnar
On Fri, 2008-04-11 at 11:16 +0200, Michael Kerrisk wrote:
> On Fri, Apr 11, 2008 at 11:01 AM, Peter Zijlstra <a.p.zijlstra@chello.nl> wrote:
> > On Fri, 2008-04-11 at 10:56 +0200, Michael Kerrisk wrote:
> > > On Thu, Feb 28, 2008 at 5:21 PM, Peter Zijlstra <a.p.zijlstra@chello.nl> wrote:
> > > >
> > > > On Thu, 2008-02-28 at 16:12 +0100, Michael Kerrisk wrote:
> > > > > Peter,
> > > > >
> > > > > Could you please provide some text describing RLIMIT_RTTIMEfor the
> > > > > getrlimit.2 man page.
> > > >
> > > > The rlimit sets a timeout in [us] for SCHED_RR and SCHED_FIFO tasks.
> > > > This time is measured between sleeps, so a schedule in RR or a
> > > > preemption in either is not a sleep - the task needs to be dequeued and
> > > > enqueued for the timer to reset.
> > > >
> > > > Upon reaching the cur limit we start giving SIGXCPU every second, upon
> > > > reaching the hard limit we give SIGKILL - matching RLIMIT_CPU.
> > > >
> > > > Time is measured in tick granularity (for now).
> > >
> > > So I have another question: why is the granularity of this rlimit
> > > microseconds? On the one hand, specifying limits down at the
> > > microsecond level seems (to my naive eye) unlikely to be useful. (But
> > > perhaps I have missed a thread where this was explained.) On the
> > > other hand, it means that on 32-bit the largest time limit we can set
> > > is ~4000 seconds, and I wonder if there are scenarios where it might
> > > be useful to have larger limits than that.
> > >
> > > Why not, for example, have a granularity of milliseconds?
> >
> > The us scale seemed the best fit in that it allows sub-ms granularity
> > while still allowing for quite long periods too. I'd preferred ns scale
> > as that is what we use throughout the scheduler where possible - but
> > that seemed too restrictive at the high end.
> >
> > No real hard arguments either way.
>
> I'm curious: what scenarios require sub-millisecond timeouts?
I'm not sure, nor will they actually work atm since its tick based. But
I'm not wanting to exclude too many things, and 4k second upper limit is
plenty large.
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH] proc: Add RLIMIT_RTTIME to /proc/<pid>/limits
2008-04-11 9:21 ` Peter Zijlstra
@ 2008-04-11 9:27 ` Michael Kerrisk
2008-04-11 9:32 ` Peter Zijlstra
0 siblings, 1 reply; 25+ messages in thread
From: Michael Kerrisk @ 2008-04-11 9:27 UTC (permalink / raw)
To: Peter Zijlstra
Cc: Michael Kerrisk, Eugene Teo, linux-kernel, Neil Horman,
Ingo Molnar
On Fri, Apr 11, 2008 at 11:21 AM, Peter Zijlstra <a.p.zijlstra@chello.nl> wrote:
>
> On Fri, 2008-04-11 at 11:16 +0200, Michael Kerrisk wrote:
> > On Fri, Apr 11, 2008 at 11:01 AM, Peter Zijlstra <a.p.zijlstra@chello.nl> wrote:
> > > On Fri, 2008-04-11 at 10:56 +0200, Michael Kerrisk wrote:
> > > > On Thu, Feb 28, 2008 at 5:21 PM, Peter Zijlstra <a.p.zijlstra@chello.nl> wrote:
> > > > >
> > > > > On Thu, 2008-02-28 at 16:12 +0100, Michael Kerrisk wrote:
> > > > > > Peter,
> > > > > >
> > > > > > Could you please provide some text describing RLIMIT_RTTIMEfor the
> > > > > > getrlimit.2 man page.
> > > > >
> > > > > The rlimit sets a timeout in [us] for SCHED_RR and SCHED_FIFO tasks.
> > > > > This time is measured between sleeps, so a schedule in RR or a
> > > > > preemption in either is not a sleep - the task needs to be dequeued and
> > > > > enqueued for the timer to reset.
> > > > >
> > > > > Upon reaching the cur limit we start giving SIGXCPU every second, upon
> > > > > reaching the hard limit we give SIGKILL - matching RLIMIT_CPU.
> > > > >
> > > > > Time is measured in tick granularity (for now).
> > > >
> > > > So I have another question: why is the granularity of this rlimit
> > > > microseconds? On the one hand, specifying limits down at the
> > > > microsecond level seems (to my naive eye) unlikely to be useful. (But
> > > > perhaps I have missed a thread where this was explained.) On the
> > > > other hand, it means that on 32-bit the largest time limit we can set
> > > > is ~4000 seconds, and I wonder if there are scenarios where it might
> > > > be useful to have larger limits than that.
> > > >
> > > > Why not, for example, have a granularity of milliseconds?
> > >
> > > The us scale seemed the best fit in that it allows sub-ms granularity
> > > while still allowing for quite long periods too. I'd preferred ns scale
> > > as that is what we use throughout the scheduler where possible - but
> > > that seemed too restrictive at the high end.
> > >
> > > No real hard arguments either way.
> >
> > I'm curious: what scenarios require sub-millisecond timeouts?
>
> I'm not sure, nor will they actually work atm since its tick based.
Just to make sure me and the man page are clear: by tick-based, you
mean the granularity is in jiffies, right?
> But
> I'm not wanting to exclude too many things, and 4k second upper limit is
> plenty large.
Okay.
And following on from my other conversation in this thread... What
should/will be the specified behavior w.r.t. resetting or not
resetting the timer on a sched_yield()?
Cheers,
Michael
--
Michael Kerrisk
Maintainer of the Linux man-pages project
http://www.kernel.org/doc/man-pages/
Want to report a man-pages bug? Look here:
http://www.kernel.org/doc/man-pages/reporting_bugs.html
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH] proc: Add RLIMIT_RTTIME to /proc/<pid>/limits
2008-04-11 9:27 ` Michael Kerrisk
@ 2008-04-11 9:32 ` Peter Zijlstra
2008-04-11 9:38 ` Michael Kerrisk
0 siblings, 1 reply; 25+ messages in thread
From: Peter Zijlstra @ 2008-04-11 9:32 UTC (permalink / raw)
To: Michael Kerrisk
Cc: Michael Kerrisk, Eugene Teo, linux-kernel, Neil Horman,
Ingo Molnar
On Fri, 2008-04-11 at 11:27 +0200, Michael Kerrisk wrote:
> On Fri, Apr 11, 2008 at 11:21 AM, Peter Zijlstra <a.p.zijlstra@chello.nl> wrote:
> >
> > On Fri, 2008-04-11 at 11:16 +0200, Michael Kerrisk wrote:
> > > On Fri, Apr 11, 2008 at 11:01 AM, Peter Zijlstra <a.p.zijlstra@chello.nl> wrote:
> > > > On Fri, 2008-04-11 at 10:56 +0200, Michael Kerrisk wrote:
> > > > > On Thu, Feb 28, 2008 at 5:21 PM, Peter Zijlstra <a.p.zijlstra@chello.nl> wrote:
> > > > > >
> > > > > > On Thu, 2008-02-28 at 16:12 +0100, Michael Kerrisk wrote:
> > > > > > > Peter,
> > > > > > >
> > > > > > > Could you please provide some text describing RLIMIT_RTTIMEfor the
> > > > > > > getrlimit.2 man page.
> > > > > >
> > > > > > The rlimit sets a timeout in [us] for SCHED_RR and SCHED_FIFO tasks.
> > > > > > This time is measured between sleeps, so a schedule in RR or a
> > > > > > preemption in either is not a sleep - the task needs to be dequeued and
> > > > > > enqueued for the timer to reset.
> > > > > >
> > > > > > Upon reaching the cur limit we start giving SIGXCPU every second, upon
> > > > > > reaching the hard limit we give SIGKILL - matching RLIMIT_CPU.
> > > > > >
> > > > > > Time is measured in tick granularity (for now).
> > > > >
> > > > > So I have another question: why is the granularity of this rlimit
> > > > > microseconds? On the one hand, specifying limits down at the
> > > > > microsecond level seems (to my naive eye) unlikely to be useful. (But
> > > > > perhaps I have missed a thread where this was explained.) On the
> > > > > other hand, it means that on 32-bit the largest time limit we can set
> > > > > is ~4000 seconds, and I wonder if there are scenarios where it might
> > > > > be useful to have larger limits than that.
> > > > >
> > > > > Why not, for example, have a granularity of milliseconds?
> > > >
> > > > The us scale seemed the best fit in that it allows sub-ms granularity
> > > > while still allowing for quite long periods too. I'd preferred ns scale
> > > > as that is what we use throughout the scheduler where possible - but
> > > > that seemed too restrictive at the high end.
> > > >
> > > > No real hard arguments either way.
> > >
> > > I'm curious: what scenarios require sub-millisecond timeouts?
> >
> > I'm not sure, nor will they actually work atm since its tick based.
>
> Just to make sure me and the man page are clear: by tick-based, you
> mean the granularity is in jiffies, right?
Yes, they are currently jiffy based - but I could do hrtimer if someone
shows need.
> > But
> > I'm not wanting to exclude too many things, and 4k second upper limit is
> > plenty large.
>
> Okay.
>
> And following on from my other conversation in this thread... What
> should/will be the specified behavior w.r.t. resetting or not
> resetting the timer on a sched_yield()?
I think I'll keep it as is; so sched_yield() will _not_ reset the
counter. The rationale is that the process didn't actually stop running
- it just got scheduled away.
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH] proc: Add RLIMIT_RTTIME to /proc/<pid>/limits
2008-04-11 9:32 ` Peter Zijlstra
@ 2008-04-11 9:38 ` Michael Kerrisk
[not found] ` <cfd18e0f0804110238l66fb60c8pa8ac934a2a43baa7-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
0 siblings, 1 reply; 25+ messages in thread
From: Michael Kerrisk @ 2008-04-11 9:38 UTC (permalink / raw)
To: Peter Zijlstra
Cc: Michael Kerrisk, Eugene Teo, linux-kernel, Neil Horman,
Ingo Molnar
On Fri, Apr 11, 2008 at 11:32 AM, Peter Zijlstra <a.p.zijlstra@chello.nl> wrote:
>
> On Fri, 2008-04-11 at 11:27 +0200, Michael Kerrisk wrote:
> > On Fri, Apr 11, 2008 at 11:21 AM, Peter Zijlstra <a.p.zijlstra@chello.nl> wrote:
> > >
> > > On Fri, 2008-04-11 at 11:16 +0200, Michael Kerrisk wrote:
> > > > On Fri, Apr 11, 2008 at 11:01 AM, Peter Zijlstra <a.p.zijlstra@chello.nl> wrote:
> > > > > On Fri, 2008-04-11 at 10:56 +0200, Michael Kerrisk wrote:
> > > > > > On Thu, Feb 28, 2008 at 5:21 PM, Peter Zijlstra <a.p.zijlstra@chello.nl> wrote:
> > > > > > >
> > > > > > > On Thu, 2008-02-28 at 16:12 +0100, Michael Kerrisk wrote:
> > > > > > > > Peter,
> > > > > > > >
> > > > > > > > Could you please provide some text describing RLIMIT_RTTIMEfor the
> > > > > > > > getrlimit.2 man page.
> > > > > > >
> > > > > > > The rlimit sets a timeout in [us] for SCHED_RR and SCHED_FIFO tasks.
> > > > > > > This time is measured between sleeps, so a schedule in RR or a
> > > > > > > preemption in either is not a sleep - the task needs to be dequeued and
> > > > > > > enqueued for the timer to reset.
> > > > > > >
> > > > > > > Upon reaching the cur limit we start giving SIGXCPU every second, upon
> > > > > > > reaching the hard limit we give SIGKILL - matching RLIMIT_CPU.
> > > > > > >
> > > > > > > Time is measured in tick granularity (for now).
> > > > > >
> > > > > > So I have another question: why is the granularity of this rlimit
> > > > > > microseconds? On the one hand, specifying limits down at the
> > > > > > microsecond level seems (to my naive eye) unlikely to be useful. (But
> > > > > > perhaps I have missed a thread where this was explained.) On the
> > > > > > other hand, it means that on 32-bit the largest time limit we can set
> > > > > > is ~4000 seconds, and I wonder if there are scenarios where it might
> > > > > > be useful to have larger limits than that.
> > > > > >
> > > > > > Why not, for example, have a granularity of milliseconds?
> > > > >
> > > > > The us scale seemed the best fit in that it allows sub-ms granularity
> > > > > while still allowing for quite long periods too. I'd preferred ns scale
> > > > > as that is what we use throughout the scheduler where possible - but
> > > > > that seemed too restrictive at the high end.
> > > > >
> > > > > No real hard arguments either way.
> > > >
> > > > I'm curious: what scenarios require sub-millisecond timeouts?
> > >
> > > I'm not sure, nor will they actually work atm since its tick based.
> >
> > Just to make sure me and the man page are clear: by tick-based, you
> > mean the granularity is in jiffies, right?
>
> Yes, they are currently jiffy based - but I could do hrtimer if someone
> shows need.
>
> > > But
> > > I'm not wanting to exclude too many things, and 4k second upper limit is
> > > plenty large.
> >
> > Okay.
> >
> > And following on from my other conversation in this thread... What
> > should/will be the specified behavior w.r.t. resetting or not
> > resetting the timer on a sched_yield()?
>
> I think I'll keep it as is; so sched_yield() will _not_ reset the
> counter. The rationale is that the process didn't actually stop running
> - it just got scheduled away.
Okay -- thanks. I will make that clear in the man page.
Cheers,
Michael
--
Michael Kerrisk
Maintainer of the Linux man-pages project
http://www.kernel.org/doc/man-pages/
Want to report a man-pages bug? Look here:
http://www.kernel.org/doc/man-pages/reporting_bugs.html
^ permalink raw reply [flat|nested] 25+ messages in thread