Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp2660058pxb; Mon, 18 Apr 2022 05:47:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw8a3jzzB5RwWZY+T41cinVxUn2SDs23mfi6UE9TN4/g+896faCRPSxzFEIhA8jHeK6li9w X-Received: by 2002:a17:906:e28a:b0:6d6:e2e9:d39d with SMTP id gg10-20020a170906e28a00b006d6e2e9d39dmr8897571ejb.2.1650286071862; Mon, 18 Apr 2022 05:47:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650286071; cv=none; d=google.com; s=arc-20160816; b=FPEa4nU2/ED/RuDi6aJZeKxzBpx7clivnEIQv7UsjzWwue1orcSQWrV4QNqZHWmltn oHaL7/g/i6RKLilqfawA/lp8MXXjoSi/icm2KrdKmnfUOaBn+6kxd59fQtCcHeypamna tVesfSOc/2bsNs1u2db7sFNALsE7Y6AuvW3kxKSBU1KVQYZ+CRWGKumJd+sgn70hN73+ /cr55NgTzgLXkKN3JxU+zIW4SdODR8mtf6RIWzEolk/0Ht8Yqf7H2BZH0R0QGSOy4bIR 2owZ3QUtS4SQORZb+7mS7IJD2c4RlBConaZ6Y3I6gMBUl8SguM48hmi8GgDQ3HuJhiy4 rH2w== 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=79lomEupTF5D/pVd0UzIYYuaOrxNmBE3CjnZdIIfNbw=; b=jGj5aLrNWJcGoFRGQdErMjPuCrk1ZjOcF0vqwx9VmbGLjP0ftAVFRun9DClswHmznS nFbMA9nPZGyD9MlnlTTGf4hwyjwNda/FG9ErJZqMYkfI9xflXwG5sfgnaClGGvJ9shMc 6F7t4+PHHoiZRQXOKxCLUPfEdbwHWNedZbWP76cAENsTksSRjwpVOcHf99BQnNKWoFhF 7VwOFTtZVHtNm7BSF9NGiP8LvbfgoQsnR36hRnjOXIl4+/OkSodppIfBMHJejp4m50XV efRoS2E1VnTVE48lB/LUoMPtfXSVoAjDFmFQZnF/fLBtXxa73k/cgO72j0Zr6UWZjvmn SXNQ== 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 z17-20020a056402275100b0041d7958aec0si7813922edd.260.2022.04.18.05.47.28; Mon, 18 Apr 2022 05:47:51 -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 S233631AbiDQIdy (ORCPT + 99 others); Sun, 17 Apr 2022 04:33:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54184 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233628AbiDQIdx (ORCPT ); Sun, 17 Apr 2022 04:33:53 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2CAB020192 for ; Sun, 17 Apr 2022 01:31:18 -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 ams.source.kernel.org (Postfix) with ESMTPS id 7393EB80AAD for ; Sun, 17 Apr 2022 08:31:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 03810C385A4; Sun, 17 Apr 2022 08:31:12 +0000 (UTC) Date: Sun, 17 Apr 2022 09:31:09 +0100 From: Catalin Marinas To: Herbert Xu Cc: Ard Biesheuvel , 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=-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 Sun, Apr 17, 2022 at 04:08:22PM +0800, Herbert Xu wrote: > 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). Not with my series, the non-sharing of cache lines is preserved. kmalloc() still returns objects aligned to a cache-line. ARCH_DMA_MINALIGN was chosen as the cover-all value for all SoCs supported but I want to reduce the kmalloc() alignment to a cache line size if a platform has a cache line smaller than ARCH_DMA_MINALIGN (most arm64 SoCs have a cache line of 64 bytes rather than 128). -- Catalin