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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20090703122710.GC7161@elte.hu>
Date:	Fri, 3 Jul 2009 14:27:10 +0200
From:	Ingo Molnar <mingo@...e.hu>
To:	Eric Dumazet <eric.dumazet@...il.com>
Cc:	Linus Torvalds <torvalds@...ux-foundation.org>,
	David Howells <dhowells@...hat.com>, akpm@...ux-foundation.org,
	paulus@...ba.org, arnd@...db.de, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 1/2] FRV: Implement atomic64_t


* Eric Dumazet <eric.dumazet@...il.com> wrote:

> My last suggestion would be :
> 
> static inline unsigned long long atomic64_read(const atomic64_t *ptr)
> {
> 	unsigned long long res;
> 
> 	asm volatile(
> 		"mov     %%ebx, %%eax\n\t"
> 		"mov     %%ecx, %%edx\n\t"
> 		LOCK_PREFIX "cmpxchg8b %1\n"
> 			: "=A" (res)
> 			: "m" (*ptr)
> 		);
> 	return res;
> }
> 
> ebx/ecx being read only, and their value can be random, they are 
> not even mentioned in asm constraints, so gcc is allowed to keep 
> useful values in these registers.
> 
> So the following (stupid) example
> 
>         for (i = 0; i < 10000000; i++) {
>                 res += atomic64_read(&myvar);
>         }
> 
> gives :
>         xorl    %esi, %esi
> .L2:
>         mov     %ebx, %eax
>         mov     %ecx, %edx
>         lock;cmpxchg8b myvar
>         addl    %eax, %ecx
>         adcl    %edx, %ebx
>         addl    $1, %esi
>         cmpl    $10000000, %esi
>         jne     .L2

Ok, agreed. We dont want to inline it - cmpxchg8b is way too fat - 
but your code above is a valid optimization for the out-of-line 
variant as well. So i have applied it as such, will post the whole 
atomic64_t series soon, after some testing.

	Ingo
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ