Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp1926632rwb; Sun, 2 Oct 2022 10:45:02 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5hIoUY6A0yvjKdIqESu3iCZ/7Lwau5l95IcG9VTgIrsRnsrb+ukitHubIZn7VfZ81gtQEf X-Received: by 2002:a17:907:168d:b0:782:68d1:f091 with SMTP id hc13-20020a170907168d00b0078268d1f091mr12791495ejc.714.1664732702635; Sun, 02 Oct 2022 10:45:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664732702; cv=none; d=google.com; s=arc-20160816; b=mnIZ2ubaXhDowHFyrLewsXmWiVdiBMc3PypSadhgPAGMm6kQrwtDqo0qA5eDIXdssp Z7hcQCcnQTCStAVUlk9+cKCb4tXophX6/LU3I3tr1iVKnSZJRNftVNtHG4NGPKe5deHg jT3V3s0ij6SJ8mktV2mmElswIjUrop53q5JA+qWY7v8Kh5i6k4yFkXTQrDRFAQK2QTBB kpOz87P6+WhZFDA32wq5OFjCBpOFJZoKar/UUDyEQ3RbA3poijmzjAYoyE8HBe6ukie3 hPHoPRZWLtNXR/G4EGjfEwu5VVFPwQL9dRSvqpORu3Dx1kIKpxdCKjQoHegJdHdA0cd6 pAIg== 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=QgT+0pE5+Jxg1Db0pjr/6GUR7lMe+WJC6D7WdnY3dDY=; b=Y83AtSNbNyCM5ZM6GWnSrlgk+0brWrARleXYW1VH1upwiXApDA03HnbDz/2E5V3Uja gjdsrrLJU7ln8rd6+OdM/wUWfi+OARSaqx1gGtSp/c8eYwBJbjw/Ly/aTUsKBLsvYNkB FkOj6YeZ+TwIcLV8q7NDfKdi8k2Q8HhEmC1CTJtxFCkSvuD8dTRaJ84oS8oOinPgNzUb iZXafehmnanzP2OUGP2PiYtMV/yOCuJnngh02c9xvpR6wuS1XZM2Fzzm7YaXxZKsCTHF XlTNw4cONH4mSkaL97KWhryuVki0GpP2yeaTvRNoAikxvCX1dinwmJvhPAWuDgQeUwvb DsNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=Nzqj81O4; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id lb8-20020a170907784800b0077951929340si6603577ejc.271.2022.10.02.10.44.37; Sun, 02 Oct 2022 10:45:02 -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=@linux-foundation.org header.s=google header.b=Nzqj81O4; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229699AbiJBRAf (ORCPT + 99 others); Sun, 2 Oct 2022 13:00:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36906 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229734AbiJBRAd (ORCPT ); Sun, 2 Oct 2022 13:00:33 -0400 Received: from mail-oa1-x2a.google.com (mail-oa1-x2a.google.com [IPv6:2001:4860:4864:20::2a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4E32C13DEF for ; Sun, 2 Oct 2022 10:00:32 -0700 (PDT) Received: by mail-oa1-x2a.google.com with SMTP id 586e51a60fabf-13207a86076so6468772fac.3 for ; Sun, 02 Oct 2022 10:00:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date; bh=QgT+0pE5+Jxg1Db0pjr/6GUR7lMe+WJC6D7WdnY3dDY=; b=Nzqj81O4P6j0wFJ6dCNqILguy0U5N+2OxhQjCFfKYDAC6M6UpY7hAq5wpd1cfw2nTd hSmo4qXcfU8ubm0sRDL10bN31XVYLOYrsXrrc2Oa+eXTJc9tQv8ii7M5hGagWac1Lm3y j4zJLaHZhsFQufPX3m6IxXYXKG+dcxt9QVs7k= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date; bh=QgT+0pE5+Jxg1Db0pjr/6GUR7lMe+WJC6D7WdnY3dDY=; b=KVHFJo152FYjkAqiNVwZtJPS3ziMljd27cBLsBaUawLQ6q8RQSwcPOvcz+2V0mHPMT WxrXyJXwbGOE4QvH/n7NYTBtvBbzrDGxeRno62Zz9XjetP4MRah350vdcobq9thKAzhQ 8wCULv7z5P0zx4/L/itLgMuGdkSkqQma/laeMCgs65lpLbsRxc9iqRpjGM7uvtuXz5pJ u6HFUWl+b7IGR3VwaoyAeoPEILmobbkZamP1ZeNLZGhDtaJrFBBeEXY7rdIApGyrqbKE /ahpqGdd2Szs1sqKUfYFG2kWNXSDPq8pILACHc33qf4kdPFJeu5xxYRFO6eInMGuRWm+ krbw== X-Gm-Message-State: ACrzQf0Q76eo79gxMUaH2tGtJBIHI/o5eWkbJc9iylp6QJfs1grVfc+0 aS8wr/HrrPr3Z49GD73luvAVsEI8nijHkQ== X-Received: by 2002:a05:6870:891a:b0:130:ea0f:c071 with SMTP id i26-20020a056870891a00b00130ea0fc071mr3661178oao.251.1664730030732; Sun, 02 Oct 2022 10:00:30 -0700 (PDT) Received: from mail-oo1-f53.google.com (mail-oo1-f53.google.com. [209.85.161.53]) by smtp.gmail.com with ESMTPSA id x16-20020a9d4590000000b00655ca9a109bsm1883051ote.36.2022.10.02.10.00.28 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 02 Oct 2022 10:00:29 -0700 (PDT) Received: by mail-oo1-f53.google.com with SMTP id t4-20020a4aa3c4000000b00475624f2369so5434897ool.3 for ; Sun, 02 Oct 2022 10:00:28 -0700 (PDT) X-Received: by 2002:a05:6830:11c6:b0:65f:913:ff93 with SMTP id v6-20020a05683011c600b0065f0913ff93mr2396114otq.69.1664730028572; Sun, 02 Oct 2022 10:00:28 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Linus Torvalds Date: Sun, 2 Oct 2022 10:00:12 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 07/10] crypto: Use ARCH_DMA_MINALIGN instead of ARCH_KMALLOC_MINALIGN To: Catalin Marinas Cc: Isaac Manjarres , Herbert Xu , Ard Biesheuvel , 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=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=no 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 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. That's particularly true for the "random drivers" situation that may not be all that relevant in real life, which is a *big* deal. Not because of any performance issues, but simply because of kernel developers not having to worry their pretty little heads about stuff that doesn't really matter. In fact, (a) might be perfectly ok even for drivers that *do* matter, if they just aren't all that performance-critical and the situation doesn't come up a lot (maybe it's a special management ioctl or similar that just causes the possibility to come up, and it's important that it *works*, but having a few bounces occasionally doesn't actually matter, and all the regular IO goes the normal path). And (b) would be triggered by actual data. Which could be fairly easy to gather with a statistical model. For example, just making dma_map_xyz() have a debug mode where it prints out the stack trace of these bounces once every minute or so - statistically the call trace will be one of the hot ones. Or, better yet, just use tracing to do it. That would allow us to say "DMA is immaterial for _correct_ alignment, because we always fix it up if required", but then also find situations where we might want to give it a gentle helper nudge. But hey, if you're comfortable with your approach, that's fine too. Anything that gets rid of the absolutely insane "you can't do small allocations" is an improvement. Linus