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 F3D31C38A2D for ; Wed, 26 Oct 2022 08:39:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 486978E0002; Wed, 26 Oct 2022 04:39:42 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 436148E0001; Wed, 26 Oct 2022 04:39:42 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 325AD8E0002; Wed, 26 Oct 2022 04:39:42 -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 214B58E0001 for ; Wed, 26 Oct 2022 04:39:42 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id EC702140985 for ; Wed, 26 Oct 2022 08:39:41 +0000 (UTC) X-FDA: 80062452162.04.ED6D254 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf25.hostedemail.com (Postfix) with ESMTP id 79D73A0002 for ; Wed, 26 Oct 2022 08:39:41 +0000 (UTC) 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 7122AB82143; Wed, 26 Oct 2022 08:39:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CACA5C433D6; Wed, 26 Oct 2022 08:39:35 +0000 (UTC) Date: Wed, 26 Oct 2022 09:39:32 +0100 From: Catalin Marinas To: Greg Kroah-Hartman Cc: Linus Torvalds , Arnd Bergmann , Will Deacon , Marc Zyngier , Andrew Morton , Herbert Xu , Ard Biesheuvel , Christoph Hellwig , Isaac Manjarres , Saravana Kannan , linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH v2 1/2] mm: slab: Introduce __GFP_PACKED for smaller kmalloc() alignments Message-ID: References: <20221025205247.3264568-1-catalin.marinas@arm.com> <20221025205247.3264568-2-catalin.marinas@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1666773581; a=rsa-sha256; cv=none; b=ifwJfuhG9izRLVr3Vo7Fx465MZR7zcJjCl0S08FhpizR5dBqN0rWYWW1XWi6Smocviq/b0 F2In77b+dUN7OCthjkrtFcbSEtn5/xA1W3nSxMW1g6RWZUFfu1l+e2wAKGSu3MSsoHgokS 89ddv5dSrycUE73vdkAmnpiNyEneSKg= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=arm.com (policy=none); spf=pass (imf25.hostedemail.com: domain of cmarinas@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=cmarinas@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1666773581; 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; bh=q7koDkKcXArIoIh6uGvswYbQZEOLfaBg/P5Yukw6U8M=; b=Eh29glqj1eAaV2OD/WoUZdvlqH5KPflAz//gDcr7RfRgML16FDwvgS1ImY53lKxUb91Udn dzbToEcggELQcdG4RwJ950nOcweyp+VwocQraJlqAya0Vu/wcZeyAD37ppf56Udkt0Ot6b v3yhKlO5u13DRK3LRGi9l7CkEle04q0= X-Rspam-User: Authentication-Results: imf25.hostedemail.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=arm.com (policy=none); spf=pass (imf25.hostedemail.com: domain of cmarinas@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=cmarinas@kernel.org X-Rspamd-Server: rspam11 X-Stat-Signature: jgzutszj1g1foiwncmygubqs8gm3gerz X-Rspamd-Queue-Id: 79D73A0002 X-HE-Tag: 1666773581-400979 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 Wed, Oct 26, 2022 at 08:39:04AM +0200, Greg Kroah-Hartman wrote: > On Tue, Oct 25, 2022 at 09:52:46PM +0100, Catalin Marinas wrote: > > By default kmalloc() returns objects aligned to ARCH_KMALLOC_MINALIGN. > > This can be somewhat large on architectures defining ARCH_DMA_MINALIGN > > (e.g. 128 on arm64) and significant memory is wasted through small > > kmalloc() allocations. > > > > Reduce the minimum alignment for kmalloc() to the default > > KMALLOC_MIN_SIZE (8 for slub, 32 for slab) but align the > > requested size to the bigger ARCH_KMALLOC_MINALIGN unless a newly added > > __GFP_PACKED flag is passed. With this gfp flag, the alignment is > > reduced to KMALLOC_PACKED_ALIGN, at least sizeof(unsigned long long). > > Can memory allocated with __GFP_PACKED be sent to DMA controllers? > > If not, you should say that somewhere here or I'm going to get a bunch > of patches trying to add this flag to tiny USB urb allocations (where we > allocate 8 or 16 bytes) that is then going to fail on some hardware. Good point, I'll add a comment. We can also add a check to the DMA API when debugging is enabled, something like WARN_ON_ONCE(ksize(ptr) < cache_line_size()) for non-coherent devices. -- Catalin