Messages in this thread | | | Date | Wed, 25 Jan 2023 13:43:04 +0100 | From | Oleg Nesterov <> | Subject | Re: [RFC PATCH v2] posix-timers: Support delivery of signals to the current thread |
| |
On 01/12, Dmitry Vyukov wrote: > > --- a/kernel/time/posix-timers.c > +++ b/kernel/time/posix-timers.c > @@ -336,6 +336,7 @@ void posixtimer_rearm(struct kernel_siginfo *info) > int posix_timer_event(struct k_itimer *timr, int si_private) > { > enum pid_type type; > + struct pid *pid; > int ret; > /* > * FIXME: if ->sigq is queued we can race with > @@ -350,8 +351,9 @@ int posix_timer_event(struct k_itimer *timr, int si_private) > */ > timr->sigq->info.si_sys_private = si_private; > > + pid = timr->it_pid ?: task_pid(current); > type = !(timr->it_sigev_notify & SIGEV_THREAD_ID) ? PIDTYPE_TGID : PIDTYPE_PID;
can't resist... somehow the line above looks confusing to me, perhaps you can change it to
type = (timr->it_sigev_notify & SIGEV_THREAD_ID) ? PIDTYPE_PID : PIDTYPE_TGID;
> -static struct pid *good_sigevent(sigevent_t * event) > +static struct pid *good_sigevent(sigevent_t *event, clockid_t which_clock) > { > struct pid *pid = task_tgid(current); > struct task_struct *rtn; > > switch (event->sigev_notify) { > case SIGEV_SIGNAL | SIGEV_THREAD_ID: > + /* This will use the current task for signals. */ > + if (which_clock == CLOCK_PROCESS_CPUTIME_ID && > + !event->sigev_notify_thread_id) > + return NULL;
this doesn't look right, this skips the "sigev_signo" check below.
Other than that I see nothing wrong in this patch, but I forgot everything about posix timers many years ago ;)
> @@ -527,9 +534,11 @@ static int do_timer_create(clockid_t which_clock, struct sigevent *event, > > if (event) { > rcu_read_lock(); > - new_timer->it_pid = get_pid(good_sigevent(event)); > + pid = good_sigevent(event, which_clock); > + if (!IS_ERR(pid)) > + new_timer->it_pid = get_pid(pid);
Another cosmetic nit, feel free to ignore... If you change good_sigevent()
case SIGEV_NONE: - return pid; + return get_pid(pid);
you can remove this "if (!IS_ERR(pid))" code above.
Oleg.
| |