Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp981954imd; Thu, 1 Nov 2018 08:29:41 -0700 (PDT) X-Google-Smtp-Source: AJdET5dOeFTV3qzx4v65dGeNsjDcuYsgQ0D6LeXnKJmxvP1E6waulm1XYdeCUGscrVrJ2LLJmXAi X-Received: by 2002:a63:fe0a:: with SMTP id p10mr4295855pgh.265.1541086181715; Thu, 01 Nov 2018 08:29:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1541086181; cv=none; d=google.com; s=arc-20160816; b=X9Hiv2/6al/A+ChrZSehcDQmPokhwPMHwbbHWPlaOoewe3mGnpuI3a5g0BIDY1k9rX UzB6EhajIHUJ6kpZIPiJlIaTIdzFKtXDu3eWhVAqNdmP42Q43KG3ZD5TORa4mg1IzTfF 2W/ZmDGrwFlEg+vVFrYon8mD9PRIeq2IMqtPjv2WI83rbmAgjbKrdmxyoDLHwDLA7A1N Q0bcgPC5N1hnukbty4hj2nNtdFhP/PPDOoz36/zlzRfxL0K5sBWIeeao3paxWX1gl3PJ YfEW0/BL/kBJwdqdfvJEfQNh7JbjgNjM6n9R8LxTekBWvXd/ky90GgmGnPActSGBWz/8 icZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=UQwNdyZs7+NarOfK+icn1dwEf9p2K/3ed2HnMcVT/yY=; b=n1M4EkXL7pBAoqa2/A/UMU6bpTYPHBJyzICViKh3QLOk/2OASBgLZhdMRnLOd3E8Zn n3QrhdBRhwacWB+Hw6NtVaziRer8QknStftUxbD1T94PS8BHyZg7k9ZVaazNN7UmPEVf cIKrjCu/Vwk5L9mTPjr/2N6JKQFcUIKekP4M/zEJm/XI+ykNhylxHgOZPaRyGyQLvZ76 /c1Fq25pVqE4FBnhloA+7EgWxDrHs0Aj3vRehtNdAzrRwfVhRWYok9eq8YgKvh6UK4TE y3gc8tBmDkPwV/aHL/BccU4kajhxD2X1tBcpHcRdJU4Q26J1QQp+bPGq+CMLGyD7eHpv OL7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b="ew7C/SFJ"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 3si894102pgf.124.2018.11.01.08.29.26; Thu, 01 Nov 2018 08:29:41 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b="ew7C/SFJ"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728790AbeKBAcS (ORCPT + 99 others); Thu, 1 Nov 2018 20:32:18 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:38260 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727950AbeKBAcS (ORCPT ); Thu, 1 Nov 2018 20:32:18 -0400 Received: by mail-pf1-f193.google.com with SMTP id b11-v6so9506774pfi.5; Thu, 01 Nov 2018 08:28:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=UQwNdyZs7+NarOfK+icn1dwEf9p2K/3ed2HnMcVT/yY=; b=ew7C/SFJ6Ri3Bz6CSG3sxAVqWNf/agXmhpiWebq1zpcRYkwr7tp3dIZQVLRK6OPw1a WRMbhYedqjfYTTyn98qQkOyOkfk6t4GlxAu/KFTHCzsiqTslIFFXHqc83+iBxCD5zjhl u3h0Qo+EIYaoZ0HxHNf8IWFBQm6Kz8CUixslkxk5KedqD/dGrxqD9K/UsfRudc0H5veq 05dUpHAjG9s5EvkLwE6RJF3+d4W8bfhgXYGBx4qChVRv3vmE3bJqOPhVpfqbzvPvnp3X MTkiJE7E80Is3fAMQWDEQtDQLZeT4OByi4H0ePAPkaFOoruc6sEeWUh0e+FJ3T6ePOd0 nvBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to:user-agent; bh=UQwNdyZs7+NarOfK+icn1dwEf9p2K/3ed2HnMcVT/yY=; b=Gzj1MNuFQO6aKQGmXsVRQrs0KWXrB2MSezK3zlEQUnetAd4U8dc/1Tz9EziTHXnPVe m+Mwi6OWhyrr16Xw6Z6skmDEJxSmM/FqOfDNob94Z8cL0T0j8nONLbVQoBbpmJqtLXfB CrYTnmcHoew7DU35SYc1J3LzB5f4EN5BzFfmkZuVvmOiINg2oQBzHlOjI92GwVZ8KDD1 yu0mzR03jPoYoChTN+bn/A9ISmmjxC+pCYIJeb9WWHG109oq0EPv+Ucsw0XoXVnJTwDU M8cHcEIl6XFx3i/Y0hxkSK9d8ePHdnvn15VHM/XUTA0X0h7bk8AEtDabSUjAF33764cZ wTYg== X-Gm-Message-State: AGRZ1gJho60qi6PPrBVo7+iT1Dn7x/6SA44fszjUXhQcCDeM9X3tRI4A R9SovqMwzERXFWLqvJwDjuk= X-Received: by 2002:a63:cc51:: with SMTP id q17-v6mr7483905pgi.291.1541086131442; Thu, 01 Nov 2018 08:28:51 -0700 (PDT) Received: from localhost ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id n65-v6sm1848713pfi.185.2018.11.01.08.28.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Nov 2018 08:28:50 -0700 (PDT) Date: Thu, 1 Nov 2018 08:28:49 -0700 From: Guenter Roeck To: Trond Myklebust Cc: "paul.burton@mips.com" , "linux-kernel@vger.kernel.org" , "ralf@linux-mips.org" , "jlayton@kernel.org" , "linuxppc-dev@lists.ozlabs.org" , "bfields@fieldses.org" , "linux-mips@linux-mips.org" , "linux-nfs@vger.kernel.org" , "akpm@linux-foundation.org" , "anna.schumaker@netapp.com" , "jhogan@kernel.org" , "netdev@vger.kernel.org" , "davem@davemloft.net" , "arnd@arndb.de" , "paulus@samba.org" , "mpe@ellerman.id.au" , "benh@kernel.crashing.org" Subject: Re: [RFC PATCH] lib: Introduce generic __cmpxchg_u64() and use it where needed Message-ID: <20181101152849.GC25346@roeck-us.net> References: <1541015538-11382-1-git-send-email-linux@roeck-us.net> <20181031213240.zhh7dfcm47ucuyfl@pburton-laptop> <20181031220253.GA15505@roeck-us.net> <20181031233235.qbedw3pinxcuk7me@pburton-laptop> <291af20b-820e-e848-cf75-730024612117@roeck-us.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Nov 01, 2018 at 06:30:08AM +0000, Trond Myklebust wrote: [ ... ] > > > > For my part I agree that this would be a much better solution. The > > argument > > that it is not always absolutely guaranteed that atomics don't wrap > > doesn't > > really hold for me because it looks like they all do. On top of that, > > there > > is an explicit atomic_dec_if_positive() and > > atomic_fetch_add_unless(), > > which to me strongly suggests that they _are_ supposed to wrap. > > Given the cost of adding a comparison to each atomic operation to > > prevent it from wrapping, anything else would not really make sense > > to me. > > That's a hypothesis, not a proven fact. There are architectures out > there that do not wrap signed integers, hence my question. > If what you say is correct, the kernel is in big trouble on those architectures. atomic_inc_return() is used all over the place in the kernel with the assumption that each returned value differs from the previous value (ie the value is used as cookie, session ID, or for similar purposes). Guenter