Received: by 2002:ab2:2441:0:b0:1f3:1f8c:d0c6 with SMTP id k1csp19980lqe; Wed, 3 Apr 2024 20:09:29 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUBRLQXlzAoHvdjwGKbvyI7BYdWOCNH4gO4XzlaSmdyS7WltCHptYYF5/MJ0yKwoiUfBmyJVbNLIoqTbR0vilWdZ3VYllK0bumy0Dka8Q== X-Google-Smtp-Source: AGHT+IEYhVHV9tELi/GnqImwA4+XeoewvJniYN/FRja0A8W3Xwl11lf0SnYpQqo3CLGDdI0zXfbx X-Received: by 2002:a17:90a:9a4:b0:2a2:dcbd:9f01 with SMTP id 33-20020a17090a09a400b002a2dcbd9f01mr148643pjo.38.1712200169069; Wed, 03 Apr 2024 20:09:29 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712200169; cv=pass; d=google.com; s=arc-20160816; b=WNkO45Trmqtm+At1URtbJ1pkAbIl1A71XLHgsG9axGkCvL/mqry23GXp2hqXBtNQ8C jPCF6XlgXBxGMM8UeQBZDgD0Cz0zebX2eJgRa7o9D42YCN8gk5ZhX0n1S6N9dCv+zqQb KhRVUWlD0XAC2YxzqgpuWaVP56VM3PH1QFVXT0UO+RU/8fWF8TE7oq3+OBKxpPFnGiRK hiLNETFFiX9f2Z6O+dgbf/iErZhWytSksMCIXmvtQPLEAVP2Jr6WFY2KSUjJSRov+Vn0 Z3BQuDBGPFEih7RIK3sAc9C2IGvRWy5Ni8xl7HAKcNw8hsd1ioh7lMs/5GQJhB3rJxMr igHw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=Sw3fDZRkn+IViLxv+K7RSezD38XZZEMCv21trZW/FW4=; fh=2zpta7jx/AjBQm4eotK0CeGLdp7kvYJ6D7bvwF0q1nk=; b=rGYr/fA12OWEClB1HDAmoQ7WEzvMW9t+PMTUiJhZ2ugwOMmoYJeP09oYZpU3MbxCCc X4DMd/jxR6ghT0FdgQ2lgTreo6diwzetGvVcDgvX6d8HfQskL9SQi9zsVBu3QyECdp78 p1ycMwtBqY0GewgLLzMjAMwggm/dGSdxYMmoWl7uCni5yuSaq09gKVvL50CSlZkYH9vn Fr2UMnt9OFiV2+z9+vB2PFrDppdpW+6wk8YpIEZsb+wnTbiKmGvnu2ZHp8voJOKXb6ji cRsJ8WyBjS/yq3EPjBCSVnj0OhCiFYZe6ZAXP38EDWsTkyXVTjsnOvFTYTkQ/inBXJVY uJgQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=RzZasvmc; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-130852-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-130852-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id mh15-20020a17090b4acf00b0029e0e07d580si794670pjb.126.2024.04.03.20.09.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Apr 2024 20:09:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-130852-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=RzZasvmc; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-130852-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-130852-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id A06CA28BCBB for ; Thu, 4 Apr 2024 03:09:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B1A4F1CF9B; Thu, 4 Apr 2024 03:09:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="RzZasvmc" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DACC91CD2D for ; Thu, 4 Apr 2024 03:09:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712200161; cv=none; b=ud7gZpZkMUZmUE6VPwo+WU5PNqLkvKpTAmIydn72ii8rUDd3IiS3YrnXgEQSHN12i0qYqZD1TLcuqPuNEQICvcahD2sWxFE1vS3nx2qTCvCxhGJqpHWi3qadBq6dnUlVmCMuP8s1SMr7W8vylCmUhasL17UkOqKVJHnn0zu1Yzs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712200161; c=relaxed/simple; bh=VeDsqzIDw+9y6Q1G53nbCpHTMO3LeJQlYx7W7Yi3jSM=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=pA7lYxyq0QUkk5ZPnAhsyhqclj0cSap2jJXaPBbGv0g9jCUL3Rfp3HVe8JrIxN95A3AZSrfPYYtQAqKJ0vAA/eEbcRUh89n5rYTxTri0VYWZ7CzAc/vfZu9M0fRIuL41rE5CTKJ7xbhRmDERwEnaMPxP9x2OQc+l6oOW9WsYGLo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=RzZasvmc; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 658EFC433F1; Thu, 4 Apr 2024 03:09:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712200161; bh=VeDsqzIDw+9y6Q1G53nbCpHTMO3LeJQlYx7W7Yi3jSM=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=RzZasvmcsRMTp33dFG8x+1sEkl14h39MN8HQ/TPzu7uHky1o2tJzapBkO/zM5ctUR 5HAnhPIT6aNJ30FETgzkhPAtMe2PcZMMI1e5edBVVoAJiaGuqycqqgCaXy8CmwzdQ/ 3FwUVCWmLeKWwDGhE8yQoCtpk6WhNOa5lQruIwnVP5Q+TaRGg/lLZyYFHby3toAfo9 rfG0KBcZZ9T04c/qBELknVaIIezJ1BPqppzujFuktbVH54FZbZgfE6JaESIz6Fb70r AK7KHzFmVdEw29ZrZg8E7BUpVV9rMGxUPKTZ2/zt8Y9FvK/fBWOGGyyhly7HpOn2zX ec5R1M38NjUjA== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 0DAD8CE109B; Wed, 3 Apr 2024 20:09:21 -0700 (PDT) Date: Wed, 3 Apr 2024 20:09:21 -0700 From: "Paul E. McKenney" To: Al Viro Cc: linux-kernel@vger.kernel.org, kernel-team@meta.com, "David S. Miller" , Andreas Larsson , Palmer Dabbelt , Arnd Bergmann , Marco Elver Subject: Re: [PATCH 1/8] sparc32: make __cmpxchg_u32() return u32 Message-ID: <2676cf77-1374-4d39-a669-e2db4b9b7bf5@paulmck-laptop> Reply-To: paulmck@kernel.org References: <20240402041138.GF538574@ZenIV> <20240402042835.11815-1-viro@zeniv.linux.org.uk> <85837f16-903c-44cd-8277-377e0228eb61@paulmck-laptop> <20240403222053.GK538574@ZenIV> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240403222053.GK538574@ZenIV> On Wed, Apr 03, 2024 at 11:20:53PM +0100, Al Viro wrote: > On Tue, Apr 02, 2024 at 01:03:13PM -0700, Paul E. McKenney wrote: > > On Tue, Apr 02, 2024 at 12:28:28AM -0400, Al Viro wrote: > > > Conversion between u32 and unsigned long is tautological there, > > > and the only use of return value is to return it from > > > __cmpxchg() (which return unsigned long). > > > > > > Signed-off-by: Al Viro > > > > I have pulled these in as replacements for my patches in the meantime. > > > > Thank you! > > FWIW, updated branch force-pushed; the difference is that __cmpxchg() > on sparc32 went > - switch (size) { > - case 1: > - return __cmpxchg_u8((u8 *)ptr, (u8)old, (u8)new_); > - case 2: > - return __cmpxchg_u16((u16 *)ptr, (u16)old, (u16)new_); > - case 4: > - return __cmpxchg_u32((u32 *)ptr, (u32)old, (u32)new_); > - default: > - __cmpxchg_called_with_bad_pointer(); > - break; > - } > - return old; > + return > + size == 1 ? __cmpxchg_u8(ptr, old, new_) : > + size == 2 ? __cmpxchg_u16(ptr, old, new_) : > + size == 4 ? __cmpxchg_u32(ptr, old, new_) : > + (__cmpxchg_called_with_bad_pointer(), old); > > (and similar for parisc). Rationale: sparse does generate constant > truncation warnings in unreachable statements, but not in never-evaluated > subexpressions. Alternative would be what parisc used to do in mainline: > case 1: return __cmpxchg_u8((u8 *)ptr, old & 0xff, new_ & 0xff); > and we'd need the same in 16bit case (both on parisc and sparc32). > Explicit (and rather mysterious) & 0xff for passing unsigned long to > a function that takes u8 was there to tell sparse that e.g. > cmpxchg(&int_var, 0, 0x12345678) was *not* trying to feed > 0x12345678 to a __cmpxchg_u8(), which would quietly truncate it had > it ever been reached. Use of conditional expression avoids that > without having to play with explicit (and utterly pointless from > C point of view) masking. IMO it's better that way, not to mention > being more concise than use of switch. Cute! I replaced the old versions of your patches with this series. However, I was too lazy to apply this transformation to the other cmpxchg() implementations. ;-) Thanx, Paul