[Devel] [RFC] Fix get_exec_env() races

Pavel Emelyanov xemul at parallels.com
Thu Oct 15 04:15:07 PDT 2015


> @@ -130,6 +131,34 @@ struct ve_struct {
>  #endif
>  };
>  
> +static inline struct ve_struct *get_exec_env(void)
> +{
> +	struct ve_struct *ve;
> +
> +	if (++current->ve_attach_lock_depth > 1)
> +		return current->task_ve;
> +
> +	rcu_read_lock();
> +again:
> +	ve = current->task_ve;
> +	read_lock(&ve->attach_lock);
> +	if (unlikely(current->task_ve != ve)) {
> +		read_unlock(&ve->attach_lock);
> +		goto again;

Please, no. 3.10 kernel has task_work-s, ask the task you want to
attach to ve to execute the work by moving itself into it and keep
this small routine small and simple.

> +	}
> +	rcu_read_unlock();
> +
> +	return ve;
> +}
> +




More information about the Devel mailing list