Skip to content
This repository has been archived by the owner on Feb 26, 2020. It is now read-only.

Fix CPU hotplug #482

Closed
wants to merge 1 commit into from
Closed
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
2 changes: 1 addition & 1 deletion include/sys/kmem_cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ typedef struct spl_kmem_cache {
uint32_t skc_magic; /* Sanity magic */
uint32_t skc_name_size; /* Name length */
char *skc_name; /* Name string */
spl_kmem_magazine_t *skc_mag[NR_CPUS]; /* Per-CPU warm cache */
spl_kmem_magazine_t **skc_mag; /* Per-CPU warm cache */
uint32_t skc_mag_size; /* Magazine size */
uint32_t skc_mag_refill; /* Magazine refill count */
spl_kmem_ctor_t skc_ctor; /* Constructor */
Expand Down
15 changes: 7 additions & 8 deletions module/spl/spl-kmem-cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -805,15 +805,18 @@ spl_magazine_create(spl_kmem_cache_t *skc)
if (skc->skc_flags & KMC_NOMAGAZINE)
return (0);

skc->skc_mag = kzalloc(sizeof (spl_kmem_magazine_t *) *
num_possible_cpus(), kmem_flags_convert(KM_SLEEP));
skc->skc_mag_size = spl_magazine_size(skc);
skc->skc_mag_refill = (skc->skc_mag_size + 1) / 2;

for_each_online_cpu(i) {
for_each_possible_cpu(i) {
skc->skc_mag[i] = spl_magazine_alloc(skc, i);
if (!skc->skc_mag[i]) {
for (i--; i >= 0; i--)
spl_magazine_free(skc->skc_mag[i]);

kfree(skc->skc_mag);
return (-ENOMEM);
}
}
Expand All @@ -833,11 +836,13 @@ spl_magazine_destroy(spl_kmem_cache_t *skc)
if (skc->skc_flags & KMC_NOMAGAZINE)
return;

for_each_online_cpu(i) {
for_each_possible_cpu(i) {
skm = skc->skc_mag[i];
spl_cache_flush(skc, skm, skm->skm_avail);
spl_magazine_free(skm);
}

kfree(skc->skc_mag);
}

/*
Expand Down Expand Up @@ -880,12 +885,6 @@ spl_kmem_cache_create(char *name, size_t size, size_t align,

might_sleep();

/*
* Allocate memory for a new cache and initialize it. Unfortunately,
* this usually ends up being a large allocation of ~32k because
* we need to allocate enough memory for the worst case number of
* cpus in the magazine, skc_mag[NR_CPUS].
*/
skc = kzalloc(sizeof (*skc), lflags);
if (skc == NULL)
return (NULL);
Expand Down