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 1CA13C433EF for ; Thu, 7 Apr 2022 10:00:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237100AbiDGKCy (ORCPT ); Thu, 7 Apr 2022 06:02:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48314 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234136AbiDGKCr (ORCPT ); Thu, 7 Apr 2022 06:02:47 -0400 Received: from mail-yw1-x112c.google.com (mail-yw1-x112c.google.com [IPv6:2607:f8b0:4864:20::112c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CF2C24553C for ; Thu, 7 Apr 2022 03:00:47 -0700 (PDT) Received: by mail-yw1-x112c.google.com with SMTP id 00721157ae682-2eba37104a2so56396667b3.0 for ; Thu, 07 Apr 2022 03:00:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=E6Ev7blcHibxt4QrE14OlVoKgZfCOo8YZprXV+hduag=; b=GgOM1DdLoxc5bK8Qlz10R0LhEAPbToMvRENNSe/5QtM8XxI6v1RyTk/WVzg8TqruNe 1P9N8a8z5LKP+EBP9jSyGJrkkFZ1sPnmaaSdMuNZ9MFmdllEZ6eE4N8ZfYfZOAbF7Xpu ZPp6WuGbxS96xg8msKumgP2GqiVfedJshtT8A0cxdA7OoojhV8ne4J5enKIEN7VQa3sV L+t2L7ngtAkQctAGqcN9rAEwg964FPUykWvIF9ZdgRUVg4BZoDYWw3nu02yI0VtaSOYr /DrqU/Zf9Jw/eUaHrtgU9HOfIBunbady22c7m8/78vbjnCplxMth+YRIcrGHjqz2mKYa jFxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=E6Ev7blcHibxt4QrE14OlVoKgZfCOo8YZprXV+hduag=; b=afRUwdbGXyFcRTH/ri3USXfx7WvSDP310fxnzGqBRBRP2B/p1dOVA7+GZljirOjpB+ f4DikRTKNn8FM/GAF09Y5Lhv54gqYtU08yo+WtrdIpUS3K9jvCcRhmH4vXza4DLetUwa abqSDkLqwchL0p2b1DYLUSdw51ffh3YGGsmN5U9BzYhIkUnG7GnwyRC2lU5qXKWiLlRr vgZ5t6AK7p/KcPnzasn8FeliAhnahJlTjh6eWcLF0sJSVYb4CC0UMVaV2Hd5I93XsUQt 0I1dlOwHFw2+bpXOKooyjNeX2qnweCQNINRlv2hQs58IlT21TvcuN/8YRkv0/6vo6m1E o4lQ== X-Gm-Message-State: AOAM533FS6EfBojQLqRlSEEEn+w3nEkDBbIGS2kVUz5zyrEuZMYUzBXM T11rdJ1eW6RkTm5rJdX6WH5S8HBx0VAc7opuO/TWI3e6BYmguQ== X-Google-Smtp-Source: ABdhPJy3W5pSmjFRsgmmpgg9SUIB7+1TAzHrvFI6Un0vTSR4I/mqJlc1GpvqT+xDAS5U35/rZNsUDL6nZ1T8HPTTypc= X-Received: by 2002:a81:5dd6:0:b0:2d6:3041:12e0 with SMTP id r205-20020a815dd6000000b002d6304112e0mr10893961ywb.331.1649325647122; Thu, 07 Apr 2022 03:00:47 -0700 (PDT) MIME-Version: 1.0 References: <20220405135758.774016-1-catalin.marinas@arm.com> <20220405135758.774016-8-catalin.marinas@arm.com> In-Reply-To: From: Muchun Song Date: Thu, 7 Apr 2022 18:00:10 +0800 Message-ID: Subject: Re: [PATCH 07/10] crypto: Use ARCH_DMA_MINALIGN instead of ARCH_KMALLOC_MINALIGN To: Catalin Marinas Cc: Will Deacon , Marc Zyngier , Arnd Bergmann , Greg Kroah-Hartman , Andrew Morton , Linus Torvalds , Linux Memory Management List , LAK , LKML , Herbert Xu , "David S. Miller" Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Apr 7, 2022 at 5:25 PM Catalin Marinas wrote: > > On Thu, Apr 07, 2022 at 02:14:15PM +0800, Muchun Song wrote: > > On Tue, Apr 05, 2022 at 02:57:55PM +0100, Catalin Marinas wrote: > > > ARCH_DMA_MINALIGN represents the minimum (static) alignment for safe DMA > > > operations while ARCH_KMALLOC_MINALIGN is the minimum kmalloc() objects > > > alignment. > > > > > > Signed-off-by: Catalin Marinas > > > Cc: Herbert Xu > > > Cc: "David S. Miller" > > > --- > > > include/linux/crypto.h | 2 +- > > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > > > diff --git a/include/linux/crypto.h b/include/linux/crypto.h > > > index 2324ab6f1846..654b9c355575 100644 > > > --- a/include/linux/crypto.h > > > +++ b/include/linux/crypto.h > > > @@ -167,7 +167,7 @@ > > > * maintenance for non-coherent DMA (cache invalidation in particular) does not > > > * affect data that may be accessed by the CPU concurrently. > > > */ > > > -#define CRYPTO_MINALIGN ARCH_KMALLOC_MINALIGN > > > +#define CRYPTO_MINALIGN ARCH_DMA_MINALIGN > > > > I don't think this should be changed since ARCH_KMALLOC_MINALIGN is > > already aligned with the size what you need. > > With this series, ARCH_KMALLOC_MINALIGN is no longer safe for > non-coherent DMA on all arm64 SoCs, that's what ARCH_DMA_MINALIGN will > cover. > > Now, looking at the comment for CRYPTO_MINALIGN, one aspect it covers is > the minimum alignment required by C for the crypto_tfm structure access. > So a smaller ARCH_KMALLOC_MINALIGN would do. But the other part of the > comment mentions in-structure alignment for non-coherent DMA. Here we'd > need the upper bound alignment, ARCH_DMA_MINALIGN. > > I'll follow up on Herbert's email as I think he has a good point on > structure vs kmalloc() alignment. Got it. Now I know what you want to do. You want to set ARCH_KMALLOC_MINALIGN to 64, however, the smallest size of kmem_cache depends on the cache line size at runtime. But we have to know the safe alignment at building time. So we have to make those align with ARCH_DMA_MINALIGN. Right? I think you are on the right road since most CPUs have a 64-byte cache line. Thanks. 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 821F3C433F5 for ; Thu, 7 Apr 2022 10:04:33 +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:Cc:To:Subject:Message-ID:Date:From: In-Reply-To:References:MIME-Version:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=JADlUuUK7kRbNeoyMe6Sh/TydRyP9LjIWlXsjayqhYc=; b=ORggFe2atedmhc MQaemOXDKCvodnvf/3uE8ZeK5ckOQAxF4TYwAs/mFgjuJChs2AYbjHKRFJmCiEYNsX8drKLyOBfeX 3I0jVv5oalqw9pWTGxk72i1PbYqTZAQoPW6/VVnXEeGLxF1XQEJwY+EDVSz0nqz7cdYNVT8T/MweS 1nqrELsJmj9MQphokifoie5lh9bG4nKzkJfu8gwN9dOvuYaP3c5IqJmQ3H3kZI/TGmucXYAsgr5Je ntQfVqkCBCgaq2BnKd3sg6NmQMt8HMRH2NSnvOkaIpRCYdzK4lvgPGA2l/TmaeJnj1TnJmXCPBAbF JIwcvRhPWYvg+mhKakTA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ncOyh-00B6CV-W6; Thu, 07 Apr 2022 10:03:00 +0000 Received: from mail-yw1-x1136.google.com ([2607:f8b0:4864:20::1136]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ncOwc-00B57S-4o for linux-arm-kernel@lists.infradead.org; Thu, 07 Apr 2022 10:00:53 +0000 Received: by mail-yw1-x1136.google.com with SMTP id 00721157ae682-2e5e31c34bfso55512587b3.10 for ; Thu, 07 Apr 2022 03:00:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=E6Ev7blcHibxt4QrE14OlVoKgZfCOo8YZprXV+hduag=; b=GgOM1DdLoxc5bK8Qlz10R0LhEAPbToMvRENNSe/5QtM8XxI6v1RyTk/WVzg8TqruNe 1P9N8a8z5LKP+EBP9jSyGJrkkFZ1sPnmaaSdMuNZ9MFmdllEZ6eE4N8ZfYfZOAbF7Xpu ZPp6WuGbxS96xg8msKumgP2GqiVfedJshtT8A0cxdA7OoojhV8ne4J5enKIEN7VQa3sV L+t2L7ngtAkQctAGqcN9rAEwg964FPUykWvIF9ZdgRUVg4BZoDYWw3nu02yI0VtaSOYr /DrqU/Zf9Jw/eUaHrtgU9HOfIBunbady22c7m8/78vbjnCplxMth+YRIcrGHjqz2mKYa jFxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=E6Ev7blcHibxt4QrE14OlVoKgZfCOo8YZprXV+hduag=; b=LVC79fafn+YySn+sAzbobVhiwvR3LPnYLi24c97+ygNFat4pXsacUs/ZJPW+mtq3gM EWKX9FGrGLiJgLTMTAIvKm6DW6KjneVYv0SjGWOYCidXSDKUzvmqGrOtzf0SDjJqGFnb /2FPsWC5WpxLYSqyk+R/jl4+A2BkNPZxcMU3jTfa8n4XEW2OmfDoddetcPhxgt95f3S8 ZKnApd+ABe5PdtcSplwCrMMY5hOSr+wqbgOfx5vMrGMGN8+uoQsX65OyJH1rdHaKbprZ xj0i0NdmdTC6vRWJDvRnN1OWwXfBr8N+8FbxC6tZaSmeVelWkJOHGHcHrSBR9IClHbWt XRog== X-Gm-Message-State: AOAM5303QR7K7y6sT3hzHA+gqHugjJd+LxaQOII1YvDX/EkCnxQQAx5I MsPjpv4sdNPSIdo2dIsSdtvo9g8CIyIprTEUiioFHQ== X-Google-Smtp-Source: ABdhPJy3W5pSmjFRsgmmpgg9SUIB7+1TAzHrvFI6Un0vTSR4I/mqJlc1GpvqT+xDAS5U35/rZNsUDL6nZ1T8HPTTypc= X-Received: by 2002:a81:5dd6:0:b0:2d6:3041:12e0 with SMTP id r205-20020a815dd6000000b002d6304112e0mr10893961ywb.331.1649325647122; Thu, 07 Apr 2022 03:00:47 -0700 (PDT) MIME-Version: 1.0 References: <20220405135758.774016-1-catalin.marinas@arm.com> <20220405135758.774016-8-catalin.marinas@arm.com> In-Reply-To: From: Muchun Song Date: Thu, 7 Apr 2022 18:00:10 +0800 Message-ID: Subject: Re: [PATCH 07/10] crypto: Use ARCH_DMA_MINALIGN instead of ARCH_KMALLOC_MINALIGN To: Catalin Marinas Cc: Will Deacon , Marc Zyngier , Arnd Bergmann , Greg Kroah-Hartman , Andrew Morton , Linus Torvalds , Linux Memory Management List , LAK , LKML , Herbert Xu , "David S. Miller" X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220407_030050_246672_F9E4DADD X-CRM114-Status: GOOD ( 28.70 ) 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 7, 2022 at 5:25 PM Catalin Marinas wrote: > > On Thu, Apr 07, 2022 at 02:14:15PM +0800, Muchun Song wrote: > > On Tue, Apr 05, 2022 at 02:57:55PM +0100, Catalin Marinas wrote: > > > ARCH_DMA_MINALIGN represents the minimum (static) alignment for safe DMA > > > operations while ARCH_KMALLOC_MINALIGN is the minimum kmalloc() objects > > > alignment. > > > > > > Signed-off-by: Catalin Marinas > > > Cc: Herbert Xu > > > Cc: "David S. Miller" > > > --- > > > include/linux/crypto.h | 2 +- > > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > > > diff --git a/include/linux/crypto.h b/include/linux/crypto.h > > > index 2324ab6f1846..654b9c355575 100644 > > > --- a/include/linux/crypto.h > > > +++ b/include/linux/crypto.h > > > @@ -167,7 +167,7 @@ > > > * maintenance for non-coherent DMA (cache invalidation in particular) does not > > > * affect data that may be accessed by the CPU concurrently. > > > */ > > > -#define CRYPTO_MINALIGN ARCH_KMALLOC_MINALIGN > > > +#define CRYPTO_MINALIGN ARCH_DMA_MINALIGN > > > > I don't think this should be changed since ARCH_KMALLOC_MINALIGN is > > already aligned with the size what you need. > > With this series, ARCH_KMALLOC_MINALIGN is no longer safe for > non-coherent DMA on all arm64 SoCs, that's what ARCH_DMA_MINALIGN will > cover. > > Now, looking at the comment for CRYPTO_MINALIGN, one aspect it covers is > the minimum alignment required by C for the crypto_tfm structure access. > So a smaller ARCH_KMALLOC_MINALIGN would do. But the other part of the > comment mentions in-structure alignment for non-coherent DMA. Here we'd > need the upper bound alignment, ARCH_DMA_MINALIGN. > > I'll follow up on Herbert's email as I think he has a good point on > structure vs kmalloc() alignment. Got it. Now I know what you want to do. You want to set ARCH_KMALLOC_MINALIGN to 64, however, the smallest size of kmem_cache depends on the cache line size at runtime. But we have to know the safe alignment at building time. So we have to make those align with ARCH_DMA_MINALIGN. Right? I think you are on the right road since most CPUs have a 64-byte cache line. Thanks. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel