Re: [PATCH v3 1/1] kthread: allocate kthread structure using kmalloc

From: Thomas Gleixner
Date: Wed Oct 26 2016 - 14:34:19 EST


On Wed, 26 Oct 2016, Oleg Nesterov wrote:
> On 10/26, Thomas Gleixner wrote:
> >
> > On Wed, 26 Oct 2016, Oleg Nesterov wrote:
> > > +static inline void set_kthread_struct(void *kthread)
> > > +{
> > > + /*
> > > + * We abuse ->set_child_tid to avoid the new member and because it
> > > + * can't be wrongly copied by copy_process(). We also rely on fact
> > > + * that the caller can't exec, so PF_KTHREAD can't be cleared.
> > > + */
> > > + current->set_child_tid = (__force void __user *)kthread;
> >
> > Can we pretty please avoid this type casting? We only have 5 places using
> > set_child_tid. So we can really make it a proper union
>
> Yes, I thought about anonymous union too, the only problem is that
> it will need more comments ;)

Be careful with anonymous unions. There are a few pitfalls with older
compilers. That's why I said make it a proper union and fixup the 5 usage
sites. It might work in this case, but you've been warned :)

Thanks,

tglx