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 2AD7EC433EF for ; Fri, 15 Jul 2022 23:10:52 +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:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=2VpbmUjcr75l1l7Gvtyo6xU5kb3JFAfVXAcICGtuVZc=; b=Ib518tpDeh8uci MfGZ0EDEgkwL0qhLmBXIn6a9oKOPfssowzNC/mVdgxO075WehEynCA4mDxWJJx9vhM7elOHY/yB5L yPXtinUwZVQIO6TUlcCORYobIPmL6x7TCFLNAxnro2Vs7k7JFqh7mT9d+BTO9W6jJo8tssDOV+SAq MfBu4THW8gnkheb8JWfStWvitFhe5FNq3nbomRYYqqk4tnylUYCPPDlS389xGmckTBl1QYWnP+hzV 1st4JL+XKfxfwypkPvajwZxTDR64bw679kYcYeCL0tnrT46wGz86sIQ9r5LIJtadjnMrsPhSkc8pK gJYn7KM/65cblenXlDWQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oCURD-00B0MG-Mq; Fri, 15 Jul 2022 23:09:36 +0000 Received: from mail-pf1-x42c.google.com ([2607:f8b0:4864:20::42c]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oCTij-00Akvc-4t for linux-arm-kernel@lists.infradead.org; Fri, 15 Jul 2022 22:23:38 +0000 Received: by mail-pf1-x42c.google.com with SMTP id l124so5754023pfl.8 for ; Fri, 15 Jul 2022 15:23:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=h08OBDtouOlnPaz6Mk89TkUqXNC6lVw4WMryRnoY4iQ=; b=SWBq670YGdUDUrz+LfGaVqhLNtXSduF+1kAy8tHbqCMHxzTK2rLblqfH6+CYEvdUam v/yPvYMRRAlLYRePmgUlEhwaZDQzzCUf0nqX9tCSngUrFJ3YHZC9ejmTonEQ50Z+I/Yj c1sewCP8LAbIU2jpaun7nKp+rgKHD72Lizf+bO4mumGPe2vWfA67JxK3kb+IEdYq8TNn pIdzdO2OTit8/qw1V54APG3u1c8H1kvrqDVs+q/aXt73IJUVDKz0ARo02W3lSYb3Qefq EDluaP4iCN+GLO9VxvShkAf0mAA5qQAoOdTV4B8ZwfWJRk5kK9g44irFj6vG73BckUH8 N1Bg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=h08OBDtouOlnPaz6Mk89TkUqXNC6lVw4WMryRnoY4iQ=; b=NDXJnplaiOTEHzDwEMJ4G3VupbIeDdac/kU5UxML1yDPyhrZ8QmsRM1HGdN0ZTLMYe 7Gw4ky9HVvCYJLSZc9VyonD/7MGH/cbBBCfJcw0/vGbgIcs4RC8BL7zB59n7NqdN1aaB MYukyLsedyDI3Ivilw5yulnkddU84o/m77CoSjKZvi+/5BsGvgQZyh6pzlVC4gO00G2B +PRhHkwquqp8R0+qm/Zo1IrY+RDF1qZF8Xni9ycYU/N0DeMWKVz+zRMbZIiyO5sInnm6 ERD6GT2+iBX4LPeoZ0+4o/YmSsxFgnwf7vKrV9yxMZOBLUi3hVQ3nh6zStJYYPKuRaB7 a0GA== X-Gm-Message-State: AJIora/k8+x3iWITyrrTs1E1QG8uHonPS7LTqu13pBRJdGDSsciPM52S sTHXYt1T4Nh92m86Wgb6rJvyOA== X-Google-Smtp-Source: AGRyM1t7Ufq+16dtrPJCG7vL3sPupbfNcIcgSZ5v9myXTI8I39QsDiDTWJovZbADGjskDpoUBCWLQQ== X-Received: by 2002:a65:5688:0:b0:3c2:1015:988e with SMTP id v8-20020a655688000000b003c21015988emr14079913pgs.280.1657923811299; Fri, 15 Jul 2022 15:23:31 -0700 (PDT) Received: from google.com ([2620:15c:2d:3:e72f:c983:e093:d463]) by smtp.gmail.com with ESMTPSA id s15-20020a170902ea0f00b0016bf803341asm1972182plg.146.2022.07.15.15.23.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Jul 2022 15:23:30 -0700 (PDT) Date: Fri, 15 Jul 2022 15:23:25 -0700 From: Isaac Manjarres To: Catalin Marinas , Herbert Xu Cc: Herbert Xu , 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" , Saravana Kannan , kernel-team@android.com Subject: Re: [PATCH 07/10] crypto: Use ARCH_DMA_MINALIGN instead of ARCH_KMALLOC_MINALIGN Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220715_152337_224467_2B1BE818 X-CRM114-Status: GOOD ( 24.53 ) 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 Sun, Apr 17, 2022 at 05:29:01PM +0100, Catalin Marinas wrote: > On Sun, Apr 17, 2022 at 04:43:33PM +0800, Herbert Xu wrote: > > On Sun, Apr 17, 2022 at 09:38:40AM +0100, Catalin Marinas wrote: > > > I don't think we need to do anything here. A structure like: > > > > > > struct x { > > > char y; > > > char z[] CRYPTO_MINALIGN_ATTR; > > > }; > > > > > > is already of size 128. Without CRYPTO_MINALIGN_ATTR, its size would be > > > 1 but otherwise the whole structure inherits the alignment of its > > > member and this translates into an aligned size. > > > > No we should not lie to the compiler, > > We won't if we ensure that a structure with sizeof() >= 128 is aligned > to 128. > Right. kmalloc() should return a 128 byte aligned pointer as long as the size of the allocation is >= 128 bytes, and the kmalloc-192 cache isn't present. So, the current behavior that crypto is relying on wouldn't change, so I agree with Catalin that we wouldn't be lying to the compiler if we move forward with getting rid of kmalloc-192. FWIW, I did a comparison on my machine with and without kmalloc-192, and the amount of memory usage that increased from allocations being redirected to kmalloc-256 was about 0.4-0.5 MB, which doesn't seem too bad. > > we have code elsewhere > > that uses the alignment to compute the amount of extra padding > > needed to create greater padding. If CRYPTO_MINALIGN is misleading > > then that calculation will fall apart. I don't think it would be misleading. If all of your allocations are >= CRYPTO_MINALIGN == ARCH_DMA_MINALIGN in size, and kmalloc()--with kmalloc-192 removed--returns buffers that are aligned to a power of 2, and are big enough to accomodate your allocation, then wouldn't they always be CYRPTO_MINALIGN'ed, so your calculation would still be fine? --Isaac _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel