On 4/11/06, Kylene Jo Hall <[email protected]> wrote:
> On Mon, 2006-04-10 at 15:03 -0700, Andrew Morton wrote:
> >
> > > + interruptible_sleep_on_timeout(&chip->vendor.int_queue,
> > > + HZ *
> > > + chip->vendor.timeout_a /
> > > + 1000);
> > >
> > > ...
> > >
> > > + interruptible_sleep_on_timeout(queue, HZ * timeout / 1000);
> >
> > Please don't use the sleep_on functions. They are racy unless (iirc) both
> > the waker and wakee are holding lock_kernel(). If the race hits, we miss a
> > wakeup.
> >
> > These should be converted to the not-racy wait_event_interruptible().
>
> Changed in this patch.
>
> Use wait_event_interruptible_timeout in place of
> interruptible_sleep_on_timeout due to its racy nature.
>
> Signed-off-by: Kylie Hall <[email protected]>
> ---
> drivers/char/tpm/tpm_tis.c | 15 +++++++++------
> 1 files changed, 9 insertions(+), 6 deletions(-)
>
> --- linux-2.6.17-rc1/drivers/char/tpm/tpm_tis.c 2006-04-11 12:18:35.573996500 -0500
> +++ linux-2.6.16-44/drivers/char/tpm/tpm_tis.c 2006-04-11 14:00:04.341229250 -0500
> @@ -95,10 +95,10 @@ static int request_locality(struct tpm_c
> chip->vendor.iobase + TPM_ACCESS(l));
>
> if (chip->vendor.irq) {
> - interruptible_sleep_on_timeout(&chip->vendor.int_queue,
> - HZ *
> - chip->vendor.timeout_a /
> - 1000);
> + wait_event_interruptible_timeout(chip->vendor.int_queue,
> + (check_locality(chip, l) >= 0),
> + HZ * chip->vendor.timeout_a /
> + 1000);
> if (check_locality(chip, l) >= 0)
> return l;
Rather than check the condition you slept on right away, couldn't you
just store the return value of wait_event_interruptible_timeout()? If
it's positive, the condition should be true, if it's negative, then
you got a signal, if it's 0, then you timed out. Same would go for the
other change.
Thanks,
Nish
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[Index of Archives]
[Kernel Newbies]
[Netfilter]
[Bugtraq]
[Photo]
[Stuff]
[Gimp]
[Yosemite News]
[MIPS Linux]
[ARM Linux]
[Linux Security]
[Linux RAID]
[Video 4 Linux]
[Linux for the blind]
[Linux Resources]