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 20A31C433F5 for ; Tue, 30 Nov 2021 09:23:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4053E6B0073; Tue, 30 Nov 2021 04:23:47 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 3B4AC6B0074; Tue, 30 Nov 2021 04:23:47 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2876A6B0075; Tue, 30 Nov 2021 04:23:47 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0160.hostedemail.com [216.40.44.160]) by kanga.kvack.org (Postfix) with ESMTP id 186156B0073 for ; Tue, 30 Nov 2021 04:23:47 -0500 (EST) Received: from smtpin06.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id BF361180989EC for ; Tue, 30 Nov 2021 09:23:36 +0000 (UTC) X-FDA: 78865058832.06.AC00FDD Received: from eu-smtp-delivery-151.mimecast.com (eu-smtp-delivery-151.mimecast.com [185.58.86.151]) by imf20.hostedemail.com (Postfix) with ESMTP id B6F80D0000B1 for ; Tue, 30 Nov 2021 09:23:30 +0000 (UTC) Received: from AcuMS.aculab.com (156.67.243.121 [156.67.243.121]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id uk-mta-13-Ag_JXOyjMBuSXQrxBjFzkA-1; Tue, 30 Nov 2021 09:23:32 +0000 X-MC-Unique: Ag_JXOyjMBuSXQrxBjFzkA-1 Received: from AcuMS.Aculab.com (fd9f:af1c:a25b:0:994c:f5c2:35d6:9b65) by AcuMS.aculab.com (fd9f:af1c:a25b:0:994c:f5c2:35d6:9b65) with Microsoft SMTP Server (TLS) id 15.0.1497.26; Tue, 30 Nov 2021 09:23:30 +0000 Received: from AcuMS.Aculab.com ([fe80::994c:f5c2:35d6:9b65]) by AcuMS.aculab.com ([fe80::994c:f5c2:35d6:9b65%12]) with mapi id 15.00.1497.026; Tue, 30 Nov 2021 09:23:30 +0000 From: David Laight To: 'Rustam Kovhaev' CC: 'Vlastimil Babka' , Christoph Lameter , "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 Thread-Topic: [PATCH v4] slob: add size header to all allocations Thread-Index: AQHX344YYrlQE8gw8k+1+rn2N9Qq+awQ435QgArNSACAACX/IA== Date: Tue, 30 Nov 2021 09:23:30 +0000 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> In-Reply-To: Accept-Language: en-GB, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.202.205.107] MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: aculab.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: B6F80D0000B1 X-Stat-Signature: qh1sn9tdd4w7f7b1bfnieu6nqpwfqjgh Authentication-Results: imf20.hostedemail.com; dkim=none; spf=pass (imf20.hostedemail.com: domain of david.laight@aculab.com designates 185.58.86.151 as permitted sender) smtp.mailfrom=david.laight@aculab.com; dmarc=pass (policy=none) header.from=aculab.com X-HE-Tag: 1638264210-463573 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: From: Rustam Kovhaev > Sent: 30 November 2021 07:00 >=20 > On Tue, Nov 23, 2021 at 10:18:27AM +0000, David Laight wrote: > > From: Vlastimil Babka > > > Sent: 22 November 2021 10:46 > > > > > > On 11/22/21 11:36, Christoph Lameter wrote: > > > > On Mon, 22 Nov 2021, Vlastimil Babka wrote: > > > > > > > >> But it seems there's no reason we couldn't do better? I.e. use the= value of > > > >> SLOB_HDR_SIZE only to align the beginning of actual object (and na= me the > > > >> define different than SLOB_HDR_SIZE). But the size of the header, = where we > > > >> store the object lenght could be just a native word - 4 bytes on 3= 2bit, 8 on > > > >> 64bit. The address of the header shouldn't have a reason to be als= o aligned > > > >> to ARCH_KMALLOC_MINALIGN / ARCH_SLAB_MINALIGN as only SLOB itself = processes > > > >> it and not the slab consumers which rely on those alignments? > > > > > > > > Well the best way would be to put it at the end of the object in or= der to > > > > avoid the alignment problem. This is a particular issue with SLOB b= ecause > > > > it allows multiple types of objects in a single page frame. > > > > ... > > > > > > So I guess placement at the beginning cannot be avoided. That in tu= rn runs > > > > into trouble with the DMA requirements on some platforms where the > > > > beginning of the object has to be cache line aligned. > > > > > > It's no problem to have the real beginning of the object aligned, and= the > > > prepended header not. > > > > I'm not sure that helps. > > The header can't share a cache line with the previous item (because it > > might be mapped for DMA) so will always take a full cache line. >=20 > I thought that DMA API allocates buffers that are larger than page size. > DMA pool seems to be able to give out smaller buffers, but underneath it > seems to be calling page allocator. > The SLOB objects that have this header are all less than page size, and > they cannot end up in DMA code paths, or can they? The problem isn't dma_alloc_coherent() it is when memory allocated elsewhere is used for DMA. On systems with non-coherent DMA accesses the data cache has to be flushed before all and invalidated after read DMA transfers. The cpu must not dirty any of the cache lines associated with a read DMA. This is on top of any requirements for the alignment of the returned addres= s. =09David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1= PT, UK Registration No: 1397386 (Wales)