Skip to content

Commit

Permalink
dm bufio: relax alignment constraint on slab cache
Browse files Browse the repository at this point in the history
The I/O buffer doesn't have to be aligned on block size granularity,
relax alignment to ARCH_KMALLOC_MINALIGN (required to allow DMA from
slab cache memory on some architectures).

Also, set SLAB_RECLAIM_ACCOUNT so that the memory allocated from the
cache is accounted as reclaimable and doesn't inflate the 'used' entry
in the free command.

Signed-off-by: Mikulas Patocka <[email protected]>
Signed-off-by: Mike Snitzer <[email protected]>
  • Loading branch information
Mikulas Patocka authored and snitm committed Apr 3, 2018
1 parent 21bb132 commit 6b5e718
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/md/dm-bufio.c
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,6 @@ static void use_inline_bio(struct dm_buffer *b, int rw, sector_t sector,
unsigned this_step = min((unsigned)(PAGE_SIZE - offset_in_page(ptr)), len);
if (!bio_add_page(&b->bio, virt_to_page(ptr), this_step,
offset_in_page(ptr))) {
BUG_ON(b->c->block_size <= PAGE_SIZE);
use_dmio(b, rw, sector, n_sectors, offset, end_io);
return;
}
Expand Down Expand Up @@ -1686,7 +1685,8 @@ struct dm_bufio_client *dm_bufio_client_create(struct block_device *bdev, unsign
if (block_size < PAGE_SIZE) {
char name[26];
snprintf(name, sizeof name, "dm_bufio_cache-%u", c->block_size);
c->slab_cache = kmem_cache_create(name, c->block_size, c->block_size, 0, NULL);
c->slab_cache = kmem_cache_create(name, c->block_size, ARCH_KMALLOC_MINALIGN,
SLAB_RECLAIM_ACCOUNT, NULL);
if (!c->slab_cache) {
r = -ENOMEM;
goto bad;
Expand Down

0 comments on commit 6b5e718

Please sign in to comment.