From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D2538C433EF for ; Thu, 16 Dec 2021 17:43:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235965AbhLPRnS (ORCPT ); Thu, 16 Dec 2021 12:43:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34776 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239936AbhLPRnR (ORCPT ); Thu, 16 Dec 2021 12:43:17 -0500 Received: from mail-ed1-x533.google.com (mail-ed1-x533.google.com [IPv6:2a00:1450:4864:20::533]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E41CDC06173E for ; Thu, 16 Dec 2021 09:43:16 -0800 (PST) Received: by mail-ed1-x533.google.com with SMTP id z5so90454376edd.3 for ; Thu, 16 Dec 2021 09:43:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=ms/wuM8WAzRPY4WykXwi0/YehvvfoHEwDko5JETWgyY=; b=Yt6iQrPRR02VnMfhyQFLe4lPoyYi1LLJZh1EAgoFFL5odLJNrpYEgdV1gCmEQ/8Ebm vqyvFiXql5+DLQ9/AE42zzsnV8GD+7jyfxwfcG0fq/qlAeVI5VhSB0SiPNjhiYS6tgxi kvXLQUaOrvL+UE8xSz2YpOdT/AUCe9TuJhNKQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ms/wuM8WAzRPY4WykXwi0/YehvvfoHEwDko5JETWgyY=; b=zohm3Hnb/VU53w3S7XLuPIWcjvvvtSQYkNI/+bKGTuePSJUz5iVv1QuarCI6Wxo2BL QQDRPte0Fk1mQY7pGrtKoeULTQ3p4E7zuNBpa/hwT7IcQRt3tipBrMmCudV7f2Wqjf+5 MkF0Ah2qRKMnroBQNEmS19LORwMepDN7D643Smuf5Wu/usNXTZ7BHIVTpeB/dhVy5gNS 9NdRZ0vJNtyqxb7GSJeuMLJRq0aSk8Gyr+5SCjxRxAM6HmOhV4UeYrOkZKVXOPo1CllS IOaM8iVbpGinH7X1p4T2aNea7/SQC8OZloUEQAo1hPH7acKpHOdrNAw2MyrztxXLlWrl oZwg== X-Gm-Message-State: AOAM533V36Ok0pKuNRZIo14LLDwPueOLCHoRrPOZ/G0yMvBS4iLZtOVS Nah1IruJJF1S5Md4s8EYhmqAIHeNxqRMo41wkKA= X-Google-Smtp-Source: ABdhPJzXJazrNh8j51iD5e0igg3QJKVdbjH+ct3CB7TBh8x7Jw2BXUohFzPjatXTTqR9VcmkYGtT6Q== X-Received: by 2002:a17:907:1c9c:: with SMTP id nb28mr15696349ejc.184.1639676588783; Thu, 16 Dec 2021 09:43:08 -0800 (PST) Received: from mail-ed1-f49.google.com (mail-ed1-f49.google.com. [209.85.208.49]) by smtp.gmail.com with ESMTPSA id f5sm1403499edu.38.2021.12.16.09.43.07 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 16 Dec 2021 09:43:08 -0800 (PST) Received: by mail-ed1-f49.google.com with SMTP id y13so89665712edd.13 for ; Thu, 16 Dec 2021 09:43:07 -0800 (PST) X-Received: by 2002:adf:8b0e:: with SMTP id n14mr9660488wra.281.1639676577218; Thu, 16 Dec 2021 09:42:57 -0800 (PST) MIME-Version: 1.0 References: <20210514100106.3404011-1-arnd@kernel.org> In-Reply-To: From: Linus Torvalds Date: Thu, 16 Dec 2021 09:42:41 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2 00/13] Unify asm/unaligned.h around struct helper To: Ard Biesheuvel Cc: Arnd Bergmann , "Jason A. Donenfeld" , Johannes Berg , Kees Cook , Nick Desaulniers , linux-arch , Vineet Gupta , Arnd Bergmann , Amitkumar Karwar , Benjamin Herrenschmidt , Borislav Petkov , Eric Dumazet , Florian Fainelli , Ganapathi Bhat , Geert Uytterhoeven , "H. Peter Anvin" , Ingo Molnar , Jakub Kicinski , James Morris , Jens Axboe , John Johansen , Jonas Bonn , Kalle Valo , Michael Ellerman , Paul Mackerras , Rich Felker , "Richard Russon (FlatCap)" , Russell King , "Serge E. Hallyn" , Sharvari Harisangam , Stafford Horne , Stefan Kristiansson , Thomas Gleixner , Vladimir Oltean , Xinming Hu , Yoshinori Sato , X86 ML , Linux Kernel Mailing List , Linux ARM , linux-m68k , Linux Crypto Mailing List , openrisc@lists.librecores.org, "open list:LINUX FOR POWERPC (32-BIT AND 64-BIT)" , Linux-sh list , "open list:SPARC + UltraSPARC (sparc/sparc64)" , linux-ntfs-dev@lists.sourceforge.net, linux-block , linux-wireless , "open list:BPF JIT for MIPS (32-BIT AND 64-BIT)" , LSM List Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org On Thu, Dec 16, 2021 at 9:29 AM Ard Biesheuvel wrote: > > CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS is used in many places to > conditionally emit code that violates C alignment rules. E.g., there > is this example in Documentation/core-api/unaligned-memory-access.rst: > > bool ether_addr_equal(const u8 *addr1, const u8 *addr2) > { > #ifdef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS > u32 fold = ((*(const u32 *)addr1) ^ (*(const u32 *)addr2)) | > ((*(const u16 *)(addr1 + 4)) ^ (*(const u16 *)(addr2 + 4))); > return fold == 0; > #else It probably works fine in practice - the one case we had was really pretty special, and about the vectorizer doing odd things. But I think we should strive to convert these to use "get_unaligned()", since code generation is fine. It still often makes sense to have that test for the config variable, simply because the approach might be different if we know unaligned accesses are slow. So I'll happily take patches that do obvious conversions to get_unaligned() where they make sense, but I don't think we should consider this some huge hard requirement. Linus