Messages in this thread | | | Date | Thu, 23 Sep 2021 06:28:44 -0700 | From | Jakub Kicinski <> | Subject | Re: [RFC v2 PATCH] mm, sl[au]b: Introduce lockless cache |
| |
On Wed, 22 Sep 2021 06:58:00 -0600 Jens Axboe wrote: > > I considered only case 2) when writing code. Well, To support 1), > > I think there are two ways: > > > > a) internally call kmem_cache_free when in_interrupt() is true > > b) caller must disable interrupt when freeing > > > > I think a) is okay, how do you think? > > If the API doesn't support freeing from interrupts, then I'd make that > the rule. Caller should know better if that can happen, and then just > use kmem_cache_free() if in a problematic context. That avoids polluting > the fast path with that check. I'd still make it a WARN_ON_ONCE() as > described and it can get removed later, hopefully.
Shooting from the hip a little but if I'm getting the context right this is all very similar to the skb cache so lockdep_assert_in_softirq() may be useful:
/* * Acceptable for protecting per-CPU resources accessed from BH. * Much like in_softirq() - semantics are ambiguous, use carefully. */ #define lockdep_assert_in_softirq() \ do { \ WARN_ON_ONCE(__lockdep_enabled && \ (!in_softirq() || in_irq() || in_nmi())); \ } while (0)
| |