* Re: [patch V3 06/18] posix-timers: Remove SLAB_PANIC from kmem cache
@ 2025-03-10 6:50 Alexey Dobriyan
0 siblings, 0 replies; 2+ messages in thread
From: Alexey Dobriyan @ 2025-03-10 6:50 UTC (permalink / raw)
To: Thomas Gleixner
Cc: linux-kernel, Anna-Maria Behnsen, Frederic Weisbecker,
Benjamin Segall, Eric Dumazet, Andrey Vagin, Pavel Tikhomirov,
Peter Zijlstra, Cyrill Gorcunov
> - posix_timers_cache = kmem_cache_create("posix_timers_cache",
> - sizeof(struct k_itimer), 0,
> - SLAB_PANIC | SLAB_ACCOUNT, NULL);
> + posix_timers_cache = kmem_cache_create("posix_timers_cache", sizeof(struct k_itimer), 0,
> + SLAB_ACCOUNT, NULL);
> There is no need to panic when the posix-timer kmem_cache can't be
> created. timer_create() will fail with -ENOMEM and that's it.
Of course there is a reason to panic.
Where did the memory go, so there is not enough for a tiny
"kmem_cache" instance?
You've taken the branch from __init code which is discarded
and made it a branch which can not be.
More or less every __init allocation should panic not the other way
around.
^ permalink raw reply [flat|nested] 2+ messages in thread
* [patch V3 06/18] posix-timers: Remove SLAB_PANIC from kmem cache
2025-03-08 16:48 [patch V3 00/18] posix-timers: Rework the global hash table and provide a sane mechanism for CRIU Thomas Gleixner
@ 2025-03-08 16:48 ` Thomas Gleixner
0 siblings, 0 replies; 2+ messages in thread
From: Thomas Gleixner @ 2025-03-08 16:48 UTC (permalink / raw)
To: LKML
Cc: Anna-Maria Behnsen, Frederic Weisbecker, Benjamin Segall,
Eric Dumazet, Andrey Vagin, Pavel Tikhomirov, Peter Zijlstra,
Cyrill Gorcunov
There is no need to panic when the posix-timer kmem_cache can't be
created. timer_create() will fail with -ENOMEM and that's it.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Frederic Weisbecker <frederic@kernel.org>
---
V2: New patch
---
kernel/time/posix-timers.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
--- a/kernel/time/posix-timers.c
+++ b/kernel/time/posix-timers.c
@@ -243,9 +243,8 @@ static int posix_get_hrtimer_res(clockid
static __init int init_posix_timers(void)
{
- posix_timers_cache = kmem_cache_create("posix_timers_cache",
- sizeof(struct k_itimer), 0,
- SLAB_PANIC | SLAB_ACCOUNT, NULL);
+ posix_timers_cache = kmem_cache_create("posix_timers_cache", sizeof(struct k_itimer), 0,
+ SLAB_ACCOUNT, NULL);
return 0;
}
__initcall(init_posix_timers);
@@ -371,8 +370,12 @@ static struct pid *good_sigevent(sigeven
static struct k_itimer *alloc_posix_timer(void)
{
- struct k_itimer *tmr = kmem_cache_zalloc(posix_timers_cache, GFP_KERNEL);
+ struct k_itimer *tmr;
+ if (unlikely(!posix_timers_cache))
+ return NULL;
+
+ tmr = kmem_cache_zalloc(posix_timers_cache, GFP_KERNEL);
if (!tmr)
return tmr;
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-03-10 6:50 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-03-10 6:50 [patch V3 06/18] posix-timers: Remove SLAB_PANIC from kmem cache Alexey Dobriyan
-- strict thread matches above, loose matches on Subject: below --
2025-03-08 16:48 [patch V3 00/18] posix-timers: Rework the global hash table and provide a sane mechanism for CRIU Thomas Gleixner
2025-03-08 16:48 ` [patch V3 06/18] posix-timers: Remove SLAB_PANIC from kmem cache Thomas Gleixner
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®