Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp2638640pxb; Mon, 18 Apr 2022 05:19:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJySYnifFEnkzECzI6vEfDO09zYisgx7GapIvpxmmyFA5q9Zo4eO5xJ+WMMvkHmSfsMjsRBO X-Received: by 2002:a17:902:b106:b0:159:5c6:cb53 with SMTP id q6-20020a170902b10600b0015905c6cb53mr2701296plr.99.1650284385476; Mon, 18 Apr 2022 05:19:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650284385; cv=none; d=google.com; s=arc-20160816; b=qOxL2S1HpI9EHK+pPNCKWzN+8g9VEPobrnAy6hCavlzL4BAzeWiDQZLwDVDd8sr6IM +SKHG6BUsv6n/VLRMvg7cfc8fkL1aRnOxzB8id3plc3Lj54dGaibixssbwOutZNQ4rN7 aePSb0BI/x1ncdzCp4Da2idF+XwvLYjG4bg/qEuZ+mZk5ydxzT60FHpeM8Us11Q2nQ9V Moon+LZq4xd7sZ5KcClv4J8tLyyOs6c2OQxZYyFR0OfvoQsROsJBKLHf6IxJnF66zHfV FZTphBC8gqHKhu1UYtOlNJcXXRHHtidh7AB8w5HWoNHnTk6c6dv5V3bbywhAozj9hGBZ KQ/A== 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=TRouDhZGX6ZPMUXwjsOP/Kkd5xfjgvoW0ZFBLDfg61s=; b=oWeqctWx+ZZ0rALiFDHpBJ4Iwh4hq5tDJknQ5BMqGkul6NDB+3mmzdG6zTrHKRIDXN S+bRuU30LdkLEhLXQN6Eyh87hWPGpNLe0s/DXPZZ6ubxYExemwX8xZ9pjjNGv2IkNSql rxA/BPLAdmkASZsjxCVzucj278gI4CbdeQQqLR0hjne6mqjlvVFXnow1ntTS/lypjhhZ O4DQ8Ew5GT1ugef/v0+slf3xYDfQa2/IdpHVc8bmxovf7fqV2NqaDFQf+u8QQ+Vnqc+p k/tjZH3RcKfHKIxBUSsa83Re1Oc3fOUgxIbwbcD3dNOuT0OHNFrF1gFHMT9r5TG7uK9q rWHQ== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d5-20020a636805000000b0038265eb37fasi8785611pgc.780.2022.04.18.05.19.30; Mon, 18 Apr 2022 05:19:45 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233309AbiDQIL1 (ORCPT + 99 others); Sun, 17 Apr 2022 04:11:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54128 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230085AbiDQIL0 (ORCPT ); Sun, 17 Apr 2022 04:11:26 -0400 Received: from fornost.hmeau.com (helcar.hmeau.com [216.24.177.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 436433337F for ; Sun, 17 Apr 2022 01:08:50 -0700 (PDT) Received: from gwarestrin.arnor.me.apana.org.au ([192.168.103.7]) by fornost.hmeau.com with smtp (Exim 4.94.2 #2 (Debian)) id 1nfzxG-003jAv-JV; Sun, 17 Apr 2022 18:08:24 +1000 Received: by gwarestrin.arnor.me.apana.org.au (sSMTP sendmail emulation); Sun, 17 Apr 2022 16:08:22 +0800 Date: Sun, 17 Apr 2022 16:08:22 +0800 From: Herbert Xu To: Ard Biesheuvel Cc: Catalin Marinas , Will Deacon , Marc Zyngier , Arnd Bergmann , Greg Kroah-Hartman , Andrew Morton , Linus Torvalds , 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=-1.9 required=5.0 tests=BAYES_00,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 Fri, Apr 15, 2022 at 01:38:15PM +0200, Ard Biesheuvel wrote: > > If this is the case, things are already broken today. We never take > ARCH_DMA_MINALIGN into account when adding the driver ctx size to the > overall allocation size. No it's not broken because kmalloc guarantees alignment. For example, if ARCH_DMA_MINALIGN is 128 bytes, then kmalloc will always return a pointer that's 128-byte aligned. That guarantees this object and the next object are on different cache-lines. If you reduce the kmalloc minimum alignment to 64 bytes, then the two neighbouring objects can share cache-lines, even if each object is bigger than 128 bytes (e.g., if they were 192 bytes each). Cheers, -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt