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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9F9A1C433EF for ; Thu, 7 Apr 2022 10:01:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3A26D6B0071; Thu, 7 Apr 2022 06:01:06 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 351AC6B0073; Thu, 7 Apr 2022 06:01:06 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 219F36B0074; Thu, 7 Apr 2022 06:01:06 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0149.hostedemail.com [216.40.44.149]) by kanga.kvack.org (Postfix) with ESMTP id EC50E6B0071 for ; Thu, 7 Apr 2022 06:01:05 -0400 (EDT) Received: from smtpin30.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 9D80E183432DC for ; Thu, 7 Apr 2022 10:00:55 +0000 (UTC) X-FDA: 79329639270.30.DF6BCE7 Received: from mail-yw1-f176.google.com (mail-yw1-f176.google.com [209.85.128.176]) by imf17.hostedemail.com (Postfix) with ESMTP id F19974000D for ; Thu, 7 Apr 2022 10:00:47 +0000 (UTC) Received: by mail-yw1-f176.google.com with SMTP id 00721157ae682-2eb43ad7909so55976247b3.2 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=GS91XQJ9KEV1iTBpb6xMck/NoN424VinWOC0KWaO4MN7gjSXz4OK0hZYq5q8PdlIyL 3Zvlm7ft0KpqsZO+XFtEIhr1jGHBWMlBFkN1tQZzUVf0ETtdUK7Mz/i862MnMc4P0AyW YgIBuoUk10GuvzqkUOLDilGl2AoWtkkEHtMW8BDRInLv4gc6UX6cG9F6RRtpn4R+g7Mh dXXArTPjYwLsdomx3C65zazd7XtPL9/DXk2DmlNH2BQBiBZLQfoLdK61hwq7MOUdzVBS wsWtCIHO8in+FNPlwCEc9Qby4+y8PjGvotRBue+R/vcW6RWQcvwnfRuMhlbogZvXZzGD Qzag== X-Gm-Message-State: AOAM531Veway+VBY/m0oTt9zO/TtPO/GluKHTeRMk5FlBzmu3aDR8ajJ CkXMoc+kWkc4Gn3SNgTroN+bjSS14agzZPjd87WAeA== 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" X-Rspam-User: X-Stat-Signature: xmbemh7jkkor4txwqejs35mp8fetxncf Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=GgOM1DdL; spf=pass (imf17.hostedemail.com: domain of songmuchun@bytedance.com designates 209.85.128.176 as permitted sender) smtp.mailfrom=songmuchun@bytedance.com; dmarc=pass (policy=none) header.from=bytedance.com X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: F19974000D X-HE-Tag: 1649325647-252636 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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.