Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934767AbcCOMeP (ORCPT ); Tue, 15 Mar 2016 08:34:15 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:34999 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751213AbcCOMdw (ORCPT ); Tue, 15 Mar 2016 08:33:52 -0400 Date: Tue, 15 Mar 2016 13:32:53 +0100 From: Ingo Molnar To: Linus Torvalds Cc: Linux Kernel Mailing List , =?iso-8859-1?Q?Fr=E9d=E9ric?= Weisbecker , Thomas Gleixner , Peter Zijlstra , Andrew Morton Subject: Re: [PATCH] atomic: Fix bugs in 'fetch_or()' and rename it to 'xchg_or()' Message-ID: <20160315123253.GA10152@gmail.com> References: <20160314123200.GA15971@gmail.com> <20160315093245.GA7943@gmail.com> <20160315120147.GA9742@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160315120147.GA9742@gmail.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1096 Lines: 42 * Ingo Molnar wrote: > But IMHO this really highlights a fundamental weakness of all this macro magic, > it's all way too fragile. > > Why don't we introduce a boring family of APIs: > > cmpxchg_8() > cmpxchg_16() > cmpxchg_32() > cmpxchg_64() > > xchg_or_32() > xchg_or_64() > ... > > ... with none of this pesky auto-typing property and none of the > macro-inside-a-macro crap? We could do clean types and would write them all in > proper C, not fragile CPP. > > It's not like we migrate between the types all that frequently - and even if we > do, it's trivial. > > hm? So if we are still on the same page at this point, we'd have to add a pointer variant too I suspect: cmpxchg_ptr() xchg_ptr() ... whose bitness may differ between architectures(subarches), but it would still be a single variant per architecture, i.e. still with pretty clear type propagation and with a very clear notion of which architecture supports what. It looks like a lot of work, but it's all low complexity work AFAICS that could be partly automated. Thanks, Ingo