From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934533AbcCOQSp (ORCPT ); Tue, 15 Mar 2016 12:18:45 -0400 Received: from mail-io0-f176.google.com ([209.85.223.176]:34045 "EHLO mail-io0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751048AbcCOQSm (ORCPT ); Tue, 15 Mar 2016 12:18:42 -0400 MIME-Version: 1.0 In-Reply-To: <20160315093245.GA7943@gmail.com> References: <20160314123200.GA15971@gmail.com> <20160315093245.GA7943@gmail.com> Date: Tue, 15 Mar 2016 09:18:36 -0700 X-Google-Sender-Auth: LH-xmrWMtgXYi1WeDGoJ-rziiAI Message-ID: Subject: Re: [PATCH] atomic: Fix bugs in 'fetch_or()' and rename it to 'xchg_or()' From: Linus Torvalds To: Ingo Molnar Cc: Linux Kernel Mailing List , =?UTF-8?B?RnLDqWTDqXJpYyBXZWlzYmVja2Vy?= , Thomas Gleixner , Peter Zijlstra , Andrew Morton Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 15, 2016 at 2:32 AM, Ingo Molnar wrote: > > I can see two other problems with it as well: > > 1) 'ptr' may get evaluated multiple times as well, not just 'mask'. Right you are. > 2) its naming sucks. "fetch_or()" does not really signal that it's a > fundamentally atomic operation, nor what API family it belongs to. Actually, I like the naming, I just don't like the implementation. It's not just the "evaluated multiple times", it's also the fact that if we start doing "fetch_or()", then some day we'll want "fetch_and()" or "fetch_clear()" etc. Or, in fact, "fetch_add()", which is often closer to what hardware does than the "atomic_add_return()" we have now (the difference is that "fetch_add()" returns the original value, while "atomic_add_return()" returns the end result). So what I meant with "try to match what we already have in our existing atomic.h" is that we do the _infrastructure_ so well. We do it well both by having separate UP and SMP versions of the underlying helpers, but we do it well by having those helpers that are then used to implement the different atomic versions. So I'd like something similar for the "fetch_op" thing. Linus