Skip to contentSkip to conversation

I made a patch and would like feedback/testers (drivers/cdrom/aztcd.c)

DISCUSSION Bodo Eggert 6 participants 9 messages Nov 20, 2005 – Nov 21, 2005 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

Review

Quoted 2 lines · Daniel Marjamäki
(quoted diff) +1 -1
-     aztTimeOutCount = 0;
+     aztTimeOut = jiffies + 2;

Different timeout based on HZ seems wrong.

Signature · 2 lines
Ich danke GMX dafür, die Verwendung meiner Adressen mittels per SPF
verbreiteten Lügen zu sabotieren.
#2 lore raw
Quoted 6 lines · Bodo Eggert

Review

Quoted 2 lines · Daniel Marjamäki
(quoted diff) +1 -1
-     aztTimeOutCount = 0;
+     aztTimeOut = jiffies + 2;

Different timeout based on HZ seems wrong.

True; I'm trying to think of a good way to emulate 8000000 iterations of loop, though. Really, this is not terrible to use 2 jiffies of offset, as we try to sleep 1 jiffy each time. As long as we don't get a signal *right* away, we'll sleep probably for 2 loops. Not sure, though, may be useful to see what happens in practice and then debug further for the right value.

May also want to use time_after_eq() not time_after().

Thanks,
Nish

#3 lore raw
In reply to Bodo Eggert
Quoted 8 lines · Bodo Eggert

Review

Quoted 2 lines · Daniel Marjamäki
(quoted diff) +1 -1
-     aztTimeOutCount = 0;
+     aztTimeOut = jiffies + 2;

Different timeout based on HZ seems wrong.

Yes, but..

If I'd say "HZ/100", then all systems that uses my driver must have HZ>=200.

The way I do it:
All systems will give me a delay for at least a few ms. I get the shortest timeout possible on each computer.

#4 lore raw
Quoted 7 lines · Daniel Marjamäki
Quoted 5 lines · Bodo Eggert

Review

Quoted 2 lines · Daniel Marjamäki
(quoted diff) +1 -1
-     aztTimeOutCount = 0;
+     aztTimeOut = jiffies + 2;

Different timeout based on HZ seems wrong.

Quoted 8 lines

Yes, but..

If I'd say "HZ/100", then all systems that uses my driver must have HZ>=200.

The way I do it:
All systems will give me a delay for at least a few ms. I get the shortest timeout possible on each computer.

Convention in the kernel would be

	aztTimeOut =  HZ / 100 ? : 1;
to be at least one tick (works for HZ even below 100) and is at least 10ms. If 
you wanted 2 ms then use
	aztTimeOut =  HZ / 500 ? : 1;

which would give you at least 2ms

Cheers,
Con

#5 lore raw
Quoted 7 lines · Con Kolivas

Convention in the kernel would be

	aztTimeOut =  HZ / 100 ? : 1;
to be at least one tick (works for HZ even below 100) and is at least 10ms. If you wanted 2 ms then use
	aztTimeOut =  HZ / 500 ? : 1;

which would give you at least 2ms

Thank you Con for the feedback.

Hmm.. The minimum value should be 2, right?
Otherwise the loop could time out after only a few nanoseconds.. since the loop will then timeout immediately on a clock tick. Or am I wrong?

Best regards,
Daniel Marjamäki

#6 lore raw
Quoted 8 lines · Daniel Marjamäki
Quoted 6 lines · Con Kolivas

Convention in the kernel would be

	aztTimeOut =  HZ / 100 ? : 1;
to be at least one tick (works for HZ even below 100) and is at least
10ms. If you wanted 2 ms then use
	aztTimeOut =  HZ / 500 ? : 1;

which would give you at least 2ms

Quoted 5 lines

Thank you Con for the feedback.

Hmm.. The minimum value should be 2, right?
Otherwise the loop could time out after only a few nanoseconds.. since the loop will then timeout immediately on a clock tick. Or am I wrong?

aztTimeOut = HZ / 500 ? : 1;
Would give you a 2ms timeout on 1000Hz and 500Hz
It would give you 5ms on 250Hz and 10ms on 100Hz

ie the absolute minimum it would be would be 2ms, but it would always be at least one timer tick which is longer than 2ms at low HZ values.

Cheers,
Con

#7 lore raw
Quoted 7 lines · Con Kolivas
Quoted 3 lines · Daniel Marjamäki

Hmm.. The minimum value should be 2, right?
Otherwise the loop could time out after only a few nanoseconds.. since the loop will then timeout immediately on a clock tick. Or am I wrong?

Quoted 6 lines

aztTimeOut = HZ / 500 ? : 1;
Would give you a 2ms timeout on 1000Hz and 500Hz
It would give you 5ms on 250Hz and 10ms on 100Hz

ie the absolute minimum it would be would be 2ms, but it would always be at least one timer tick which is longer than 2ms at low HZ values.

Not true. From 'now', the next timer interrupt is somewhere between epsilon and 1/HZ seconds away.

Luckily, time_after is < rather than <=, so your aztTimeOut would actually make Daniel's code wait until a minimum of *two* timer ticks have elapsed since reading jiffies. So it would manage to scrape by the values of HZ you quoted.

OTOH, if HZ were between 500 and 1000, it would again be too short due to truncation.

Better I think would be to use the proper interfaces for converting msecs to jiffies:

  aztTimeOut = jiffies + msecs_to_jiffies(2);

Nick

Signature · 3 lines
SUSE Labs, Novell Inc.

Send instant messages to your online friends http://au.messenger.yahoo.com 
#8 lore raw
Quoted 24 lines · Nick Piggin
Quoted 7 lines · Con Kolivas
Quoted 3 lines · Daniel Marjamäki

Hmm.. The minimum value should be 2, right?
Otherwise the loop could time out after only a few nanoseconds.. since the loop will then timeout immediately on a clock tick. Or am I wrong?

Quoted 7 lines
      aztTimeOut =  HZ / 500 ? : 1;

Would give you a 2ms timeout on 1000Hz and 500Hz
It would give you 5ms on 250Hz and 10ms on 100Hz

ie the absolute minimum it would be would be 2ms, but it would always be at least one timer tick which is longer than 2ms at low HZ values.

Not true. From 'now', the next timer interrupt is somewhere between epsilon and 1/HZ seconds away.

Luckily, time_after is < rather than <=, so your aztTimeOut would actually make Daniel's code wait until a minimum of *two* timer ticks have elapsed since reading jiffies. So it would manage to scrape by the values of HZ you quoted.

Quoted 7 lines

OTOH, if HZ were between 500 and 1000, it would again be too short due to truncation.

Better I think would be to use the proper interfaces for converting msecs to jiffies:

   aztTimeOut = jiffies + msecs_to_jiffies(2);

That's what I get for sleeping. Yes, Nick is right, don't do this conversion yourself, please, use the interfaces designed exactly to avoid any confusion / HZ-issues (and if those interfaces have limitations, as Willy discovered earlier, please fix them).

Thanks,
Nish

#9 lore raw
In reply to Con Kolivas
Quoted 9 lines · Con Kolivas
Quoted 3 lines · Daniel Marjamäki

The way I do it:
All systems will give me a delay for at least a few ms. I get the shortest timeout possible on each computer.

Convention in the kernel would be

	aztTimeOut =  HZ / 100 ? : 1;

to be at least one tick (works for HZ even below 100) and is at least 10ms.

You have to add one to the timeout, since you might be just before the end of the timeslice when the delay starts. aztTimeOut = (HZ / 100 ? : 1) + 1;

Signature · 2 lines
Top 100 things you don't want the sysadmin to say:
11. Can you get VMS for this Sparc thingy?