Skip to content

Commit eeb67a0

Browse files
Mikulas Patockasnitm
authored andcommitted
dm bufio: get rid of slab cache name allocations
dm-bufio keeps the dm_bufio_cache_names array that holds names of the slab caches. Since the commit db265ec ("mm/sl[aou]b: Move duping of slab name to slab_common.c"), the kernel automatically duplicates the slab cache name when creating the slab cache, so we no longer have to keep the name allocated. Remove the code that allocates the slab names and keeps them around. Signed-off-by: Mikulas Patocka <mpatocka@redhat.com> Signed-off-by: Mike Snitzer <snitzer@redhat.com>
1 parent afa53df commit eeb67a0

File tree

1 file changed

+3
-18
lines changed

1 file changed

+3
-18
lines changed

drivers/md/dm-bufio.c

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,6 @@ struct dm_buffer {
173173
/*----------------------------------------------------------------*/
174174

175175
static struct kmem_cache *dm_bufio_caches[PAGE_SHIFT - SECTOR_SHIFT];
176-
static char *dm_bufio_cache_names[PAGE_SHIFT - SECTOR_SHIFT];
177176

178177
static inline int dm_bufio_cache_index(struct dm_bufio_client *c)
179178
{
@@ -185,7 +184,6 @@ static inline int dm_bufio_cache_index(struct dm_bufio_client *c)
185184
}
186185

187186
#define DM_BUFIO_CACHE(c) (dm_bufio_caches[dm_bufio_cache_index(c)])
188-
#define DM_BUFIO_CACHE_NAME(c) (dm_bufio_cache_names[dm_bufio_cache_index(c)])
189187

190188
#define dm_bufio_in_request() (!!current->bio_list)
191189

@@ -1703,19 +1701,10 @@ struct dm_bufio_client *dm_bufio_client_create(struct block_device *bdev, unsign
17031701

17041702
mutex_lock(&dm_bufio_clients_lock);
17051703
if (c->blocks_per_page_bits) {
1706-
if (!DM_BUFIO_CACHE_NAME(c)) {
1707-
DM_BUFIO_CACHE_NAME(c) = kasprintf(GFP_KERNEL, "dm_bufio_cache-%u", c->block_size);
1708-
if (!DM_BUFIO_CACHE_NAME(c)) {
1709-
r = -ENOMEM;
1710-
mutex_unlock(&dm_bufio_clients_lock);
1711-
goto bad;
1712-
}
1713-
}
1714-
17151704
if (!DM_BUFIO_CACHE(c)) {
1716-
DM_BUFIO_CACHE(c) = kmem_cache_create(DM_BUFIO_CACHE_NAME(c),
1717-
c->block_size,
1718-
c->block_size, 0, NULL);
1705+
char name[26];
1706+
snprintf(name, sizeof name, "dm_bufio_cache-%u", c->block_size);
1707+
DM_BUFIO_CACHE(c) = kmem_cache_create(name, c->block_size, c->block_size, 0, NULL);
17191708
if (!DM_BUFIO_CACHE(c)) {
17201709
r = -ENOMEM;
17211710
mutex_unlock(&dm_bufio_clients_lock);
@@ -1908,7 +1897,6 @@ static int __init dm_bufio_init(void)
19081897
dm_bufio_current_allocated = 0;
19091898

19101899
memset(&dm_bufio_caches, 0, sizeof dm_bufio_caches);
1911-
memset(&dm_bufio_cache_names, 0, sizeof dm_bufio_cache_names);
19121900

19131901
mem = (__u64)mult_frac(totalram_pages - totalhigh_pages,
19141902
DM_BUFIO_MEMORY_PERCENT, 100) << PAGE_SHIFT;
@@ -1952,9 +1940,6 @@ static void __exit dm_bufio_exit(void)
19521940
for (i = 0; i < ARRAY_SIZE(dm_bufio_caches); i++)
19531941
kmem_cache_destroy(dm_bufio_caches[i]);
19541942

1955-
for (i = 0; i < ARRAY_SIZE(dm_bufio_cache_names); i++)
1956-
kfree(dm_bufio_cache_names[i]);
1957-
19581943
if (dm_bufio_client_count) {
19591944
DMCRIT("%s: dm_bufio_client_count leaked: %d",
19601945
__func__, dm_bufio_client_count);

0 commit comments

Comments
 (0)