NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: kern/45634: hardclock_ticks corner cases in vflushnext() et al



The following reply was made to PR kern/45634; it has been noted by GNATS.

From: Christian Biere <christianbiere%gmx.de@localhost>
To: gnats-bugs%NetBSD.org@localhost
Cc: 
Subject: Re: kern/45634: hardclock_ticks corner cases in vflushnext() et al
Date: Wed, 23 Nov 2011 21:28:10 +0100

 This is a multi-part message in MIME format.
 
 --Multipart=_Wed__23_Nov_2011_21_28_10_+0100_m.Y6y0xomZ4R3QzA
 Content-Type: text/plain; charset=US-ASCII
 Content-Transfer-Encoding: 7bit
 
 The following should fix a related issue in sys/kern/kern_ras.c in ras_sync().
 
 Assume "target" is (close to) INT_MAX, then "hardclock_ticks" might advance
 sufficiently during kpause() to wrap around and become negative. It will
 take a very long time before the loop terminates, if ever.
 
 --Multipart=_Wed__23_Nov_2011_21_28_10_+0100_m.Y6y0xomZ4R3QzA
 Content-Type: text/x-diff;
  name="kern_ras.c.diff"
 Content-Disposition: attachment;
  filename="kern_ras.c.diff"
 Content-Transfer-Encoding: 7bit
 
 --- kern_ras.c.orig    2011-11-23 21:04:04.174184339 +0100
 +++ kern_ras.c 2011-11-23 21:17:37.914184076 +0100
 @@ -82,11 +82,12 @@
                 * o ras_lookup() plus loads reordered in advance
                 *   will take no longer than 1/8s to complete.
                 */
 -              const int delta = hz >> 3;
 -              int target = hardclock_ticks + delta;
 +              const unsigned delta = hz >> 3;
 +              unsigned dt, t0 = hardclock_ticks;
                do {
                        kpause("ras", false, delta, NULL);
 -              } while (hardclock_ticks < target);
 +                      dt = hardclock_ticks - t0;
 +              } while (dt < delta);
  #endif
        }
  }
 
 --Multipart=_Wed__23_Nov_2011_21_28_10_+0100_m.Y6y0xomZ4R3QzA--
 


Home | Main Index | Thread Index | Old Index