[CRIU] [PATCH 5/5] x86: atomic -- Adopt code from linux kernel

Pavel Emelyanov xemul at parallels.com
Fri Feb 15 08:28:42 EST 2013


On 02/06/2013 12:04 AM, Cyrill Gorcunov wrote:
> 
> This allow us to eliminate "asm/types.h" inclusion as well,
> together with simplifying the code.
> 
> Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
> ---
>  arch/x86/include/asm/atomic.h | 92 +++++++++++++++++++------------------------
>  include/lock.h                |  3 +-
>  2 files changed, 43 insertions(+), 52 deletions(-)
> 


> @@ -119,7 +119,8 @@ static void inline mutex_lock(mutex_t *m)
>  	u32 c;
>  	int ret;
>  
> -	while ((c = atomic_inc(&m->raw))) {
> +	while ((c = atomic_read(&m->raw))) {
> +		atomic_inc(&m->raw);

This is not equal change. It was while (atomic_get_and_inc) now its while (atomic_get) atomic_inc.

>  		ret = sys_futex(&m->raw.counter, FUTEX_WAIT, c + 1, NULL, NULL, 0);
>  		BUG_ON(ret < 0 && ret != -EWOULDBLOCK);
>  	}



More information about the CRIU mailing list