[PATCH 09/14] powerpc/vas: Update CSB and notify process for fault CRBs

Haren Myneni hbabu at us.ibm.com
Wed Nov 27 21:03:56 AEDT 2019




"Linuxppc-dev" <linuxppc-dev-bounces+hbabu=us.ibm.com at lists.ozlabs.org>
wrote on 11/27/2019 12:46:09 AM:
> >
> > +static void notify_process(pid_t pid, u64 fault_addr)
> > +{
> > +   int rc;
> > +   struct kernel_siginfo info;
> > +
> > +   memset(&info, 0, sizeof(info));
> > +
> > +   info.si_signo = SIGSEGV;
> > +   info.si_errno = EFAULT;
> > +   info.si_code = SEGV_MAPERR;
> > +
> > +   info.si_addr = (void *)fault_addr;
> > +   rcu_read_lock();
> > +   rc = kill_pid_info(SIGSEGV, &info, find_vpid(pid));
> > +   rcu_read_unlock();
> > +
> > +   pr_devel("%s(): pid %d kill_proc_info() rc %d\n", __func__, pid,
rc);
> > +}
>
> Shouldn't this use force_sig_fault_to_task instead?
>
> > +   /*
> > +    * User space passed invalid CSB address, Notify process with
> > +    * SEGV signal.
> > +    */
> > +   tsk = get_pid_task(window->pid, PIDTYPE_PID);
> > +   /*
> > +    * Send window will be closed after processing all NX requests
> > +    * and process exits after closing all windows. In multi-thread
> > +    * applications, thread may not exists, but does not close FD
> > +    * (means send window) upon exit. Parent thread (tgid) can use
> > +    * and close the window later.
> > +    */
> > +   if (tsk) {
> > +      if (tsk->flags & PF_EXITING)
> > +         task_exit = 1;
> > +      put_task_struct(tsk);
> > +      pid = vas_window_pid(window);
>
> The pid is later used for sending the signal again, why not keep the
> reference?

Sorry, Not dropping the PID reference here, Happens only when window
closed. If the task for this PID is not available, looking for tgid in the
case of multi-thread process.
>
> > +   } else {
> > +      pid = vas_window_tgid(window);
> > +
> > +      rcu_read_lock();
> > +      tsk = find_task_by_vpid(pid);
> > +      if (!tsk) {
> > +         rcu_read_unlock();
> > +         return;
> > +      }
> > +      if (tsk->flags & PF_EXITING)
> > +         task_exit = 1;
> > +      rcu_read_unlock();
>
> Why does this not need a reference to the task, but the other one does?

Window is opened with open() and ioctl(fd), will be closed either by close
(fd) explicitly or release FD during process exit.

Process closes all open windows when it exits. So we do not need to keep
the reference for this case. In multi-thread case, child thread can open a
window, but it does not release FD when it exits. Parent thread (tgid) can
continue use this window and closes it upon its exit. So taking reference
to PID in case if this pid is assigned to child thread to make sure its pid
is not reused until window is closed.

We are taking pid reference during window open and releases it when closing
the window.

Thanks
Haren



>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ozlabs.org/pipermail/linuxppc-dev/attachments/20191127/34b492a8/attachment-0001.htm>


More information about the Linuxppc-dev mailing list