Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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.

Signed-off-by: Greg Thelen <gthelen@google.com>
Acked-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Cc: stable@vger.kernel.org # v3.12+

authored by

Greg Thelen and committed by
Mike Snitzer
d8c712ea 64aa90f2

+1 -1
+1 -1
drivers/md/dm-bufio.c
··· 1541 1541 BUG_ON(block_size < 1 << SECTOR_SHIFT || 1542 1542 (block_size & (block_size - 1))); 1543 1543 1544 - c = kmalloc(sizeof(*c), GFP_KERNEL); 1544 + c = kzalloc(sizeof(*c), GFP_KERNEL); 1545 1545 if (!c) { 1546 1546 r = -ENOMEM; 1547 1547 goto bad_client;