lkml.org 
[lkml]   [2020]   [Jun]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [PATCH 6/6] kernel: add a kernel_wait helper
On Fri, Jun 19, 2020 at 09:17:00PM +0000, Luis Chamberlain wrote:
> On Thu, Jun 18, 2020 at 04:46:27PM +0200, Christoph Hellwig wrote:
> > --- a/kernel/exit.c
> > +++ b/kernel/exit.c
> > @@ -1626,6 +1626,22 @@ long kernel_wait4(pid_t upid, int __user *stat_addr, int options,
> > return ret;
> > }
> >
> > +int kernel_wait(pid_t pid, int *stat)
> > +{
> > + struct wait_opts wo = {
> > + .wo_type = PIDTYPE_PID,
> > + .wo_pid = find_get_pid(pid),
> > + .wo_flags = WEXITED,
> > + };
> > + int ret;
> > +
> > + ret = do_wait(&wo);
> > + if (ret > 0 && wo.wo_stat)
> > + *stat = wo.wo_stat;
>
> Since all we care about is WEXITED, that could be simplified
> to something like this:
>
> if (ret > 0 && KWIFEXITED(wo.wo_stat)
> *stat = KWEXITSTATUS(wo.wo_stat)
>
> Otherwise callers have to use W*() wrappers.
>
> > + put_pid(wo.wo_pid);
> > + return ret;
> > +}
>
> Then we don't get *any* in-kernel code dealing with the W*() crap.
> I just unwrapped this for the umh [0], given that otherwise we'd
> have to use KW*() callers elsewhere. Doing it upshot one level
> further would be even better.
>
> [0] https://lkml.kernel.org/r/20200610154923.27510-1-mcgrof@kernel.org
Do you just want to pick this patch up, add your suggested bits and
add it to the beginning of your series? That should clean the whole
thing up a bit. Nothing else in this series depends on the patch.

\
 
 \ /
  Last update: 2020-06-20 08:36    [W:0.586 / U:0.052 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site