Received: by 2002:a05:6a10:83d0:0:0:0:0 with SMTP id o16csp43117pxh; Thu, 7 Apr 2022 13:26:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwR4IgfpkxKEqA7eHBcgkpwjHiyq+fm7alakGzUFkccmwKzrdIU2FBHc4i9eZNvL/kUrv3J X-Received: by 2002:a63:7d49:0:b0:378:907d:1fc7 with SMTP id m9-20020a637d49000000b00378907d1fc7mr12692157pgn.252.1649363181567; Thu, 07 Apr 2022 13:26:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649363181; cv=none; d=google.com; s=arc-20160816; b=Oz14IGwhWwLzQFql1ikpX6Ip47cCQvMTtL2frOuHOT25DsDmfXSlodB5drioU0RYtP 3p6Qimv9J7AGEExsX3Iy0XQYt76YVUDpZbPg3Ai7K+Q9BuJQWPa6qJhETUxv9usrG8Nn VhnuDtB6mbAN514moLZoZA0TQOC0zCrCufp4MSco4XRIQyBuwclTTXOyWjcUP7H5JD4G dtvdtZL079cenyCEOEl+K47tGt1lssTdDwqLiAwjbdXYm10uLThtes2ijkx6IEiBUyin q77UoF3s9gfz/Oc2aLH1WyehnZXdCzrEskb/ietA0vWFTP+5vnMXTHIh0M4BduHGBrK/ h/1Q== 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=E6Ev7blcHibxt4QrE14OlVoKgZfCOo8YZprXV+hduag=; b=OCTI7AloEg1nbbY30aEQnqB5XjKrr1ubLR2RVTskf1FqrjOw68unUIfYLzS8QXRFtB 6NcMAJ11rV48rnoptbMepCpxxSqMvPoVEKYYtwnH1LvUxpOEc2J3SC+OoA7s61OBwuVb xXh1fpeU3HXW4V13PThTbp/ZKbq56oWA2lR4Dm03dEFOT4Bhe32VBnwDCvUl1Q6+0JFv GASNa4zCjAAZPCNrMXJSwts38hMc7WcSoL3k3ETMVIzsBBxlvovRdhL7GSZCBQ+9NnZm B4ogShZNMZp589ZzKnEbEioFjVkIOHInlCICanLzm7g6Kq7alLEHxDbVEgxZJrXQCwIx KsWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=GgOM1DdL; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id d2-20020a170902854200b00153bb80673bsi667546plo.52.2022.04.07.13.26.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Apr 2022 13:26:21 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=GgOM1DdL; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C160635785B; Thu, 7 Apr 2022 12:41:28 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235567AbiDGKCy (ORCPT + 99 others); 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-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" X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE 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 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.