From: Todd Mokros <tmokros@neo.rr.com>
To: Andrew Morton <akpm@digeo.com>
Cc: cobra@compuserve.com, linux-kernel@vger.kernel.org,
george anzinger <george@mvista.com>
Subject: [PATCH] Re: Runaway cron task on 2.5.63/4 bk?
Date: 09 Mar 2003 11:28:30 -0500 [thread overview]
Message-ID: <1047227310.1958.20.camel@localhost> (raw)
In-Reply-To: <20030309001706.75467db1.akpm@digeo.com>
On Sun, 2003-03-09 at 03:17, Andrew Morton wrote:
> Andrew Morton <akpm@digeo.com> wrote:
> >
> > errr, OK. This returns -EINVAL:
> >
> > #include <time.h>
> >
> > main()
> > {
> > struct timespec req;
> > struct timespec rem;
> > int ret;
> >
> > req.tv_sec = 5000000;
> > req.tv_nsec = 0;
> >
> > ret = nanosleep(&req, &rem);
> > if (ret)
> > perror("nanosleep");
> > }
> >
>
> OK, I give up.
>
> /*
> * This is a considered response, not exactly in
> * line with the standard (in fact it is silent on
> * possible overflows). We assume such a large
> * value is ALMOST always a programming error and
> * try not to compound it by setting a really dumb
> * value.
> */
> return -EINVAL;
>
> George, RH7.3 and RH8.0 cron daemons are triggering this (trying to sleep
> for 4,500,000 seconds) and it causes them to go into a busy loop.
>
> I think we need to just sleep for as long as we can and return an
> appropriate partial result.
Cron really isn't at fault, I saw sleep(52) return 4500000, which it
just passed into another sleep call.
The problem is a bug in do_clock_nanosleep. If it gets interrupted by a
signal, when it calculates the amount of time left, it doesn't check if
jiffies has advanced past the expire time, and can pass a negative value
to jiffies_to_timespec, which results in values around 4,500,000
((unsigned int)-1)/HZ, which ends up as sleep's return value. The
following trivial patch appears to have fixed the problem on my system.
Hopefully this isn't wrapped.
--- 2.5-merge/kernel/posix-timers.c Sun Mar 9 08:49:11 2003
+++ 2.5-snapshot/kernel/posix-timers.c Sun Mar 9 08:49:11 2003
@@ -1282,6 +1282,9 @@
if (abs)
return -ERESTARTNOHAND;
+ if (time_after_eq(jiffies_f, new_timer.expires))
+ return 0;
+
jiffies_to_timespec(new_timer.expires - jiffies_f, tsave);
while (tsave->tv_nsec < 0) {
--
Todd Mokros <tmokros@neo.rr.com>
next prev parent reply other threads:[~2003-03-09 16:18 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-03-09 7:30 Runaway cron task on 2.5.63/4 bk? Kevin Brosius
2003-03-09 8:08 ` Andrew Morton
2003-03-09 8:17 ` Andrew Morton
2003-03-09 16:28 ` Todd Mokros [this message]
2003-03-10 19:42 ` george anzinger
2003-03-10 19:49 ` Linus Torvalds
2003-03-10 22:21 ` george anzinger
2003-03-10 22:29 ` Andrew Morton
2003-03-10 22:46 ` george anzinger
-- strict thread matches above, loose matches on Subject: below --
2003-03-10 23:33 Linus Torvalds
2003-03-12 3:45 ` [PATCH] " george anzinger
2003-03-12 4:57 ` Andrew Morton
2003-03-12 10:09 ` george anzinger
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=1047227310.1958.20.camel@localhost \
--to=tmokros@neo.rr.com \
--cc=akpm@digeo.com \
--cc=cobra@compuserve.com \
--cc=george@mvista.com \
--cc=linux-kernel@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.