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]
Date:	Tue, 8 Aug 2006 10:53:40 +1000
From:	"Darren Jenkins" <darrenrjenkins@...il.com>
To:	"Pavel Machek" <pavel@...e.cz>
Cc:	torvalds@...l.org, "Zed 0xff" <zed.0xff@...il.com>,
	kernel-janitors@...l.org, linux-kernel@...r.kernel.org
Subject: Re: [KJ] [patch] fix common mistake in polling loops

G'day

On 8/8/06, Pavel Machek <pavel@...e.cz> wrote:
> Hi!
>
> > >> Well, whoever wrote thi has some serious problems (in attitude
> > >> department). *Any* loop you design may take half a minute under
> > >> streange circumstances.
> >
> > 6.
> > common mistake in polling loops [from Linus]:
>
> Yes, Linus was wrong here. Or more precisely, he's right original code
> is broken, but his suggested "fix" is worse than the original.
>
>         unsigned long timeout = jiffies + HZ/2;
>         for (;;) {
>                 if (ready())
>                         return 0;
> [IMAGINE HALF A SECOND DELAY HERE]
>                 if (time_after(timeout, jiffies))
>                         break;
>                 msleep(10);
>         }
>
> Oops.
>
> > >Actually it may be broken, depending on use. In some cases this loop
> > >may want to poll the hardware 50 times, 10msec appart... and your loop
> > >can poll it only once in extreme conditions.
> > >
> > >Actually your loop is totally broken, and may poll only once (without
> > >any delay) and then directly timeout :-P -- that will break _any_
> > >user.
> >
> > The Idea is that we are checking some event in external hardware that
> > we know will complete in a given time (This time is not dependant on
> > system activity but is fixed). After that time if the event has not
> > happened we know something has borked.
>
> But you have to make sure YOU CHECK READY AFTER THE TIMEOUT. Linus'
> code does not do that.
>                                                                 Pavel


Sorry I did not realise that was your problem with the code.
Would it help if we just explicitly added a

if (ready())
        return 0;

after the loop, in the example code? so people wont miss adding
something like that in?

Darren J.
-
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