lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20180426160227.GA6297@andrea>
Date:   Thu, 26 Apr 2018 18:02:27 +0200
From:   Andrea Parri <andrea.parri@...rulasolutions.com>
To:     Peter Zijlstra <peterz@...radead.org>
Cc:     Gaurav Kohli <gkohli@...eaurora.org>, tglx@...utronix.de,
        mpe@...erman.id.au, mingo@...nel.org, bigeasy@...utronix.de,
        linux-kernel@...r.kernel.org, linux-arm-msm@...r.kernel.org,
        Neeraj Upadhyay <neeraju@...eaurora.org>,
        Will Deacon <will.deacon@....com>,
        Oleg Nesterov <oleg@...hat.com>
Subject: Re: [PATCH v1] kthread/smpboot: Serialize kthread parking against
 wakeup

On Thu, Apr 26, 2018 at 10:41:31AM +0200, Peter Zijlstra wrote:

[...]

> +/*
> + * Special states are those that do not use the normal wait-loop pattern. See
> + * the comment with set_special_state().
> + */
> +#define is_special_state(state)		\
> +	((state) == TASK_DEAD ||	\
> +	 (state) == TASK_STOPPED)
> +
>  #ifdef CONFIG_DEBUG_ATOMIC_SLEEP
>  
> +/*
> + * Assert we don't use the regular *set_current_state() helpers for special
> + * states. See the comment with set_special_state().
> + */
> +#define assert_special_state(state)	WARN_ON_ONCE(is_special_state(state))

Nitpicking, this name suggests "Shout if the state is NOT special" to me:
maybe,

#define assert_special_state(state)	WARN_ON_ONCE(!is_special_state(state))
#define assert_regular_state(state)	WARN_ON_ONCE(is_special_state(state))

or just do with the WARN_ON_ONCE()s ?

  Andrea


> +
>  #define __set_current_state(state_value)			\
>  	do {							\
> +		assert_special_state(state_value);		\
>  		current->task_state_change = _THIS_IP_;		\
>  		current->state = (state_value);			\
>  	} while (0)
> +
>  #define set_current_state(state_value)				\
>  	do {							\
> +		assert_special_state(state_value);		\
>  		current->task_state_change = _THIS_IP_;		\
>  		smp_store_mb(current->state, (state_value));	\
>  	} while (0)
>  
> +#define set_special_state(state_value)					\
> +	do {								\
> +		unsigned long flags; /* may shadow */			\
> +		WARN_ON_ONCE(!is_special_state(state_value));		\
> +		raw_spin_lock_irqsave(&current->pi_lock, flags);	\
> +		current->task_state_change = _THIS_IP_;			\
> +		current->state = (state_value);				\
> +		raw_spin_unlock_irqrestore(&current->pi_lock, flags);	\
> +	} while (0)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ