All of lore.kernel.org
 help / color / mirror / Atom feed
* Deprecating and removing SLOB
@ 2022-11-08 15:55 Vlastimil Babka
  2022-11-08 18:18 ` Christophe Leroy
                   ` (2 more replies)
  0 siblings, 3 replies; 112+ messages in thread
From: Vlastimil Babka @ 2022-11-08 15:55 UTC (permalink / raw)
  To: Christoph Lameter, David Rientjes, Joonsoo Kim, Pekka Enberg
  Cc: Hyeonggon Yoo, Matthew Wilcox, Roman Gushchin, Linus Torvalds,
	linux-mm, linux-kernel, Catalin Marinas, Rustam Kovhaev,
	Andrew Morton

Hi,

as we all know, we currently have three slab allocators. As we discussed 
at LPC [1], it is my hope that one of these allocators has a future, and 
two of them do not.

The unsurprising reasons include code maintenance burden, other features 
compatible with only a subset of allocators (or more effort spent on the 
features), blocking API improvements (more on that below), and my 
inability to pronounce SLAB and SLUB in a properly distinguishable way, 
without resorting to spelling out the letters.

I think (but may be proven wrong) that SLOB is the easier target of the 
two to be removed, so I'd like to focus on it first.

I believe SLOB can be removed because:

- AFAIK nobody really uses it? It strives for minimal memory footprint 
by putting all objects together, which has its CPU performance costs 
(locking, lack of percpu caching, searching for free space...). I'm not 
aware of any "tiny linux" deployment that opts for this. For example, 
OpenWRT seems to use SLUB and the devices these days have e.g. 128MB 
RAM, not up to 16 MB anymore. I've heard anecdotes that the performance 
SLOB impact is too much for those who tried. Googling for 
"CONFIG_SLOB=y" yielded nothing useful.

- Last time we discussed it [2], it seemed SLUB memory requirements can 
be brought very close to SLOB's if needed. Of course it can never have 
as small footprint as SLOB due to separate kmem_caches, but the 
difference is not that significant, unless somebody still tries to use 
Linux on very tiny systems (goes back to the previous point).

Besides the smaller maintenance burden, removing SLOB would allow us to 
do a useful API improvement - the ability to use kfree() for both 
objects allocated by kmalloc() and kmem_cache_alloc(). Currently the 
latter has to be freed by kmem_cache_free(), passing a kmem_cache 
pointer in addition to the object pointer. With SLUB and SLAB, it is 
however possible to use kfree() instead, as the kmalloc caches and the 
rest of kmem_caches are the same and kfree() can lookup the kmem_cache 
from object pointer easily for any of those. XFS has apparently did that 
for years without anyone noticing it's broken on SLOB [3], and 
legitimizing and expanding this would help some use cases beside XFS 
(IIRC Matthew mentioned rcu-based freeing for example).

However for SLOB to support kfree() on all allocations, it would need to 
store object size of allocated objects (which it currently does only for 
kmalloc() objects, prepending a size header to the object), but for 
kmem_cache_alloc() allocations as well. This has been attempted in the 
thread [3] but it bloats the memory usage, especially on architectures 
with large ARCH_KMALLOC_MINALIGN, where the prepended header basically 
has to occupy the whole ARCH_KMALLOC_MINALIGN block to be DMA safe. 
There are ongoing efforts to reduce this minalign, but the memory 
footprint would still increase, going against the purpose of SLOB, so 
again it would be easier if we could just remove it.

So with this thread I'm interested in hearing arguments/use cases for 
keeping SLOB. There might be obviously users of SLOB whom this 
conversation will not reach, so I assume the eventual next step would be 
to deprecate it in a way that those users are notified when building a 
new kernel and can raise their voice then. Is there a good proven way 
how to do that for a config option like this one?

Thanks,
Vlastimil

[1] https://lpc.events/event/16/contributions/1272/ - slides in the 
slabs.pdf linked there
[2] 
https://lore.kernel.org/all/20211017135708.GA8442@kvm.asia-northeast3-a.c.our-ratio-313919.internal/#t
[3] 
https://lore.kernel.org/all/20210930044202.GP2361455@dread.disaster.area/


^ permalink raw reply	[flat|nested] 112+ messages in thread
* Re: Deprecating and removing SLOB
@ 2022-11-09 20:56 Paul Cercueil
  2022-11-09 21:39 ` Linus Torvalds
  0 siblings, 1 reply; 112+ messages in thread
From: Paul Cercueil @ 2022-11-09 20:56 UTC (permalink / raw)
  To: vbabka
  Cc: 42.hyeyoo, akpm, catalin.marinas, cl, iamjoonsoo.kim,
	linux-kernel, linux-mm, penberg, rientjes, rkovhaev,
	roman.gushchin, torvalds, willy

Hi Vlastimil,

I was actually using SLOB until recently for a device flasher program 
(kernel + initramfs + dtb, booted over USB) for Ingenic SoCs. I picked 
SLOB just because it said "embedded systems" in menuconfig and some of 
my boards have as little as 32 MiB RAM.

It worked fine on some boards, but on others it had about a 25% chance 
of booting, and 75% chance of hanging at boot. I tried printk-debugging 
it, and was coming to the conclusion that it's memory corruption of 
some sort.

Then I switched to SLUB and all the problems are gone. Same with SLAB.

So while I can't say for sure that SLOB is broken (it might be 
triggering a bug somewhere else), I am highly suspicious that it is.

So yeah... axe it.

Cheers,
-Paul



^ permalink raw reply	[flat|nested] 112+ messages in thread

end of thread, other threads:[~2022-11-21 17:04 UTC | newest]

Thread overview: 112+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-08 15:55 Deprecating and removing SLOB Vlastimil Babka
2022-11-08 18:18 ` Christophe Leroy
2022-11-08 19:17   ` Andrew Morton
2022-11-08 18:46 ` Roman Gushchin
2022-11-08 20:13   ` Yosry Ahmed
2022-11-09  9:09     ` Vlastimil Babka
2022-11-08 21:44 ` Pasha Tatashin
2022-11-09  9:00   ` Vlastimil Babka
2022-11-09  9:00     ` Vlastimil Babka
2022-11-09  9:00     ` Vlastimil Babka
2022-11-09  9:00     ` Vlastimil Babka
2022-11-09 15:50     ` Aaro Koskinen
2022-11-09 15:50       ` Aaro Koskinen
2022-11-09 15:50       ` Aaro Koskinen
2022-11-09 15:50       ` Aaro Koskinen
2022-11-09 16:45       ` Geert Uytterhoeven
2022-11-09 16:45         ` Geert Uytterhoeven
2022-11-09 16:45         ` Geert Uytterhoeven
2022-11-09 16:45         ` Geert Uytterhoeven
2022-11-09 17:45       ` Mike Rapoport
2022-11-09 17:45         ` Mike Rapoport
2022-11-09 17:45         ` Mike Rapoport
2022-11-09 17:45         ` Mike Rapoport
2022-11-09 21:16       ` Janusz Krzysztofik
2022-11-09 21:16         ` Janusz Krzysztofik
2022-11-09 21:16         ` Janusz Krzysztofik
2022-11-09 21:16         ` Janusz Krzysztofik
2022-11-09 17:57   ` Conor.Dooley
2022-11-09 23:00     ` Damien Le Moal
2022-11-11 10:25       ` Vlastimil Babka
2022-11-12  1:40         ` Damien Le Moal
2022-11-11 10:33   ` Vlastimil Babka
2022-11-11 10:33     ` Vlastimil Babka
2022-11-11 10:33     ` Vlastimil Babka
2022-11-11 10:33     ` Vlastimil Babka
2022-11-11 12:49     ` [lkp] [+5395 bytes kernel size regression] [i386-tinyconfig] [b7c8731082] " kernel test robot
2022-11-11 17:24       ` Josh Triplett
2022-11-11 21:11         ` Vlastimil Babka
2022-11-17  8:57         ` Vlastimil Babka
2022-11-11 20:46     ` Conor Dooley
2022-11-11 20:46       ` Conor Dooley
2022-11-11 20:46       ` Conor Dooley
2022-11-11 20:46       ` Conor Dooley
2022-11-12  1:40       ` Damien Le Moal
2022-11-12  1:40         ` Damien Le Moal
2022-11-12  1:40         ` Damien Le Moal
2022-11-12  1:40         ` Damien Le Moal
2022-11-14  1:55       ` Damien Le Moal
2022-11-14  1:55         ` Damien Le Moal
2022-11-14  1:55         ` Damien Le Moal
2022-11-14  1:55         ` Damien Le Moal
2022-11-14  5:48         ` Damien Le Moal
2022-11-14  5:48           ` Damien Le Moal
2022-11-14  5:48           ` Damien Le Moal
2022-11-14  5:48           ` Damien Le Moal
2022-11-14  9:36           ` Vlastimil Babka
2022-11-14  9:36             ` Vlastimil Babka
2022-11-14  9:36             ` Vlastimil Babka
2022-11-14  9:36             ` Vlastimil Babka
2022-11-14 11:35             ` Damien Le Moal
2022-11-14 11:35               ` Damien Le Moal
2022-11-14 11:35               ` Damien Le Moal
2022-11-14 11:35               ` Damien Le Moal
2022-11-14 14:47               ` Hyeonggon Yoo
2022-11-14 14:47                 ` Hyeonggon Yoo
2022-11-14 14:47                 ` Hyeonggon Yoo
2022-11-14 14:47                 ` Hyeonggon Yoo
2022-11-15  4:24                 ` Damien Le Moal
2022-11-15  4:24                   ` Damien Le Moal
2022-11-15  4:24                   ` Damien Le Moal
2022-11-15  4:24                   ` Damien Le Moal
2022-11-15  4:28                   ` Damien Le Moal
2022-11-15  4:28                     ` Damien Le Moal
2022-11-15  4:28                     ` Damien Le Moal
2022-11-15  4:28                     ` Damien Le Moal
2022-11-16  7:57                     ` Matthew Wilcox
2022-11-16  7:57                       ` Matthew Wilcox
2022-11-16  7:57                       ` Matthew Wilcox
2022-11-16  7:57                       ` Matthew Wilcox
2022-11-16  8:02                       ` Damien Le Moal
2022-11-16  8:02                         ` Damien Le Moal
2022-11-16  8:02                         ` Damien Le Moal
2022-11-16  8:02                         ` Damien Le Moal
2022-11-16 17:51                   ` Vlastimil Babka
2022-11-16 17:51                     ` Vlastimil Babka
2022-11-16 17:51                     ` Vlastimil Babka
2022-11-16 17:51                     ` Vlastimil Babka
2022-11-17  0:22                     ` Damien Le Moal
2022-11-17  0:22                       ` Damien Le Moal
2022-11-17  0:22                       ` Damien Le Moal
2022-11-17  0:22                       ` Damien Le Moal
2022-11-21  4:30                     ` Damien Le Moal
2022-11-21  4:30                       ` Damien Le Moal
2022-11-21  4:30                       ` Damien Le Moal
2022-11-21  4:30                       ` Damien Le Moal
2022-11-21 17:02                       ` Vlastimil Babka
2022-11-21 17:02                         ` Vlastimil Babka
2022-11-21 17:02                         ` Vlastimil Babka
2022-11-21 17:02                         ` Vlastimil Babka
2022-11-14 11:50             ` Hyeonggon Yoo
2022-11-14 11:50               ` Hyeonggon Yoo
2022-11-14 11:50               ` Hyeonggon Yoo
2022-11-14 11:50               ` Hyeonggon Yoo
2022-11-09 20:56 Paul Cercueil
2022-11-09 21:39 ` Linus Torvalds
2022-11-09 23:48   ` Aaro Koskinen
2022-11-09 23:51     ` Aaro Koskinen
2022-11-10  4:40     ` Theodore Ts'o
2022-11-10  7:31       ` Vlastimil Babka
2022-11-10  7:54         ` Feng Tang
2022-11-10 16:20         ` Matthew Wilcox
2022-11-11  9:37           ` David Laight

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.