Received: by 2002:a05:6500:1b8f:b0:1fa:5c73:8e2d with SMTP id df15csp759973lqb; Wed, 29 May 2024 09:40:48 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCViBUWdUaATWvSMlFuzsZOIwOg5I+hNcr/2G6pEnKln3fqse+yrVPPH4+MoH2t3DrF4lwWGNVMuCyCTqfgnbwWHUnRqUzKhHDfnfrVvhg== X-Google-Smtp-Source: AGHT+IGi0qmurJcFzkMx03xxkYlCUMwkGZvUKNqwtXSvz2h3fF0CbBwiszaduRJuNqGQIAKxoBB5 X-Received: by 2002:a05:6214:3991:b0:6ad:6bb0:f267 with SMTP id 6a1803df08f44-6ad6bb0f50cmr117550426d6.50.1717000847690; Wed, 29 May 2024 09:40:47 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717000847; cv=pass; d=google.com; s=arc-20160816; b=Tt1Rq4XMwegHSh/QpYxj1A3rpG33/5agslJyLNI8IjTEqnwZqO9Kfy6cGmhoOBTs1l ht9zpVvL4BH2feIKF+MUR29TIMOgahKbJ0bn6kwq9bg7gMPJHJf7HPTXGJNFg/y7aaHC 5JLfLUIZZuc1c9KbXcKdFF34CXWNouGYQLiV6N1q/2edL6g3ooJFndB+f7sZVOrGor4r xn6ibMXB7okKM185xD8/uWUlddn1sCpiOXT1dy098exIagbS1zgfepl/mPIYhxme8Paa STerxVFj6FoWPOsyVsDFKBEfglFEJiNdYB9bKzNulbGGRSCJBBC/2NYAl5Ea+hklHMbB vzjA== 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:message-id:subject:cc :to:from:date; bh=aquYP9ML4xfaZ1a20F6ysa+uGYUssR9Tl2hvH2TzUoU=; fh=o5Pw2Cn+rmoc5IA6wKMK6Sg+LaEdn9rL81ESXuSIJu4=; b=qvdR6snUIVV3o6l9twFAl2xkUcLjvIpA+uowmfTLLqh9y/IGvium6KT3KB/eQyUy0Q Xj+Q8lBaq0lqseVWmwwDz3O+6xzMXMMQ9doUkh4n2HTBIAFn8W9xo0uKaC3punN+z2dR 2Mg2VCQEPt7cMvG6VTU2wSj+Mrmct9ct80Kye0+7Wg1IoD8gu/ITzhIREtQ8/EDc9V2m yyefB7jCQom78/r9ayFaN1guYgJYAnGHs7zXk1ji0yI5FnWVauLiadneULg7uXo9XnYx ygW7mUjqKywE4Hwo1yU7HCMn/D2TuzRvjaI1/JMyd/BNP4B9IHSulhSrIGPpeXZ69gec H22Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-194481-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-194481-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id 6a1803df08f44-6ac162de1besi131325596d6.586.2024.05.29.09.40.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 May 2024 09:40:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-194481-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-194481-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-194481-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 377F81C24F2E for ; Wed, 29 May 2024 16:39:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 60354194C61; Wed, 29 May 2024 16:36:42 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1F0D4190683 for ; Wed, 29 May 2024 16:36:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717000601; cv=none; b=R/EmlxoOVps5Y0eKW7bEAEMQt2y23b14WEry4xt8LW5cJGjEN8dbLep7Dwa+ADlnR/vxkgowTFKezG4FdbzmwIcWLNipngOGKeNJFHt4V2LW7lFzUnSoz3cdr42F6671R02vX5axqn+0/9GwYLe/ZwsNuiQWPOCjBgJJoR8j6FU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717000601; c=relaxed/simple; bh=N9WrYbSatpSG3LGiA7yCIjFuPYdHg8AWHSKNnwTQGrI=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=rp39Qbd9vh57fB4e96Zqa2dxNxj1ybiD7UEPMMCN0RRyi6PMpdziw43QApIya0ZdG0WFxmuf0mTzXyRy2KlWrYUiTW+yFJblKSVmEJUNgxvKi0YfJG9wa2nCO2gLiHb9JVpnCQZF8gT06cFFyQuJqbYBwxipYZM5HfjUJIicWHg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 7645D339; Wed, 29 May 2024 09:37:03 -0700 (PDT) Received: from J2N7QTR9R3.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id D270E3F792; Wed, 29 May 2024 09:36:37 -0700 (PDT) Date: Wed, 29 May 2024 17:36:34 +0100 From: Mark Rutland To: Arnd Bergmann Cc: Arnd Bergmann , Catalin Marinas , Will Deacon , Jason Gunthorpe , Valentin Schneider , Baoquan He , Peter Zijlstra , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] arm64/io: add constant-argument check Message-ID: References: <20240528120844.3523915-1-arnd@kernel.org> <8ff9bc52-bf2f-4856-9335-14bf659e7e4c@app.fastmail.com> 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: On Wed, May 29, 2024 at 06:15:57PM +0200, Arnd Bergmann wrote: > On Wed, May 29, 2024, at 17:08, Mark Rutland wrote: > > On Wed, May 29, 2024 at 02:29:37PM +0200, Arnd Bergmann wrote: > >> On Wed, May 29, 2024, at 13:14, Mark Rutland wrote: > > >> > >> Yes, your version addresses both failures I ran into, and > >> I think all other theoretical cases. > >> > >> I would prefer to combine both though, using __always_inline > >> to force the compiler to pick the inline version over > >> __iowrite32_copy_full() even when it is optimizing for size > >> and it decides the inline version is larger, but removing > >> the extra complexity from the macro. > > > > Sorry, I'm not sure what you mean here. I don't see anything handling > > optimizing for size today so I'm not sure what change your suggesting to > > force the use of the inline version; AFAICT that'd always be forced for > > a suitable constant size. > > > > What change are you suggesting? > > What I meant is that reason gcc chooses to not inline > the macro is when we build with CONFIG_CC_OPTIMIZE_FOR_SIZE. > > Since it doesn't know that __const_memcpy_toio_aligned64() > is intended to be small after inlining, it sometimes > decides against it, which (with just my patch) would > fall back to the out-of-line __iowrite32_copy_full() > while trying to generate smaller code. > > The __always_inline annotation just overrides the > calculation. Ah, ok. I think what you're suggesting is: * Add the __always_inline annotations, as in my patch. * Move the __builtin_constant_p check into __const_iowrite32_copy(), as in your patch. * Remove the __iowrite32_copy() macro and rename __const_iowrite32_copy() to __iowrite32_copy(), removing the redundant logic. Assuming so, that makes total sense to me. Mark.