Le mardi 18 octobre 2011 à 15:00 +0100, Ben Hutchings a écrit :
AIUI, the reason for limits on delays is not that it's bad practice to
spin for so long, but that the delay calculations may overflow or
otherwise become inaccurate.
OK, I can understand that, then a more appropriate patch would be :
diff --git a/net/core/pktgen.c b/net/core/pktgen.c
index 796044a..28bbf5b 100644
--- a/net/core/pktgen.c
+++ b/net/core/pktgen.c
@@ -2145,9 +2145,12 @@ static void spin(struct pktgen_dev *pkt_dev, ktime_t spin_until)
}
start_time = ktime_now();
- if (remaining < 100000)
- ndelay(remaining); /* really small just spin */
- else {
+ if (remaining < 100000) {
+ if (remaining >= 10000)
+ udelay(remaining/1000);
+ else
+ ndelay(remaining);
+ } else {
/* see do_nanosleep */
hrtimer_init_sleeper(&t, current);
do {