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 E0D32C433FE for ; Tue, 30 Nov 2021 15:26:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4921D6B0072; Tue, 30 Nov 2021 10:26:22 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 43FC86B0074; Tue, 30 Nov 2021 10:26:22 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 308A46B0075; Tue, 30 Nov 2021 10:26:22 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0087.hostedemail.com [216.40.44.87]) by kanga.kvack.org (Postfix) with ESMTP id 240856B0072 for ; Tue, 30 Nov 2021 10:26:22 -0500 (EST) Received: from smtpin22.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id E935D8F162 for ; Tue, 30 Nov 2021 15:26:11 +0000 (UTC) X-FDA: 78865972542.22.3A31FF8 Received: from gentwo.de (gentwo.de [161.97.139.209]) by imf03.hostedemail.com (Postfix) with ESMTP id 8083630000B0 for ; Tue, 30 Nov 2021 15:26:06 +0000 (UTC) Received: by gentwo.de (Postfix, from userid 1001) id 328F4B001EC; Tue, 30 Nov 2021 16:26:09 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by gentwo.de (Postfix) with ESMTP id 30B5DB0006D; Tue, 30 Nov 2021 16:26:09 +0100 (CET) Date: Tue, 30 Nov 2021 16:26:09 +0100 (CET) From: Christoph Lameter X-X-Sender: cl@gentwo.de To: Vlastimil Babka cc: David Laight , Rustam Kovhaev , "penberg@kernel.org" , "rientjes@google.com" , "iamjoonsoo.kim@lge.com" , "akpm@linux-foundation.org" , "corbet@lwn.net" , "djwong@kernel.org" , "david@fromorbit.com" , "linux-kernel@vger.kernel.org" , "linux-mm@kvack.org" , "linux-doc@vger.kernel.org" , "gregkh@linuxfoundation.org" , "viro@zeniv.linux.org.uk" , "dvyukov@google.com" Subject: Re: [PATCH v4] slob: add size header to all allocations In-Reply-To: Message-ID: References: <037227db-c869-7d9c-65e8-8f5f8682171d@suse.cz> <20211122013026.909933-1-rkovhaev@gmail.com> <3c996e22-034f-1013-3978-1f786aae38fb@suse.cz> <148d2774-77b9-bb25-c132-80b00e16ea06@suse.cz> <69fc0cead9774dfdba816a8e25f30a53@AcuMS.aculab.com> User-Agent: Alpine 2.22 (DEB 394 2020-01-19) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 8083630000B0 X-Stat-Signature: akguxtwgag61yb7ekoztym5ggzmtrh99 Authentication-Results: imf03.hostedemail.com; dkim=none; spf=none (imf03.hostedemail.com: domain of cl@gentwo.org has no SPF policy when checking 161.97.139.209) smtp.mailfrom=cl@gentwo.org; dmarc=none X-HE-Tag: 1638285966-846446 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 Tue, 30 Nov 2021, Vlastimil Babka wrote: > So either I missed something or we violate the rule that kmalloc() provides > blocks where ARCH_KMALLOC_MINALIGN is not just the alignment of their > beginning but also nothing else touches the N*ARCH_KMALLOC_MINALIGN area > containing the allocated object. Indeed.... The DMA API documentation in the kernel states: Documentation/DMA-API-HOWTO.rst 2) ARCH_KMALLOC_MINALIGN + Architectures must ensure that kmalloc'ed buffer is + DMA-safe. Drivers and subsystems depend on it. If an architecture + isn't fully DMA-coherent (i.e. hardware doesn't ensure that data in + the CPU cache is identical to data in main memory), + ARCH_KMALLOC_MINALIGN must be set so that the memory allocator + makes sure that kmalloc'ed buffer doesn't share a cache line with + the others. See arch/arm/include/asm/cache.h as an example. Note that this is only the case for kmalloc. Not for a slab cache setup separately from the kmalloc array. That is why ARCH_KMALLOC_MINALIGN exists.