Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp2102609rwb; Sun, 2 Oct 2022 15:22:32 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7SBLaabI+I2Vjypi+Ox3qzrP6D7gyypkGe8DkFQQ4rEqOoBRt9zr39hlz9lZCOQi8zTQix X-Received: by 2002:a17:902:d4c2:b0:17c:9872:4b50 with SMTP id o2-20020a170902d4c200b0017c98724b50mr12562964plg.146.1664749351981; Sun, 02 Oct 2022 15:22:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664749351; cv=none; d=google.com; s=arc-20160816; b=Af9+O2BVw+lDdTO5xXRvA3vM5bcETBBBj+7L9vwEzGXHNzIwZSdJ6kz7qYIQW5sa/r qhIESP1cSggYC/B/YEfA7m7i3baZmad41B76wwjggPHSO9JQNRimYeOU8PdawjDRaLEL NjAJViO8qhoQtiE1lUGs2acHv6474sYFT2AHLeZzCCY/FEzo6+XyfpQSx+3eTocbFUVP YyuzSocwXTWiLA9YrQBu6iwQoZzUC10r82hKIF2zeKOvVeQ8lf6oJT+AEd+lidsxuV0I Qk2ZeOjqh3vhl0KgcZj1fa+A+p6qUZG0mM7eTm7TurMOqxkLd5t7FKL0mYRe1gul5IFq kbyg== 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=uHQJYN/m4RTMq382SFNcZ29dVno9Xk6EWkyV/FTNDgk=; b=GsPz5gAausUyqfJV4AmodIXyPaUxtmZcf7KTg4vLUXE1JAH5mHIcip14lPq59cKjdd AgBU4C+f6gs9jCK4VWj/mP/VPPGOMnTrOL1Qp7V+UnHbAYYSpGR2Y28T+ONaztLSL7t1 iYW6hvImuaB0vtBC7U9+gFrYNLyneyH3F1j4Cxh0zgl+PWYrNIwdMC9KHb5sRID0n0ME TtZcWmaXEfSoK6qfOfxEzhNcliF4mcJPdBtAaoPwznHcsGkaEXNeXp89tzjshf+1Z1hF gQAwNgS5CcAddt0gzIFAunDhRmeRvxT5S/noWTkOA9n28cM/MdUqkftgtthxiEk7dl48 8KKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=skUXldGK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ba3-20020a170902720300b0017540816378si8003122plb.48.2022.10.02.15.22.20; Sun, 02 Oct 2022 15:22:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=skUXldGK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S229693AbiJBWJI (ORCPT + 99 others); Sun, 2 Oct 2022 18:09:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47920 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229714AbiJBWJE (ORCPT ); Sun, 2 Oct 2022 18:09:04 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B432638685 for ; Sun, 2 Oct 2022 15:09:01 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 279F9B80DD8 for ; Sun, 2 Oct 2022 22:09:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CF317C433D6 for ; Sun, 2 Oct 2022 22:08:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1664748538; bh=HfH4SXjoakBAXCnyUt76Zo2AktATIjMnXSVMSbQybwI=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=skUXldGKEjsSoWONew9/z6Em/MECHl3mpGGkv9FrbVUHZwZ9kC0pLmEQtX++slog7 gorbTNqT6LY+1JEmP2ORe0mvtbJlQP9Gpx5ms6TnXCiAxwr+rSBizR6eeyaODCbbI0 nrTVslhUkbeeYkl2wWpQwsfsStcax13Ra6McM28l/Tt0/NqHVNH9bD7ilsDF8hk00u WTQgTznDp7QMWKeuHhI27ivlgyt7KNKP5SLQM5tVp81xxK1h4yJvAyiULUD8EC6qkm /C1PCC4npfhqjlTV8/uc65LbKRPZY3iN7XvKAQ4TAAaWIqHC9AYc4uJ6mUIZyIsWTH 9aDc+3wNjsMbQ== Received: by mail-lf1-f45.google.com with SMTP id bu25so14186159lfb.3 for ; Sun, 02 Oct 2022 15:08:58 -0700 (PDT) X-Gm-Message-State: ACrzQf2KiuYr2qgJlNmMckB5iGJCUUlrp4tUoA3vc9SYST5Uof7VAB7t x6iNGjXSXCYQ0fBy0IfMbrjoNNlep5g4LkoHYbg= X-Received: by 2002:a19:c20b:0:b0:4a2:40e5:78b1 with SMTP id l11-20020a19c20b000000b004a240e578b1mr411616lfc.228.1664748535957; Sun, 02 Oct 2022 15:08:55 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Ard Biesheuvel Date: Mon, 3 Oct 2022 00:08:43 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 07/10] crypto: Use ARCH_DMA_MINALIGN instead of ARCH_KMALLOC_MINALIGN To: Linus Torvalds Cc: Catalin Marinas , Isaac Manjarres , Herbert Xu , Will Deacon , Marc Zyngier , Arnd Bergmann , Greg Kroah-Hartman , Andrew Morton , Linux Memory Management List , Linux ARM , Linux Kernel Mailing List , "David S. Miller" , Saravana Kannan , kernel-team@android.com Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, 2 Oct 2022 at 19:00, Linus Torvalds wrote: > > On Sat, Oct 1, 2022 at 3:30 PM Catalin Marinas wrote: > > > > The "force bouncing" in my series currently only checks for small > > (potentially kmalloc'ed) sizes under the assumption that intra-object > > DMA buffers were properly aligned to 128. So for something like below: > > Ahh, so your forced bouncing isn't actually safe. > > I would have hoped (but obviously never checked) that the force > bouncing be made really safe and look at the actual alignment of the > DMA (comparing it to the hardware coherency requirements), so that > alignment at allocation time simply wouldn't matter. > > At that point, places like the ones you found would still work, they'd > just cause bouncing. > > At which point you'd then have a choice of > > (a) just let it bounce > > (b) marking the allocations that led to them > > and (a) might actually be perfectly fine in a lot of situations. Non-coherent DMA for networking is going to be fun, though. Fortunately, we'll only need to bounce for inbound DMA (where the cache invalidation might otherwise corrupt adjacent unrelated data), and for inbound networking, the driver typically owns and maps the buffers, and so in most cases, it can hopefully be easily modified to round up the allocations and the length values passed to dma_map_xxx(). And for outbound, we can just clean the SKB from the caches without the risk of corruption. It does mean that there is likely going to be a long tail of network drivers that will non-negligibly regress in performance and in memory footprint (as the entire RX ring will be double buffered all the time) until they get updated. -- Ard.