[patch V2 11/50] posix-cpu-timers: Handle SIGEV_NONE timers correctly in timer_set()

Thomas Gleixner posted 50 patches 1 year, 8 months ago
There is a newer version of this series
[patch V2 11/50] posix-cpu-timers: Handle SIGEV_NONE timers correctly in timer_set()
Posted by Thomas Gleixner 1 year, 8 months ago
Expired SIGEV_NONE oneshot timers must return 0 nsec for the expiry time in
timer_get(), but the posix CPU timer implementation returns 1 nsec.

Add the missing conditional.

This will be cleaned up in a follow up patch.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
V2: Split out into new patch to make review simpler - Frederic
---
 kernel/time/posix-cpu-timers.c |   11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

--- a/kernel/time/posix-cpu-timers.c
+++ b/kernel/time/posix-cpu-timers.c
@@ -706,7 +706,16 @@ static int posix_cpu_timer_set(struct k_
 				old_expires = exp - val;
 				old->it_value = ns_to_timespec64(old_expires);
 			} else {
-				old->it_value.tv_nsec = 1;
+				/*
+				 * A single shot SIGEV_NONE timer must return 0, when it is
+				 * expired! Timers which have a real signal delivery mode
+				 * must return a remaining time greater than 0 because the
+				 * signal has not yet been delivered.
+				 */
+				if (sigev_none)
+					old->it_value.tv_nsec = 0;
+				else
+					old->it_value.tv_nsec = 1;
 				old->it_value.tv_sec = 0;
 			}
 		}
Re: [patch V2 11/50] posix-cpu-timers: Handle SIGEV_NONE timers correctly in timer_set()
Posted by Anna-Maria Behnsen 1 year, 8 months ago
Thomas Gleixner <tglx@linutronix.de> writes:

> Expired SIGEV_NONE oneshot timers must return 0 nsec for the expiry time in
> timer_get(), but the posix CPU timer implementation returns 1 nsec.

copy paste error (get/set) ?

> Add the missing conditional.
>
> This will be cleaned up in a follow up patch.

I'm confused. Why do you want to cleanup the conditional in a follow up
patch?

Thanks,

	Anna-Maria
Re: [patch V2 11/50] posix-cpu-timers: Handle SIGEV_NONE timers correctly in timer_set()
Posted by Thomas Gleixner 1 year, 8 months ago
On Thu, Apr 11 2024 at 17:48, Anna-Maria Behnsen wrote:

> Thomas Gleixner <tglx@linutronix.de> writes:
>
>> Expired SIGEV_NONE oneshot timers must return 0 nsec for the expiry time in
>> timer_get(), but the posix CPU timer implementation returns 1 nsec.
>
> copy paste error (get/set) ?

Yes.

>> Add the missing conditional.
>>
>> This will be cleaned up in a follow up patch.
>
> I'm confused. Why do you want to cleanup the conditional in a follow up
> patch?

This patch is to fix the issue. The next one consolidates the code, but
I can see why the "this will be ..." part of the changelog does not make
sense.

Thanks,

        tglx
Re: [patch V2 11/50] posix-cpu-timers: Handle SIGEV_NONE timers correctly in timer_set()
Posted by Frederic Weisbecker 1 year, 8 months ago
Le Fri, Apr 12, 2024 at 12:02:28AM +0200, Thomas Gleixner a écrit :
> On Thu, Apr 11 2024 at 17:48, Anna-Maria Behnsen wrote:
> 
> > Thomas Gleixner <tglx@linutronix.de> writes:
> >
> >> Expired SIGEV_NONE oneshot timers must return 0 nsec for the expiry time in
> >> timer_get(), but the posix CPU timer implementation returns 1 nsec.
> >
> > copy paste error (get/set) ?
> 
> Yes.
> 
> >> Add the missing conditional.
> >>
> >> This will be cleaned up in a follow up patch.
> >
> > I'm confused. Why do you want to cleanup the conditional in a follow up
> > patch?
> 
> This patch is to fix the issue. The next one consolidates the code, but
> I can see why the "this will be ..." part of the changelog does not make
> sense.

But please keep it cut that way. FWIW it's much easier to review than the
previous take. That way we aren't missing subtle changes.