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 2E4ECC4332F for ; Fri, 11 Nov 2022 09:37:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5358B6B0071; Fri, 11 Nov 2022 04:37:14 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4E5F96B0072; Fri, 11 Nov 2022 04:37:14 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3AD5B6B0074; Fri, 11 Nov 2022 04:37:14 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 2A2B16B0071 for ; Fri, 11 Nov 2022 04:37:14 -0500 (EST) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id EAE7D80263 for ; Fri, 11 Nov 2022 09:37:13 +0000 (UTC) X-FDA: 80120657946.09.5C96588 Received: from eu-smtp-delivery-151.mimecast.com (eu-smtp-delivery-151.mimecast.com [185.58.86.151]) by imf05.hostedemail.com (Postfix) with ESMTP id 47917100006 for ; Fri, 11 Nov 2022 09:37:12 +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-97-8TJG0fauNZW-nVbR3oMe2A-1; Fri, 11 Nov 2022 09:37:09 +0000 X-MC-Unique: 8TJG0fauNZW-nVbR3oMe2A-1 Received: from AcuMS.Aculab.com (10.202.163.6) by AcuMS.aculab.com (10.202.163.6) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Fri, 11 Nov 2022 09:37:08 +0000 Received: from AcuMS.Aculab.com ([::1]) by AcuMS.aculab.com ([::1]) with mapi id 15.00.1497.042; Fri, 11 Nov 2022 09:37:08 +0000 From: David Laight To: 'Matthew Wilcox' , Vlastimil Babka CC: Theodore Ts'o , Aaro Koskinen , "Linus Torvalds" , Paul Cercueil , "42.hyeyoo@gmail.com" <42.hyeyoo@gmail.com>, "akpm@linux-foundation.org" , "catalin.marinas@arm.com" , "cl@linux.com" , "iamjoonsoo.kim@lge.com" , "linux-kernel@vger.kernel.org" , "linux-mm@kvack.org" , "penberg@kernel.org" , "rientjes@google.com" , "rkovhaev@gmail.com" , "roman.gushchin@linux.dev" , Feng Tang Subject: RE: Deprecating and removing SLOB Thread-Topic: Deprecating and removing SLOB Thread-Index: AQHY9SBUoMjUW3vwt0m3f4uC9hH+/a45b0ow Date: Fri, 11 Nov 2022 09:37:07 +0000 Message-ID: References: <20221109234832.GE307514@darkstar.musicnaut.iki.fi> 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 ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=none; spf=pass (imf05.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 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1668159433; a=rsa-sha256; cv=none; b=aG92n3kFg3X3n79HRbwjvb53axojH+ir+RgNm9USaN7keO8Dmsb0ySka0ct7aXltgfituc C1FOD7h1HM6eErZh2E1mF3Q6FzmhAJFn5jGY6QgKfPPTYtY1uxp3/SDhb10q+h6Oxjr6a/ IaqIRwmq4AG9J1x6RxCB7qA2xP9FSOY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1668159433; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ufdtAr7J/jojtbBoDB4qIefSpr8U2o+7dkk8TnQEByg=; b=VpG3YYa9PRB71bA/dgG5xSH4NmT+Jeushlw5YekXGs7hs3/ApAT/TZBK/6p2HbkLJx2kP+ qVSfQkVWvOFZvcb3yD3xRh8PZSbM7XdpbwHtrRDJc99zDh6yK8XoNB36Zuz3xvF/z5kv3/ ApkclvyLOUxLaFyc5H5ZbrxJh8suEII= X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 47917100006 X-Rspam-User: Authentication-Results: imf05.hostedemail.com; dkim=none; spf=pass (imf05.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-Stat-Signature: 5edcw4f3aafw9w38qyahjsu7a5rtd67w X-HE-Tag: 1668159432-696325 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: Matthew Wilcox > Sent: 10 November 2022 16:20 >=20 > On Thu, Nov 10, 2022 at 08:31:31AM +0100, Vlastimil Babka wrote: > > > octeon-hcd will crash the kernel when SLOB is used. This usually = happens > > > after the 18-byte control transfer when a device descriptor is re= ad. > > > The DMA engine is always transfering full 32-bit words and if the > > > transfer is shorter, some random garbage appears after the buffer= . > > > The problem is not visible with SLUB since it rounds up the alloc= ations > > > to word boundary, and the extra bytes will go undetected. > > > > Ah, actually it wouldn't *now* as SLUB would make the allocation fall i= nto > > kmalloc-32 cache and only add redzone beyond 32 bytes. But with upcomin= g > > changes by Feng Tang, this should work. >=20 > This is kind of "if a bug stings a tree in a forest, does it hurt" > problem. If all allocations of 18 bytes are rounded up to 20 or more > bytes, then it doesn't matter that the device has this bug. Sure, it > may end up hurting in the future if we decide to create 18-byte slab > caches, but it's not actually going to affect anything today (and we > seem to be moving towards less precision in order to get more > performance) Yes, even on dma-coherent systems allocated blocks have to be moderately aligned - so the space after an 18 byte block can't be used. I also doubt there is any benefit (and many bugs) from allowing 2 bytes alignment on m68k. So the 'overwrite to a whole number of words' maybe reasonably expected to not cause any real bugs. x86 (even 32bit) probably requires 16 byte alignment (for some corner cases) - ok for a power-of-2 allocator that doesn't add a header. (Although 1, 2, 4 and 8 byte allocates are valid.) To reduce memory wastage what you really don't want is an allocator that adds a header/trailer and then rounds up to a power of 2. Coders write in binary and do kmalloc(256) not kmalloc(200) and rounding 256 up to 512 is rather wasteful. (Search for the kmalloc(PAGE_SIZE+1) :-) I also think that one of the allocators only cuts pages into power-of-2 sizes. It is probably sensible to return cache-aligned (probably 64 byte) buffers for requests larger than a cache line. But a 4k page can be split into 21 192-byte buffers. As well as using less memory for allocates between 129 and 192 bytes it may reduce pressure on the d-cache by evening out cache line usage. =09David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1= PT, UK Registration No: 1397386 (Wales)