dm bufio: fully initialize shrinker
Subsystems (3)
PATCH 1/1 dm bufio: fully initialize shrinker
1d3d4437eae1 ("vmscan: per-node deferred work") added a flags field to struct shrinker assuming that all shrinkers were zero filled. The dm bufio shrinker is not zero filled, which leaves arbitrary kmalloc() data in flags. So far the only defined flags bit is SHRINKER_NUMA_AWARE. But there are proposed patches which add other bits to shrinker.flags (e.g. memcg awareness).
Rather than simply initializing the shrinker, this patch uses kzalloc() when allocating the dm_bufio_client to ensure that the embedded shrinker and any other similar structures are zeroed.
This fixes theoretical over aggressive shrinking of dm bufio objects. If the uninitialized dm_bufio_client.shrinker.flags contains SHRINKER_NUMA_AWARE then shrink_slab() would call the dm shrinker for each numa node rather than just once. This has been broken since 3.12.
--- drivers/md/dm-bufio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/md/dm-bufio.c +1 -1
@@ -1541,7 +1541,7 @@ struct dm_bufio_client *dm_bufio_client_create(struct block_device *bdev, unsignBUG_ON (block_size <1 <<SECTOR_SHIFT || (block_size & (block_size -1 ))); - c =kmalloc (sizeof (*c),GFP_KERNEL ); + c =kzalloc (sizeof (*c),GFP_KERNEL );if (!c) { r = -ENOMEM ; goto bad_client;
Signature · 7 lines
2.0.0.526.g5318336 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 11 lines · Greg Thelen
1d3d4437eae1("vmscan: per-node deferred work") added a flags field to struct shrinker assuming that all shrinkers were zero filled. The dm bufio shrinker is not zero filled, which leaves arbitrarykmalloc()data in flags. So far the only defined flags bit isSHRINKER_NUMA_AWARE. But there are proposed patches which add other bits to shrinker.flags (e.g. memcg awareness).Rather than simply initializing the shrinker, this patch uses
kzalloc()when allocating thedm_bufio_clientto ensure that the embedded shrinker and any other similar structures are zeroed.
Quoted 6 lines
This fixes theoretical over aggressive shrinking of dm bufio objects. If the uninitialized dm_bufio_client.shrinker.flags contains
SHRINKER_NUMA_AWAREthenshrink_slab()would call the dm shrinker for each numa node rather than just once. This has been broken since 3.12.Signed-off-by Greg Thelen <[email protected]>
Quoted 25 lines
--- drivers/md/dm-bufio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/md/dm-bufio.c +1
-1@@ -1541,7 +1541,7 @@ struct dm_bufio_client *dm_bufio_client_create(struct block_device *bdev, unsignBUG_ON (block_size <1 <<SECTOR_SHIFT || (block_size & (block_size -1 ))); - c =kmalloc (sizeof (*c),GFP_KERNEL ); + c =kzalloc (sizeof (*c),GFP_KERNEL );if (!c) { r = -ENOMEM ; goto bad_client;Signature · 6 lines
2.0.0.526.g5318336 -- dm-devel mailing list [email protected] https://www.redhat.com/mailman/listinfo/dm-devel