Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp1480426pxb; Sat, 16 Apr 2022 09:58:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwty8j4Y53iXZCvNRp1pItPice/2QG9GFPVT8pZ2i3yZZvQUZUOAKHjCQeDWY+5Pp/rYvEa X-Received: by 2002:a17:903:248:b0:155:e660:b774 with SMTP id j8-20020a170903024800b00155e660b774mr4230534plh.174.1650128310816; Sat, 16 Apr 2022 09:58:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650128310; cv=none; d=google.com; s=arc-20160816; b=claE0T5IgCbOBXZ9nk8pPrUEpzssxBE06iVhH6rDd+pr+L2E1D7vXxVq0YNLUuSq7h l5VavrgUBgpi3WMfrj3nfxbMu1xaOzReqRCbTZ5yS5YIlfF8Jc3ttfeSsup8dQFrV4w1 5LyKTx8bbWhA0ZbdrIJliRE7jEuYe5WwgJ1mbBT0crMmMszmT/uQgo7Yl8XcVdOe26N6 oBPTHC8lrMD+Kme/tLPSeO4l+PFIUoyE3K/qCVUjKAaJSOnwypgnWTV7dr+1rSDq6f2U axSLR075nhVzfpGDNlaZ9MMIuIWKGnxK5SC9P/EXml8ZLsHAFWirKHWq3nnhHQFr6EeQ abqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=pnm/Re+gmo61nvSQ8cTHd5N/x8RaK68CvfcRGH70h2c=; b=oypGqpZXQjtHbv6TuTwreoPSrEeU/Gh1PQ2oUqaYDk1wUumkf5q7vfboS8AnFDiwxe qXUXL4dB06k6lY2tXh3O8axba1jTmD81aQTnJvTkAZAY+jJDIo6JIcnndOb7gdnU2VnK G7/zjCDmPqWWKopg4q7PxMV3zJxrPzaaILDJFA00beMLE/VUL64bXQH3nznvEWRWaqAH rL/rf4kt3EximMhrrPNkL9v/npO+kFrJg35b72MRmxkUdI9IkSJi1qU1E56pEVQ8mgpW g+pQXFxFHRBvTCECZhrXSw/B5yegruttMYDSx4pwpXLw9JTsShEdhfKGG35+tFeDhuUe 0RvA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h70-20020a638349000000b0038253c4de24si3970172pge.186.2022.04.16.09.58.14; Sat, 16 Apr 2022 09:58:30 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231266AbiDPJoq (ORCPT + 99 others); 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: X-Spam-Status: No, score=-6.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE 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 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