Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp917997pxj; Sat, 8 May 2021 02:31:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwa28/2hx9tFLTfdl/Y/fqGMsAHZ6Gm5ztnZEZew2ynbqG1ETw46NgtKKVR6XlVoyJ3V4iz X-Received: by 2002:a17:902:9002:b029:e6:c95f:2a1d with SMTP id a2-20020a1709029002b02900e6c95f2a1dmr14662942plp.79.1620466279856; Sat, 08 May 2021 02:31:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620466279; cv=none; d=google.com; s=arc-20160816; b=LgT26NKmUVslpg7kvwKxs6EyEBuiZy8GmdVcgNeLDYbNEJgqp3mahTOcKga4FoId3W /i6bLMt2Wxzd4fEy6gKB3jTmLzRi+3HvznIjheKNtCHAcVIqEx4tIITxS/9lUSbhvisN 12WM8n9E4keHEMmVXCxsv78HAKRPA7VLObsyFmYWlvNEE+zH+/EwW4lW/+aI5UdV0Y3s QVaNJ2Gy/ea5UeX9eBcfKnSL35IhEBXGebGOHqhezXlWFfhLxpE/bQQ6E9Pz0mM9FFgN T2dXaNPz7dB2j6ChpFXYYJDqRMC7xcqhJafkv0pOBg2HpCwXz5cjwNIiA3eaQbbl2ovY JQDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=6K4JXazsVt4Z8/R197JcA50lURA0wn3wrU1I3Di1gx8=; b=nLcAnkIxBaPDZ52KajhB/Mw/lya3GoSbCgDA1SJfTl35cTjrySVsc8cNElFWE5gyMD N0+v+yHE8urSTq5KXl0kf+Ayoi8IX750Cc+/nZq2QYrUYZ5O2zz+onWloW9EOr2tIhce 3YJvHST1xFA6iPwgBtq1oCd14RWWCHq7PJqyIIS1w+VYwHBsROICGe3M1j/WRblMb3o+ /HNXWAr+IF8WG2BHh9X8R2m5qhotYx5qB6jXlYe7hsIn7JK2LzZCcIvzEuV9uM+eOoz2 3ClHDmx5Fv0Vr34KiJaYmpJQBK1fjvTmHKia39gPwSwOj9DWwdudn1uhrBG1ZUH6sAab 9q3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=sHJQs0+G; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i12si10218574plt.306.2021.05.08.02.31.07; Sat, 08 May 2021 02:31:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=sHJQs0+G; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230289AbhEHJaW (ORCPT + 99 others); Sat, 8 May 2021 05:30:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:44988 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229583AbhEHJaQ (ORCPT ); Sat, 8 May 2021 05:30:16 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id B101461430; Sat, 8 May 2021 09:29:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1620466155; bh=R6RMIUYi3bq0SpvGcfXGDP9cDJfCB+cyfouoJdnFiRI=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=sHJQs0+GeEQ9GsxbId71DGEqb8J/IkMWOCo5LDI4s1VlhJJRyHRVPvLaRSiqzF+zs uevx6s4CiFMC7l3+NIsJA0p2L46mjHZNqfmMmpQI4XiFuIkRpXumoH4sX7YrNixoRe 54el9y7wUj/q9N+vWhdgmCRpOUKiG+qwdmipfSTpAFxxK1qY+zgBi6STJ4VUKTfPr2 VodIeRiiVRg2FsI3I9sX3elIkIbsaTVonmschSZhrWg72a/+3g1SV/ijXgXhW8iire Hs2JVNwnBT7BYkk9vvXYWenCaFuvP32WhORaro73FcuFVo6Jg/cwdBUkYhf09vRCFs 5+Y95P0irCz4g== Received: by mail-ot1-f48.google.com with SMTP id u25-20020a0568302319b02902ac3d54c25eso10102599ote.1; Sat, 08 May 2021 02:29:15 -0700 (PDT) X-Gm-Message-State: AOAM533yMIwIEUQldB/Bk2Eo0sLH/6uK1DA3F3dxpXsmpHgL2WeWqHQ0 Hv3ZitNlK07i4m4NZvs6us1D+l+DXGy/ro1IFo8= X-Received: by 2002:a9d:30b:: with SMTP id 11mr11493944otv.298.1620466155082; Sat, 08 May 2021 02:29:15 -0700 (PDT) MIME-Version: 1.0 References: <20210507220813.365382-1-arnd@kernel.org> <20210507220813.365382-13-arnd@kernel.org> In-Reply-To: From: Arnd Bergmann Date: Sat, 8 May 2021 11:28:26 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [RFC 12/12] asm-generic: simplify asm/unaligned.h To: Linus Torvalds Cc: linux-arch , Vineet Gupta , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, May 8, 2021 at 1:54 AM Linus Torvalds wrote: > On Fri, May 7, 2021 at 3:12 PM Arnd Bergmann wrote: > > > > From: Arnd Bergmann > > > > The get_unaligned()/put_unaligned() implementations are much more complex > > than necessary, now that all architectures use the same code. > > Thanks for doing this, it looks good to me. > > I suspect it's still slightly unnecessarily complicated - why is that > get_unaligned() not just > > #define get_unaligned(ptr) \ > __get_unaligned_t(typeof(*__ptr), __ptr) > > Because I'm not seeing the reason for doing that "__auto_type __ptr" > thing - the argument to a "typeof()" isn't actually evaluated. Both versions are equally correct, I picked the __auto_type version because this tends to produce smaller preprocessor output when you have multiple layers of nested macros with 'ptr' expanding to something complicated, and the get_unaligned() itself being expanded multiple times again. When I recently experimented with possible changes to cmpxchg() and get_user(), it had a measurable impact on compile time with clang on those macros. get_unaligned() doesn't appear to be used much in nested macros at all, so it probably won't actually help here, and I can just do the simpler version instead. I forgot to mention in the changelog that this version does not actually require the argument to be a scalar, not sure if this is something we want or not. It does allow developers to write something like __be32 get_ip_saddr(struct sk_buff *skb) { struct iphdr *iph = ip_hdr(skb); return get_unaligned(iph).saddr; } and get the expected result. While this seems handy, it also makes it harder to change the macro back to one that only works on scalars after such usage becomes widespread. Arnd