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 65228C433EF for ; Sat, 16 Apr 2022 09:42:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231283AbiDPJoq (ORCPT ); Sat, 16 Apr 2022 05:44:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56144 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229705AbiDPJoo (ORCPT ); Sat, 16 Apr 2022 05:44:44 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E16CB165B0 for ; Sat, 16 Apr 2022 02:42:11 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 7104360DBA for ; Sat, 16 Apr 2022 09:42:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8477BC385A3; Sat, 16 Apr 2022 09:42:08 +0000 (UTC) Date: Sat, 16 Apr 2022 10:42:04 +0100 From: Catalin Marinas To: Linus Torvalds Cc: Ard Biesheuvel , 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" Subject: Re: [PATCH 07/10] crypto: Use ARCH_DMA_MINALIGN instead of ARCH_KMALLOC_MINALIGN Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Apr 14, 2022 at 03:25:59PM -0700, Linus Torvalds wrote: > On Thu, Apr 14, 2022 at 12:49 PM Catalin Marinas > wrote: > > It's a lot worse, ARCH_KMALLOC_MINALIGN is currently 128 bytes on arm64. > > I want to at least get it down to 64 with this series while preserving > > the current kmalloc() semantics. > > So here's a thought - maybe we could do the reverse of GFP_DMA, and > add a flag to the places that want small allocations and know they > don't need DMA? I wonder whether that's a lot more churn than trying to identify places where a small kmalloc()'ed buffer is passed to the DMA API. DMA into kmalloc() buffers should be a small fraction of the total kmalloc() uses. For kmem_cache we have the SLAB_HWCACHE_ALIGN flag. We can add a similar GFP_ flag as that's what we care about for DMA safety. It doesn't even need to force the alignment to ARCH_DMA_MINALIGN but just cache_line_size() (typically 64 on arm64 while ARCH_DMA_MINALIGN is 128 for about three platforms that have this requirement). Functions like dma_map_single() can be made to track down the origin of the buffer when size < cache_line_size() and warn if the slab is not correctly aligned. -- Catalin