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 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A46EBC433F5 for ; Sat, 16 Apr 2022 09:43:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=2zajB4+Ihzz/Y5RGo8fc7Fevdm2/GgyzpyLGyvktDVs=; b=pc98pJxk91U66J 1eSaVd400ZctlEY/ZwBhOzbveUjqUk17i6o8M7KrezJUqWilbgONrQdGQr8YUJEx0sgdiqMwXioaQ XJIMXE4iImx2D8Vl1xFrNPZkI32Rwur40mMYMYQu6wLKtZ5lRr1euT0dM2vzpTEMSCi5/l83dO0UX WBGARoNiECLBzENfL9Z/9svlxfojSMCab1RWSLIn1hgbRoyND5eDdYshBCpUJM23VsCfsPn21y0Jz NcKMz4LCYjSe4ADVYa9BnTF5IQX7zqR/Iykdnc6w2yHcXk0qPyCpX/DgyZ4L0CalonkP76kJyG9yz ++xhQs8SSpeSwesBXE5A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nfewb-00Cfb4-TN; Sat, 16 Apr 2022 09:42:17 +0000 Received: from ams.source.kernel.org ([2604:1380:4601:e00::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nfewY-00CfaA-6o for linux-arm-kernel@lists.infradead.org; Sat, 16 Apr 2022 09:42:16 +0000 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 1076EB81D17; Sat, 16 Apr 2022 09:42:12 +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-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220416_024214_427887_6A79766B X-CRM114-Status: GOOD ( 19.31 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel