Skip to contentSkip to conversation

hrtimer_nanosleep: use -EINTR, not -ERESTARTNOHAND

PATCH In review Oleg Nesterov 2 participants 3 messages Feb 1, 2008

lore
Share & tools
lore
#0 lore raw

PATCH 1/5 hrtimer_nanosleep: use -EINTR, not -ERESTARTNOHAND

hrtimer_nanosleep:

	/* Absolute timers do not update the rmtp value and restart: */
	return -ERESTARTNOHAND;

This is not right, -ERESTARTNOHAND means we will do restart if there is no in fact pending signal, and worse, this restart will use the same unchanged "__user *rmtp" parameter.

Use -EINTR instead.

kernel/hrtimer.c~HRT_RMTP renamed from kernel/hrtimer.c~HRT_RMTP~ +1 -1
@@ -1359,7 +1359,7 @@ long hrtimer_nanosleep(struct timespec *
 
 	/* Absolute timers do not update the rmtp value and restart: */
 	if (mode == HRTIMER_MODE_ABS)
-		return -ERESTARTNOHAND;
+		return -EINTR;
 
 	if (rmtp) {
 		rem = ktime_sub(t.timer.expires, t.timer.base->get_time());
#1 lore raw
Quoted 8 lines · Oleg Nesterov

hrtimer_nanosleep:

	/* Absolute timers do not update the rmtp value and restart: */
	return -ERESTARTNOHAND;

This is not right, -ERESTARTNOHAND means we will do restart if there is no in fact pending signal, and worse, this restart will use the same unchanged "__user *rmtp" parameter.

-ERESTARTNOHAND is safe here. We want to restart the timer.

The rmtp problem is separate, but that's addressed by your follow up changes.

Thanks,
tglx

Quoted 16 lines

Use -EINTR instead.

kernel/hrtimer.c~HRT_RMTP renamed from kernel/hrtimer.c~HRT_RMTP~ +1 -1
@@ -1359,7 +1359,7 @@ long hrtimer_nanosleep(struct timespec *
 
 	/* Absolute timers do not update the rmtp value and restart: */
 	if (mode == HRTIMER_MODE_ABS)
-		return -ERESTARTNOHAND;
+		return -EINTR;
 
 	if (rmtp) {
 		rem = ktime_sub(t.timer.expires, t.timer.base->get_time());
#2 lore raw
Quoted 5 lines · Thomas Gleixner
Quoted 2 lines · Oleg Nesterov

hrtimer_nanosleep:

Quoted 8 lines
Quoted 6 lines
	/* Absolute timers do not update the rmtp value and restart: */
	return -ERESTARTNOHAND;

This is not right, -ERESTARTNOHAND means we will do restart if there is no in fact pending signal, and worse, this restart will use the same unchanged "__user *rmtp" parameter.

-ERESTARTNOHAND is safe here. We want to restart the timer.

Ah. I was greatly confused by the comment, it says "do not ... restart", now I understand what this _actually_ means.

And yes, I was wrong. If restart is wanted, it is safe to use the original *rqtp, the timer is HRTIMER_MODE_ABS.

Thanks Thomas!

Andrew, please ignore this patch.

Oleg.