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 3EFBBC43334 for ; Fri, 15 Jul 2022 22:23:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4CA14940216; Fri, 15 Jul 2022 18:23:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 478CB9401FB; Fri, 15 Jul 2022 18:23:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 33F7C940216; Fri, 15 Jul 2022 18:23:33 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 208199401FB for ; Fri, 15 Jul 2022 18:23:33 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id CE5B7ABA for ; Fri, 15 Jul 2022 22:23:32 +0000 (UTC) X-FDA: 79690761864.19.B4E5990 Received: from mail-pg1-f174.google.com (mail-pg1-f174.google.com [209.85.215.174]) by imf27.hostedemail.com (Postfix) with ESMTP id 6085F4008A for ; Fri, 15 Jul 2022 22:23:32 +0000 (UTC) Received: by mail-pg1-f174.google.com with SMTP id q16so2478709pgq.6 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=sjbJ+iLVyGnQRVefjtrl2iZa+Skk6dUa4UQDaZ2YvhhN4+68DgIkgFCIHfLRftFLoH zCdw/kq0hoSCvv9O/HDbfZp7Jb5zCK2f8NNPDpIUyBdogi3NuWo6DJfGcAIPmYKnfXNK 6AfBKKbyx5bLX1QPX7lpSsCvlifgjI7S/1AjjCh490QtE7rUNwbcx8zcT7P0zQGfB6kx QM9aT3jF95mSbO0KoeYM/vndNyRWmS0YXrNHVBEzrIrVZElV/GzZ9noiKIrDrMsB5XyR neOAHqvGvul+PS7oSKcj0yiOYDTsX12lBO3VlMo/BunCIxppL+cgmW+1AZ152wG5tzqY 6ueA== X-Gm-Message-State: AJIora+v5pqD1mPQs57gdw/TjMD087rK5cvYhjtRx4wkyrHgay8I67bR HrLElBqdFWTr9lbvCmND2Z6hag== 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-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=SWBq670Y; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf27.hostedemail.com: domain of isaacmanjarres@google.com designates 209.85.215.174 as permitted sender) smtp.mailfrom=isaacmanjarres@google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1657923812; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=h08OBDtouOlnPaz6Mk89TkUqXNC6lVw4WMryRnoY4iQ=; b=8Y8LkB0rgRMkEF0mh7Nyu49wai7xsm3o8OWROAxc1Ngn/iOzUEpIizwHwrTaLgg9UNxza1 tkRKpiAj4VEZwQauzl9s0GamqSOylnSu8W956plWPDSuk2qAtKK6sgAg7ZRKQeA1N/GCLP 81WpePLIwiOLR3rf40wSbfB9daervEE= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1657923812; a=rsa-sha256; cv=none; b=6MKXEPsVd1WTN25H+AwGw7bQKll2R0UyM0Vh55sxMGZRhqbci0CAoH+CCtM/S7Y7hyons0 xH7MnaeCF+DIiNXekP6vK+EwlsVYiCi/3aupeEvFChRaa6E2GvZHTKEGR+Ly3FS+GaKpQ0 oKEdCR3TKxoRPok2Oe85t+f+j9J+J5o= X-Rspam-User: X-Rspamd-Queue-Id: 6085F4008A X-Rspamd-Server: rspam02 X-Stat-Signature: 65k3im9m1ehyf8kyopmqyrw85rb7rq3n Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=SWBq670Y; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf27.hostedemail.com: domain of isaacmanjarres@google.com designates 209.85.215.174 as permitted sender) smtp.mailfrom=isaacmanjarres@google.com X-HE-Tag: 1657923812-788113 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 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