Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update skc_obj_alloc for spl kmem caches that are backed by Linux #9474

Merged
merged 1 commit into from
Oct 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions module/os/linux/spl/spl-kmem-cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -1467,6 +1467,17 @@ spl_kmem_cache_alloc(spl_kmem_cache_t *skc, int flags)
obj = kmem_cache_alloc(slc, kmem_flags_convert(flags));
} while ((obj == NULL) && !(flags & KM_NOSLEEP));

if (obj != NULL) {
/*
* Even though we leave everything up to the
* underlying cache we still keep track of
* how many objects we've allocated in it for
* better debuggability.
*/
spin_lock(&skc->skc_lock);
skc->skc_obj_alloc++;
spin_unlock(&skc->skc_lock);
}
goto ret;
}

Expand Down Expand Up @@ -1540,6 +1551,9 @@ spl_kmem_cache_free(spl_kmem_cache_t *skc, void *obj)
*/
if (skc->skc_flags & KMC_SLAB) {
kmem_cache_free(skc->skc_linux_cache, obj);
spin_lock(&skc->skc_lock);
skc->skc_obj_alloc--;
spin_unlock(&skc->skc_lock);
return;
}

Expand Down
28 changes: 22 additions & 6 deletions module/os/linux/spl/spl-proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -437,11 +437,29 @@ slab_seq_show(struct seq_file *f, void *p)

ASSERT(skc->skc_magic == SKC_MAGIC);

/*
* Backed by Linux slab see /proc/slabinfo.
*/
if (skc->skc_flags & KMC_SLAB)
if (skc->skc_flags & KMC_SLAB) {
/*
* This cache is backed by a generic Linux kmem cache which
* has its own accounting. For these caches we only track
* the number of active allocated objects that exist within
* the underlying Linux slabs. For the overall statistics of
* the underlying Linux cache please refer to /proc/slabinfo.
*/
spin_lock(&skc->skc_lock);
seq_printf(f, "%-36s ", skc->skc_name);
seq_printf(f, "0x%05lx %9s %9lu %8s %8u "
"%5s %5s %5s %5s %5lu %5s %5s %5s %5s\n",
(long unsigned)skc->skc_flags,
"-",
(long unsigned)(skc->skc_obj_size * skc->skc_obj_alloc),
"-",
(unsigned)skc->skc_obj_size,
"-", "-", "-", "-",
(long unsigned)skc->skc_obj_alloc,
"-", "-", "-", "-");
spin_unlock(&skc->skc_lock);
return (0);
}

spin_lock(&skc->skc_lock);
seq_printf(f, "%-36s ", skc->skc_name);
Expand All @@ -461,9 +479,7 @@ slab_seq_show(struct seq_file *f, void *p)
(long unsigned)skc->skc_obj_deadlock,
(long unsigned)skc->skc_obj_emergency,
(long unsigned)skc->skc_obj_emergency_max);

spin_unlock(&skc->skc_lock);

return (0);
}

Expand Down