linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] dm bufio: fully initialize shrinker
@ 2014-07-31 16:07 Greg Thelen
  2014-07-31 16:35 ` [dm-devel] " Mikulas Patocka
  0 siblings, 1 reply; 2+ messages in thread
From: Greg Thelen @ 2014-07-31 16:07 UTC (permalink / raw)
  To: Alasdair Kergon, Mike Snitzer, dm-devel
  Cc: Neil Brown, Andrew Morton, Vladimir Davydov, Dave Chinner,
	linux-raid, linux-mm, linux-kernel, 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 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>
---
 drivers/md/dm-bufio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/md/dm-bufio.c b/drivers/md/dm-bufio.c
index 4e84095833db..d724459860d9 100644
--- a/drivers/md/dm-bufio.c
+++ b/drivers/md/dm-bufio.c
@@ -1541,7 +1541,7 @@ struct dm_bufio_client *dm_bufio_client_create(struct block_device *bdev, unsign
 	BUG_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;
-- 
2.0.0.526.g5318336

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [dm-devel] [PATCH] dm bufio: fully initialize shrinker
  2014-07-31 16:07 [PATCH] dm bufio: fully initialize shrinker Greg Thelen
@ 2014-07-31 16:35 ` Mikulas Patocka
  0 siblings, 0 replies; 2+ messages in thread
From: Mikulas Patocka @ 2014-07-31 16:35 UTC (permalink / raw)
  To: device-mapper development
  Cc: Alasdair Kergon, Mike Snitzer, Vladimir Davydov, linux-kernel,
	linux-raid, linux-mm, Dave Chinner, Greg Thelen, Andrew Morton


On Thu, 31 Jul 2014, Greg Thelen wrote:

> 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>
Cc: stable@vger.kernel.org	#v3.12

> ---
>  drivers/md/dm-bufio.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/md/dm-bufio.c b/drivers/md/dm-bufio.c
> index 4e84095833db..d724459860d9 100644
> --- a/drivers/md/dm-bufio.c
> +++ b/drivers/md/dm-bufio.c
> @@ -1541,7 +1541,7 @@ struct dm_bufio_client *dm_bufio_client_create(struct block_device *bdev, unsign
>  	BUG_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;
> -- 
> 2.0.0.526.g5318336
> 
> --
> dm-devel mailing list
> dm-devel@redhat.com
> https://www.redhat.com/mailman/listinfo/dm-devel
> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-07-31 16:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-31 16:07 [PATCH] dm bufio: fully initialize shrinker Greg Thelen
2014-07-31 16:35 ` [dm-devel] " Mikulas Patocka

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).