Changeset View
Changeset View
Standalone View
Standalone View
sys/compat/linuxkpi/common/src/linux_slab.c
Show First 20 Lines • Show All 90 Lines • ▼ Show 20 Lines | linux_kmem_ctor(void *mem, int size, void *arg, int flags) | ||||
/* check for constructor */ | /* check for constructor */ | ||||
if (likely(c->cache_ctor != NULL)) | if (likely(c->cache_ctor != NULL)) | ||||
c->cache_ctor(mem); | c->cache_ctor(mem); | ||||
return (0); | return (0); | ||||
} | } | ||||
static void | void | ||||
linux_kmem_cache_free_rcu_callback(struct rcu_head *head) | linux_kmem_cache_free_rcu_callback(struct rcu_head *head) | ||||
{ | { | ||||
struct linux_kmem_rcu *rcu = | struct linux_kmem_rcu *rcu = | ||||
container_of(head, struct linux_kmem_rcu, rcu_head); | container_of(head, struct linux_kmem_rcu, rcu_head); | ||||
uma_zfree(rcu->cache->cache_zone, LINUX_RCU_TO_KMEM(rcu)); | uma_zfree(rcu->cache->cache_zone, LINUX_RCU_TO_KMEM(rcu)); | ||||
} | } | ||||
Show All 32 Lines | linux_kmem_cache_create(const char *name, size_t size, size_t align, | ||||
c->cache_flags = flags; | c->cache_flags = flags; | ||||
c->cache_ctor = ctor; | c->cache_ctor = ctor; | ||||
c->cache_size = size; | c->cache_size = size; | ||||
init_llist_head(&c->cache_items); | init_llist_head(&c->cache_items); | ||||
TASK_INIT(&c->cache_task, 0, lkpi_kmem_cache_free_async_fn, c); | TASK_INIT(&c->cache_task, 0, lkpi_kmem_cache_free_async_fn, c); | ||||
return (c); | return (c); | ||||
} | } | ||||
static inline void | void | ||||
lkpi_kmem_cache_free_rcu(struct linux_kmem_cache *c, void *m) | linux_kmem_cache_free_rcu(struct linux_kmem_cache *c, void *m) | ||||
wulf: `lkpi_kmem_cache_free_rcu` function should be renamed back to `linux_kmem_cache_free_rcu` and… | |||||
{ | { | ||||
struct linux_kmem_rcu *rcu = LINUX_KMEM_TO_RCU(c, m); | struct linux_kmem_rcu *rcu = LINUX_KMEM_TO_RCU(c, m); | ||||
call_rcu(&rcu->rcu_head, linux_kmem_cache_free_rcu_callback); | call_rcu(&rcu->rcu_head, linux_kmem_cache_free_rcu_callback); | ||||
} | } | ||||
static inline void | static inline void | ||||
lkpi_kmem_cache_free_sync(struct linux_kmem_cache *c, void *m) | lkpi_kmem_cache_free_sync(struct linux_kmem_cache *c, void *m) | ||||
Show All 20 Lines | lkpi_kmem_cache_free_async(struct linux_kmem_cache *c, void *m) | ||||
llist_add(m, &c->cache_items); | llist_add(m, &c->cache_items); | ||||
taskqueue_enqueue(linux_irq_work_tq, &c->cache_task); | taskqueue_enqueue(linux_irq_work_tq, &c->cache_task); | ||||
} | } | ||||
void | void | ||||
lkpi_kmem_cache_free(struct linux_kmem_cache *c, void *m) | lkpi_kmem_cache_free(struct linux_kmem_cache *c, void *m) | ||||
{ | { | ||||
if (unlikely(c->cache_flags & SLAB_TYPESAFE_BY_RCU)) | if (unlikely(c->cache_flags & SLAB_TYPESAFE_BY_RCU)) | ||||
lkpi_kmem_cache_free_rcu(c, m); | linux_kmem_cache_free_rcu(c, m); | ||||
else if (unlikely(curthread->td_critnest != 0)) | else if (unlikely(curthread->td_critnest != 0)) | ||||
lkpi_kmem_cache_free_async(c, m); | lkpi_kmem_cache_free_async(c, m); | ||||
else | else | ||||
lkpi_kmem_cache_free_sync(c, m); | lkpi_kmem_cache_free_sync(c, m); | ||||
} | } | ||||
void | void | ||||
linux_kmem_cache_destroy(struct linux_kmem_cache *c) | linux_kmem_cache_destroy(struct linux_kmem_cache *c) | ||||
Show All 32 Lines |
lkpi_kmem_cache_free_rcu function should be renamed back to linux_kmem_cache_free_rcu and made visible.
linux_kmem_cache_free_rcu_callback can be left intact. 10235ad0567f did not change it.