Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755921AbZGBV3G (ORCPT ); Thu, 2 Jul 2009 17:29:06 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1754563AbZGBV24 (ORCPT ); Thu, 2 Jul 2009 17:28:56 -0400 Received: from smtp1.linux-foundation.org ([140.211.169.13]:37011 "EHLO smtp1.linux-foundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754289AbZGBV24 (ORCPT ); Thu, 2 Jul 2009 17:28:56 -0400 Date: Thu, 2 Jul 2009 14:28:23 -0700 (PDT) From: Linus Torvalds X-X-Sender: torvalds@localhost.localdomain To: Eric Dumazet cc: David Howells , mingo@elte.hu, akpm@linux-foundation.org, paulus@samba.org, arnd@arndb.de, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/2] FRV: Implement atomic64_t In-Reply-To: <4A4D2239.5000602@gmail.com> Message-ID: References: <20090701144913.GA28172@elte.hu> <20090701164700.29780.15103.stgit@warthog.procyon.org.uk> <4A4D2239.5000602@gmail.com> User-Agent: Alpine 2.01 (LFD 1184 2008-12-16) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1223 Lines: 30 On Thu, 2 Jul 2009, Eric Dumazet wrote: > > Using a fixed initial value (instead of __atomic64_read()) is even faster, > it apparently permits cpu to use an appropriate bus transaction. Yeah, I guess it does a "read-for-write-ownership" and allows the thing to be done as a single cache transaction. If we read it first, it will first get the cacheline for shared-read, and then the cmpxchg8b will need to turn it from shared to exclusive. Of course, the _optimal_ situation would be if the cmpxchg8b didn't actually do the write at all when the value matches (and all cores could just keep it shared), but I guess that's not going to happen. Too bad there is no pure 8-byte read op. Using MMX has too many downsides. Btw, your numbers imply that for the atomic64_add_return(), we really would be much better off not reading the original value at all. Again, in that case, we really do want the "read-for-write-ownership" cache transaction, not a read. Linus -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/