Skip to content
Permalink
Browse files

Add kmem cache accessors

Make metaslab platform agnostic again

Signed-off-by: Matt Macy <mmacy@FreeBSD.org>
  • Loading branch information...
mattmacy committed Oct 2, 2019
1 parent 381d91d commit d2f5b6ef7c7488ee30c657064c5073cd19d632a4
Showing with 20 additions and 4 deletions.
  1. +2 −0 include/os/linux/spl/sys/kmem_cache.h
  2. +14 −0 module/os/linux/spl/spl-kmem-cache.c
  3. +4 −4 module/zfs/metaslab.c
@@ -218,6 +218,8 @@ extern void spl_kmem_cache_free(spl_kmem_cache_t *skc, void *obj);
extern void spl_kmem_cache_set_allocflags(spl_kmem_cache_t *skc, gfp_t flags);
extern void spl_kmem_cache_reap_now(spl_kmem_cache_t *skc, int count);
extern void spl_kmem_reap(void);
extern uint64_t spl_kmem_cache_inuse(kmem_cache_t *cache);
extern uint64_t spl_kmem_cache_entry_size(kmem_cache_t *cache);

#define kmem_cache_create(name, size, align, ctor, dtor, rclm, priv, vmp, fl) \
spl_kmem_cache_create(name, size, align, ctor, dtor, rclm, priv, vmp, fl)
@@ -257,6 +257,20 @@ spl_obj_size(spl_kmem_cache_t *skc)
P2ROUNDUP_TYPED(sizeof (spl_kmem_obj_t), align, uint32_t));
}

uint64_t
spl_kmem_cache_inuse(kmem_cache_t *cache)
{
return (cache->skc_obj_total);
}
EXPORT_SYMBOL(spl_kmem_cache_inuse);

uint64_t
spl_kmem_cache_entry_size(kmem_cache_t *cache)
{
return (cache->skc_obj_size);
}
EXPORT_SYMBOL(spl_kmem_cache_entry_size);

/*
* Lookup the spl_kmem_object_t for an object given that object.
*/
@@ -2142,8 +2142,8 @@ metaslab_potentially_evict(metaslab_class_t *mc)
{
#ifdef _KERNEL
uint64_t allmem = arc_all_memory();
uint64_t inuse = zfs_btree_leaf_cache->skc_obj_total;
uint64_t size = zfs_btree_leaf_cache->skc_obj_size;
uint64_t inuse = spl_kmem_cache_inuse(zfs_btree_leaf_cache);
uint64_t size = spl_kmem_cache_entry_size(zfs_btree_leaf_cache);
int tries = 0;
for (; allmem * zfs_metaslab_mem_limit / 100 < inuse * size &&
tries < multilist_get_num_sublists(mc->mc_metaslab_txg_list) * 2;
@@ -2180,7 +2180,7 @@ metaslab_potentially_evict(metaslab_class_t *mc)
*/
if (msp->ms_loading) {
msp = next_msp;
inuse = zfs_btree_leaf_cache->skc_obj_total;
inuse = spl_kmem_cache_inuse(zfs_btree_leaf_cache);
continue;
}
/*
@@ -2202,7 +2202,7 @@ metaslab_potentially_evict(metaslab_class_t *mc)
}
mutex_exit(&msp->ms_lock);
msp = next_msp;
inuse = zfs_btree_leaf_cache->skc_obj_total;
inuse = spl_kmem_cache_inuse(zfs_btree_leaf_cache);
}
}
#endif

0 comments on commit d2f5b6e

Please sign in to comment.
You can’t perform that action at this time.