Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934576AbcCOKvK (ORCPT ); Tue, 15 Mar 2016 06:51:10 -0400 Received: from [198.137.202.9] ([198.137.202.9]:49129 "EHLO bombadil.infradead.org" rhost-flags-FAIL-FAIL-OK-OK) by vger.kernel.org with ESMTP id S934511AbcCOKvF (ORCPT ); Tue, 15 Mar 2016 06:51:05 -0400 Date: Tue, 15 Mar 2016 11:50:08 +0100 From: Peter Zijlstra To: Ingo Molnar Cc: Linus Torvalds , Linux Kernel Mailing List , =?iso-8859-1?Q?Fr=E9d=E9ric?= Weisbecker , Thomas Gleixner , Andrew Morton Subject: Re: [PATCH] atomic: Fix bugs in 'fetch_or()' and rename it to 'xchg_or()' Message-ID: <20160315105008.GT6344@twins.programming.kicks-ass.net> References: <20160314123200.GA15971@gmail.com> <20160315093245.GA7943@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160315093245.GA7943@gmail.com> User-Agent: Mutt/1.5.21 (2012-12-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1109 Lines: 25 On Tue, Mar 15, 2016 at 10:32:45AM +0100, Ingo Molnar wrote: > 2) its naming sucks. "fetch_or()" does not really signal that it's a > fundamentally atomic operation, nor what API family it belongs to. I disagree there, the fetch-$op naming is widely used for atomic operations that return the previous value. See for example the C/C++11 atomic ops. I've even thought about reworking our entire atomic*_t bits to match. That is, introduce all the fetch_$op primitives, then convert all the $op_return ones over and finally remove all the $op_return ones. I've not done so because we're all so very used to $op_return that I'm sure people (and this would very much include me) would curse me for changing this. The reason for fetch_$op is that it also works for irreversible operations like or. With or_return you simply cannot tell what the previous state was (with add_return you can do a simple subtraction to revert to the prior state). And yes, some people use the xchg-$op naming, but its less widely used (x86 asm being one). Other also use swap-$op. In any case, I prefer the name as it was.