Re: [patch 14/45] posix-timers: Consolidate interval retrieval

From: Frederic Weisbecker
Date: Fri Jun 30 2023 - 10:04:13 EST


On Fri, Jun 30, 2023 at 03:07:17PM +0200, Thomas Gleixner wrote:
> On Fri, Jun 30 2023 at 13:25, Frederic Weisbecker wrote:
> > On Thu, Jun 29, 2023 at 08:47:30PM +0200, Thomas Gleixner wrote:
> >> On Wed, Jun 28 2023 at 15:08, Frederic Weisbecker wrote:
> >>
> >> > Le Tue, Jun 06, 2023 at 04:37:40PM +0200, Thomas Gleixner a écrit :
> >> >> There is no point to collect the current interval in the posix clock
> >> >> specific settime() and gettime() callbacks. Just do it right in the common
> >> >> code.
> >> >>
> >> >> Signed-off-by: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
> >> >
> >> > The only difference I see is that we now return the old interval
> >> > even if the target is reaped, which probably doesn't matter anyway.
> >>
> >> But we don't return it to user space because ret != 0 in that case.
> >
> > In the case of ->set yes but in the case of ->get there is no error
> > handling.
>
> SYSCALL_DEFINE2(timer_gettime, timer_t, timer_id,
> struct __kernel_itimerspec __user *, setting)
> {
> struct itimerspec64 cur_setting;
>
> int ret = do_timer_gettime(timer_id, &cur_setting);
> if (!ret) {
> if (put_itimerspec64(&cur_setting, setting))
>
> How exactly does this end up being copied to user space if ret != 0?

kc->timer_get() doesn't return any value.

So before the patch, interval is retrieved only if the target is not reaped:

timer_gettime() {
do_timer_gettime() {
posix_cpu_timer_get() {
p = cpu_timer_task_rcu(timer);
if (p)
itp->interval = ....
}
}
}

After the patch it's retrieved unconditionally:

timer_gettime() {
do_timer_gettime() {
//unconditionally set
itp->interval = ....
posix_cpu_timer_get() {
p = cpu_timer_task_rcu(timer);
if (!p)
//doesn't return any value so no failure reported
}
}
}